OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze
ged | 2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze
ged |
3 # Copyright (C) 2011 Apple Inc. All rights reserved. | 3 # Copyright (C) 2011 Apple Inc. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 26 matching lines...) Expand all Loading... |
37 import unittest | 37 import unittest |
38 | 38 |
39 from webkitpy.common.system import outputcapture, path | 39 from webkitpy.common.system import outputcapture, path |
40 from webkitpy.common.system.crashlogs_unittest import make_mock_crash_report_dar
win | 40 from webkitpy.common.system.crashlogs_unittest import make_mock_crash_report_dar
win |
41 from webkitpy.common.system.systemhost import SystemHost | 41 from webkitpy.common.system.systemhost import SystemHost |
42 from webkitpy.common.host import Host | 42 from webkitpy.common.host import Host |
43 from webkitpy.common.host_mock import MockHost | 43 from webkitpy.common.host_mock import MockHost |
44 | 44 |
45 from webkitpy.layout_tests import port | 45 from webkitpy.layout_tests import port |
46 from webkitpy.layout_tests import run_webkit_tests | 46 from webkitpy.layout_tests import run_webkit_tests |
| 47 from webkitpy.layout_tests.models import test_expectations |
| 48 from webkitpy.layout_tests.models import test_failures |
47 from webkitpy.layout_tests.models import test_run_results | 49 from webkitpy.layout_tests.models import test_run_results |
48 from webkitpy.layout_tests.port import test | 50 from webkitpy.layout_tests.port import test |
49 from webkitpy.layout_tests.port.base import Port | 51 from webkitpy.layout_tests.port.base import Port |
50 from webkitpy.tool import grammar | 52 from webkitpy.tool import grammar |
51 from webkitpy.tool.mocktool import MockOptions | 53 from webkitpy.tool.mocktool import MockOptions |
52 | 54 |
53 | 55 |
54 def parse_args(extra_args=None, tests_included=False, new_results=False, print_n
othing=True): | 56 def parse_args(extra_args=None, tests_included=False, new_results=False, print_n
othing=True): |
55 extra_args = extra_args or [] | 57 extra_args = extra_args or [] |
56 args = [] | 58 args = [] |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 test_name = 'virtual/references_use_default_args/passes/reftest.html' | 820 test_name = 'virtual/references_use_default_args/passes/reftest.html' |
819 run_details, err, _ = logging_run(['--details', test_name], tests_includ
ed=True) | 821 run_details, err, _ = logging_run(['--details', test_name], tests_includ
ed=True) |
820 self.assertEqual(run_details.exit_code, 0) | 822 self.assertEqual(run_details.exit_code, 0) |
821 self.assertEqual(run_details.initial_results.total, 1) | 823 self.assertEqual(run_details.initial_results.total, 1) |
822 test_result = run_details.initial_results.all_results[0] | 824 test_result = run_details.initial_results.all_results[0] |
823 self.assertEqual(test_result.test_name, test_name) | 825 self.assertEqual(test_result.test_name, test_name) |
824 self.assertEqual(test_result.references[0], 'passes/reftest-expected.htm
l') | 826 self.assertEqual(test_result.references[0], 'passes/reftest-expected.htm
l') |
825 # reference_args should be empty since we are using the default flags. | 827 # reference_args should be empty since we are using the default flags. |
826 self.assertTrue(re.search('reference_args:\s*ref:', err.getvalue())) | 828 self.assertTrue(re.search('reference_args:\s*ref:', err.getvalue())) |
827 | 829 |
| 830 def test_reftest_matching_text_expectation(self): |
| 831 test_name = 'passes/reftest.html' |
| 832 host = MockHost() |
| 833 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/passes/reftest-
expected.txt', 'reftest') |
| 834 run_details, err, _ = logging_run([test_name], tests_included=True, host
=host) |
| 835 self.assertEqual(run_details.exit_code, 0) |
| 836 self.assertEqual(run_details.initial_results.total, 1) |
| 837 test_result = run_details.initial_results.all_results[0] |
| 838 self.assertEqual(test_result.test_name, test_name) |
| 839 self.assertEqual(len(test_result.failures), 0) |
| 840 |
| 841 def test_reftest_mismatching_text_expectation(self): |
| 842 test_name = 'passes/reftest.html' |
| 843 host = MockHost() |
| 844 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/passes/reftest-
expected.txt', 'mismatch') |
| 845 run_details, err, _ = logging_run([test_name], tests_included=True, host
=host) |
| 846 self.assertNotEqual(run_details.exit_code, 0) |
| 847 self.assertEqual(run_details.initial_results.total, 1) |
| 848 test_result = run_details.initial_results.all_results[0] |
| 849 self.assertEqual(test_result.test_name, test_name) |
| 850 self.assertEqual(len(test_result.failures), 1) |
| 851 self.assertEqual(test_failures.determine_result_type(test_result.failure
s), test_expectations.TEXT) |
| 852 |
| 853 def test_reftest_mismatching_pixel_matching_text(self): |
| 854 test_name = 'failures/unexpected/reftest.html' |
| 855 host = MockHost() |
| 856 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/failures/unexpe
cted/reftest-expected.txt', 'reftest') |
| 857 run_details, err, _ = logging_run([test_name], tests_included=True, host
=host) |
| 858 self.assertNotEqual(run_details.exit_code, 0) |
| 859 self.assertEqual(run_details.initial_results.total, 1) |
| 860 test_result = run_details.initial_results.all_results[0] |
| 861 self.assertEqual(test_result.test_name, test_name) |
| 862 self.assertEqual(len(test_result.failures), 1) |
| 863 self.assertEqual(test_failures.determine_result_type(test_result.failure
s), test_expectations.IMAGE) |
| 864 |
| 865 def test_reftest_mismatching_both_text_and_pixel(self): |
| 866 test_name = 'failures/unexpected/reftest.html' |
| 867 host = MockHost() |
| 868 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/failures/unexpe
cted/reftest-expected.txt', 'mismatch') |
| 869 run_details, err, _ = logging_run([test_name], tests_included=True, host
=host) |
| 870 self.assertNotEqual(run_details.exit_code, 0) |
| 871 self.assertEqual(run_details.initial_results.total, 1) |
| 872 test_result = run_details.initial_results.all_results[0] |
| 873 self.assertEqual(test_result.test_name, test_name) |
| 874 self.assertEqual(len(test_result.failures), 2) |
| 875 self.assertEqual(test_failures.determine_result_type(test_result.failure
s), test_expectations.IMAGE_PLUS_TEXT) |
| 876 |
828 def test_additional_platform_directory(self): | 877 def test_additional_platform_directory(self): |
829 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/fo
o'])) | 878 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/fo
o'])) |
830 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/..
/foo'])) | 879 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/..
/foo'])) |
831 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/fo
o', '--additional-platform-directory', '/tmp/bar'])) | 880 self.assertTrue(passing_run(['--additional-platform-directory', '/tmp/fo
o', '--additional-platform-directory', '/tmp/bar'])) |
832 self.assertTrue(passing_run(['--additional-platform-directory', 'foo'])) | 881 self.assertTrue(passing_run(['--additional-platform-directory', 'foo'])) |
833 | 882 |
834 def test_additional_expectations(self): | 883 def test_additional_expectations(self): |
835 host = MockHost() | 884 host = MockHost() |
836 host.filesystem.write_text_file('/tmp/overrides.txt', 'Bug(x) failures/u
nexpected/mismatch.html [ Failure ]\n') | 885 host.filesystem.write_text_file('/tmp/overrides.txt', 'Bug(x) failures/u
nexpected/mismatch.html [ Failure ]\n') |
837 self.assertTrue(passing_run(['--additional-expectations', '/tmp/override
s.txt', 'failures/unexpected/mismatch.html'], | 886 self.assertTrue(passing_run(['--additional-expectations', '/tmp/override
s.txt', 'failures/unexpected/mismatch.html'], |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 ['--pixel-tests', '--new-baseline', 'passes/image.html', 'failures/e
xpected/missing_image.html'], | 1109 ['--pixel-tests', '--new-baseline', 'passes/image.html', 'failures/e
xpected/missing_image.html'], |
1061 tests_included=True, host=host, new_results=True) | 1110 tests_included=True, host=host, new_results=True) |
1062 file_list = host.filesystem.written_files.keys() | 1111 file_list = host.filesystem.written_files.keys() |
1063 self.assertEqual(details.exit_code, 0) | 1112 self.assertEqual(details.exit_code, 0) |
1064 self.assertEqual(len(file_list), 9) | 1113 self.assertEqual(len(file_list), 9) |
1065 self.assertBaselines(file_list, | 1114 self.assertBaselines(file_list, |
1066 "platform/test-mac-mac10.10/passes/image", [".txt",
".png"], err) | 1115 "platform/test-mac-mac10.10/passes/image", [".txt",
".png"], err) |
1067 self.assertBaselines(file_list, | 1116 self.assertBaselines(file_list, |
1068 "platform/test-mac-mac10.10/failures/expected/missi
ng_image", [".txt", ".png"], err) | 1117 "platform/test-mac-mac10.10/failures/expected/missi
ng_image", [".txt", ".png"], err) |
1069 | 1118 |
| 1119 def test_reftest_reset_results(self): |
| 1120 # Test rebaseline of reftests. |
| 1121 # Should ignore reftests without text expectations. |
| 1122 host = MockHost() |
| 1123 details, err, _ = logging_run(['--reset-results', 'passes/reftest.html']
, tests_included=True, host=host) |
| 1124 file_list = host.filesystem.written_files.keys() |
| 1125 self.assertEqual(details.exit_code, 0) |
| 1126 self.assertEqual(len(file_list), 5) |
| 1127 self.assertBaselines(file_list, '', [], err) |
| 1128 |
| 1129 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/passes/reftest-
expected.txt', '') |
| 1130 host.filesystem.clear_written_files() |
| 1131 details, err, _ = logging_run(['--reset-results', 'passes/reftest.html']
, tests_included=True, host=host) |
| 1132 file_list = host.filesystem.written_files.keys() |
| 1133 self.assertEqual(details.exit_code, 0) |
| 1134 self.assertEqual(len(file_list), 6) |
| 1135 self.assertBaselines(file_list, 'passes/reftest', ['.txt'], err) |
| 1136 |
| 1137 def test_reftest_new_baseline(self): |
| 1138 # Test rebaseline of reftests. |
| 1139 # Should ignore reftests without text expectations. |
| 1140 host = MockHost() |
| 1141 details, err, _ = logging_run(['--new-baseline', 'passes/reftest.html'],
tests_included=True, host=host) |
| 1142 file_list = host.filesystem.written_files.keys() |
| 1143 self.assertEqual(details.exit_code, 0) |
| 1144 self.assertEqual(len(file_list), 5) |
| 1145 self.assertBaselines(file_list, '', [], err) |
| 1146 |
| 1147 host.filesystem.write_text_file(test.LAYOUT_TEST_DIR + '/passes/reftest-
expected.txt', '') |
| 1148 host.filesystem.clear_written_files() |
| 1149 details, err, _ = logging_run(['--new-baseline', 'passes/reftest.html'],
tests_included=True, host=host) |
| 1150 file_list = host.filesystem.written_files.keys() |
| 1151 self.assertEqual(details.exit_code, 0) |
| 1152 self.assertEqual(len(file_list), 6) |
| 1153 self.assertBaselines(file_list, 'platform/test-mac-mac10.10/passes/refte
st', ['.txt'], err) |
| 1154 |
1070 | 1155 |
1071 class PortTest(unittest.TestCase): | 1156 class PortTest(unittest.TestCase): |
1072 | 1157 |
1073 def assert_mock_port_works(self, port_name, args=[]): | 1158 def assert_mock_port_works(self, port_name, args=[]): |
1074 self.assertTrue(passing_run(args + ['--platform', 'mock-' + port_name, | 1159 self.assertTrue(passing_run(args + ['--platform', 'mock-' + port_name, |
1075 'fast/harness/results.html'], tests_
included=True, host=Host())) | 1160 'fast/harness/results.html'], tests_
included=True, host=Host())) |
1076 | 1161 |
1077 def disabled_test_mac_lion(self): | 1162 def disabled_test_mac_lion(self): |
1078 self.assert_mock_port_works('mac-lion') | 1163 self.assert_mock_port_works('mac-lion') |
1079 | 1164 |
(...skipping 26 matching lines...) Expand all Loading... |
1106 | 1191 |
1107 run_webkit_tests._run_tests = successful_run | 1192 run_webkit_tests._run_tests = successful_run |
1108 res = run_webkit_tests.main(['--platform', 'test'], stdout, stderr) | 1193 res = run_webkit_tests.main(['--platform', 'test'], stdout, stderr) |
1109 self.assertEqual(res, test_run_results.UNEXPECTED_ERROR_EXIT_STATUS) | 1194 self.assertEqual(res, test_run_results.UNEXPECTED_ERROR_EXIT_STATUS) |
1110 | 1195 |
1111 run_webkit_tests._run_tests = exception_raising_run | 1196 run_webkit_tests._run_tests = exception_raising_run |
1112 res = run_webkit_tests.main([], stdout, stderr) | 1197 res = run_webkit_tests.main([], stdout, stderr) |
1113 self.assertEqual(res, test_run_results.UNEXPECTED_ERROR_EXIT_STATUS) | 1198 self.assertEqual(res, test_run_results.UNEXPECTED_ERROR_EXIT_STATUS) |
1114 finally: | 1199 finally: |
1115 run_webkit_tests._run_tests = orig_run_fn | 1200 run_webkit_tests._run_tests = orig_run_fn |
OLD | NEW |