OLD | NEW |
1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 1 # Copyright (C) 2013 Adobe Systems Incorporated. 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 | 4 # modification, are permitted provided that the following conditions |
5 # are met: | 5 # are met: |
6 # | 6 # |
7 # 1. Redistributions of source code must retain the above | 7 # 1. Redistributions of source code must retain the above |
8 # copyright notice, this list of conditions and the following | 8 # copyright notice, this list of conditions and the following |
9 # disclaimer. | 9 # disclaimer. |
10 # 2. Redistributions in binary form must reproduce the above | 10 # 2. Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 # SUCH DAMAGE. | 26 # SUCH DAMAGE. |
27 | 27 |
28 import optparse | 28 import optparse |
29 import unittest | 29 import unittest |
30 | 30 |
31 from webkitpy.common.host_mock import MockHost | 31 from webkitpy.common.host_mock import MockHost |
32 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError | 32 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError |
33 from webkitpy.common.system.filesystem_mock import MockFileSystem | 33 from webkitpy.common.system.filesystem_mock import MockFileSystem |
34 from webkitpy.w3c.test_importer import TestImporter | 34 from webkitpy.w3c.test_importer import TestImporter |
35 from webkitpy.common.system.log_testing import LoggingTestCase | |
36 | 35 |
37 | 36 |
38 FAKE_SOURCE_REPO_DIR = '/blink' | 37 FAKE_SOURCE_REPO_DIR = '/blink' |
39 | 38 |
40 FAKE_FILES = { | 39 FAKE_FILES = { |
41 '/mock-checkout/third_party/Webkit/LayoutTests/w3c/OWNERS': '', | 40 '/mock-checkout/third_party/Webkit/LayoutTests/w3c/OWNERS': '', |
42 '/blink/w3c/dir/has_shebang.txt': '#!', | 41 '/blink/w3c/dir/has_shebang.txt': '#!', |
43 '/blink/w3c/dir/README.txt': '', | 42 '/blink/w3c/dir/README.txt': '', |
44 '/blink/w3c/dir/OWNERS': '', | 43 '/blink/w3c/dir/OWNERS': '', |
45 '/blink/w3c/dir/reftest.list': '', | 44 '/blink/w3c/dir/reftest.list': '', |
46 '/blink/w3c/dir1/OWNERS': '', | 45 '/blink/w3c/dir1/OWNERS': '', |
47 '/blink/w3c/dir1/reftest.list': '', | 46 '/blink/w3c/dir1/reftest.list': '', |
48 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', | 47 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', |
49 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', | 48 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', |
50 } | 49 } |
51 | 50 |
52 | 51 |
53 class TestImporterTest(LoggingTestCase): | 52 class TestImporterTest(unittest.TestCase): |
54 | 53 |
55 @staticmethod | 54 @staticmethod |
56 def options(**kwargs): | 55 def options(**kwargs): |
57 """Returns a set of option values for TestImporter.""" | 56 """Returns a set of option values for TestImporter.""" |
58 options = { | 57 options = { |
59 "overwrite": False, | 58 "overwrite": False, |
60 "destination": "w3c", | 59 "destination": "w3c", |
61 "ignore_expectations": False, | 60 "ignore_expectations": False, |
62 "dry_run": False, | 61 "dry_run": False, |
63 } | 62 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 host = MockHost() | 158 host = MockHost() |
160 host.filesystem = MockFileSystem(files={ | 159 host.filesystem = MockFileSystem(files={ |
161 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', | 160 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', |
162 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', | 161 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', |
163 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in'
: '', | 162 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in'
: '', |
164 }) | 163 }) |
165 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) | 164 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) |
166 importer.find_importable_tests() | 165 importer.find_importable_tests() |
167 self.assertEqual(importer.import_list, []) | 166 self.assertEqual(importer.import_list, []) |
168 | 167 |
169 def test_large_files_are_skipped(self): | |
170 host = MockHost() | |
171 host.filesystem = MockFileSystem(files={ | |
172 '/blink/w3c/dir1/my-large-test.html': '...', | |
173 '/blink/w3c/dir1/my-small-test.html': '...', | |
174 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', | |
175 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in'
: '', | |
176 }) | |
177 | |
178 def getsize(path): | |
179 if 'large' in path: | |
180 return 1000000 | |
181 return 100 | |
182 host.filesystem.getsize = getsize | |
183 | |
184 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) | |
185 importer.do_import() | |
186 self.assertIn('ERROR: /blink/w3c/dir1/my-large-test.html is too large (1
000000 bytes)\n', self.logMessages()) | |
187 self.assertTrue(host.filesystem.exists( | |
188 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/blink/w3c/dir1/my
-small-test.html')) | |
189 self.assertFalse(host.filesystem.exists( | |
190 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/blink/w3c/dir1/my
-large-test.html')) | |
191 | |
192 def test_should_try_to_convert_positive_cases(self): | 168 def test_should_try_to_convert_positive_cases(self): |
193 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.css', 'Layou
tTests/imported/csswg-test/x')) | 169 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.css', 'Layou
tTests/imported/csswg-test/x')) |
194 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.htm', 'Layou
tTests/imported/csswg-test/x')) | 170 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.htm', 'Layou
tTests/imported/csswg-test/x')) |
195 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.html', 'Layo
utTests/imported/csswg-test/x')) | 171 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.html', 'Layo
utTests/imported/csswg-test/x')) |
196 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xht', 'Layou
tTests/imported/csswg-test/x')) | 172 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xht', 'Layou
tTests/imported/csswg-test/x')) |
197 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xhtml', 'Lay
outTests/imported/csswg-test/x')) | 173 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xhtml', 'Lay
outTests/imported/csswg-test/x')) |
198 | 174 |
199 def test_should_not_try_to_convert_js_test(self): | 175 def test_should_not_try_to_convert_js_test(self): |
200 self.assertFalse(TestImporter.should_try_to_convert({'is_jstest': True},
'foo.html', 'LayoutTests/imported/csswg-test/x')) | 176 self.assertFalse(TestImporter.should_try_to_convert({'is_jstest': True},
'foo.html', 'LayoutTests/imported/csswg-test/x')) |
201 | 177 |
202 def test_should_not_try_to_convert_test_in_wpt(self): | 178 def test_should_not_try_to_convert_test_in_wpt(self): |
203 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.html', 'Lay
outTests/imported/wpt/foo')) | 179 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.html', 'Lay
outTests/imported/wpt/foo')) |
204 | 180 |
205 def test_should_not_try_to_convert_other_file_types(self): | 181 def test_should_not_try_to_convert_other_file_types(self): |
206 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.bar', 'Layo
utTests/imported/csswg-test/x')) | 182 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.bar', 'Layo
utTests/imported/csswg-test/x')) |
207 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.js', 'Layou
tTests/imported/csswg-test/x')) | 183 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.js', 'Layou
tTests/imported/csswg-test/x')) |
208 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.md', 'Layou
tTests/imported/csswg-test/x')) | 184 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.md', 'Layou
tTests/imported/csswg-test/x')) |
209 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.png', 'Layo
utTests/imported/csswg-test/x')) | 185 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.png', 'Layo
utTests/imported/csswg-test/x')) |
210 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svg', 'Layo
utTests/imported/csswg-test/x')) | 186 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svg', 'Layo
utTests/imported/csswg-test/x')) |
211 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svgz', 'Lay
outTests/imported/csswg-test/x')) | 187 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svgz', 'Lay
outTests/imported/csswg-test/x')) |
OLD | NEW |