OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 def to_raw_bytes(string_value): | 519 def to_raw_bytes(string_value): |
520 if isinstance(string_value, unicode): | 520 if isinstance(string_value, unicode): |
521 return string_value.encode('utf-8') | 521 return string_value.encode('utf-8') |
522 return string_value | 522 return string_value |
523 expected_filename = to_raw_bytes(expected_filename) | 523 expected_filename = to_raw_bytes(expected_filename) |
524 actual_filename = to_raw_bytes(actual_filename) | 524 actual_filename = to_raw_bytes(actual_filename) |
525 diff = difflib.unified_diff(expected_text.splitlines(True), | 525 diff = difflib.unified_diff(expected_text.splitlines(True), |
526 actual_text.splitlines(True), | 526 actual_text.splitlines(True), |
527 expected_filename, | 527 expected_filename, |
528 actual_filename) | 528 actual_filename) |
529 return ''.join(diff) | 529 |
| 530 # The diff generated by the difflib is incorrect if one of the files |
| 531 # does not have a newline at the end of the file and it is present in |
| 532 # the diff. Relevant Python issue: http://bugs.python.org/issue2142 |
| 533 def diff_fixup(diff): |
| 534 for line in diff: |
| 535 yield line |
| 536 if not line.endswith('\n'): |
| 537 yield '\n\ No newline at end of file\n' |
| 538 |
| 539 return ''.join(diff_fixup(diff)) |
530 | 540 |
531 def driver_name(self): | 541 def driver_name(self): |
532 if self.get_option('driver_name'): | 542 if self.get_option('driver_name'): |
533 return self.get_option('driver_name') | 543 return self.get_option('driver_name') |
534 return self.CONTENT_SHELL_NAME | 544 return self.CONTENT_SHELL_NAME |
535 | 545 |
536 def expected_baselines_by_extension(self, test_name): | 546 def expected_baselines_by_extension(self, test_name): |
537 """Returns a dict mapping baseline suffix to relative path for each base
line in | 547 """Returns a dict mapping baseline suffix to relative path for each base
line in |
538 a test. For reftests, it returns ".==" or ".!=" instead of the suffix.""
" | 548 a test. For reftests, it returns ".==" or ".!=" instead of the suffix.""
" |
539 # FIXME: The name similarity between this and expected_baselines() below
, is unfortunate. | 549 # FIXME: The name similarity between this and expected_baselines() below
, is unfortunate. |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 | 1772 |
1763 class PhysicalTestSuite(object): | 1773 class PhysicalTestSuite(object): |
1764 def __init__(self, base, args): | 1774 def __init__(self, base, args): |
1765 self.name = base | 1775 self.name = base |
1766 self.base = base | 1776 self.base = base |
1767 self.args = args | 1777 self.args = args |
1768 self.tests = set() | 1778 self.tests = set() |
1769 | 1779 |
1770 def __repr__(self): | 1780 def __repr__(self): |
1771 return "PhysicalTestSuite('%s', '%s', %s)" % (self.name, self.base, self
.args) | 1781 return "PhysicalTestSuite('%s', '%s', %s)" % (self.name, self.base, self
.args) |
OLD | NEW |