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 |
35 | 36 |
36 | 37 |
37 FAKE_SOURCE_REPO_DIR = '/blink' | 38 FAKE_SOURCE_REPO_DIR = '/blink' |
38 | 39 |
39 FAKE_FILES = { | 40 FAKE_FILES = { |
40 '/mock-checkout/third_party/Webkit/LayoutTests/w3c/OWNERS': '', | 41 '/mock-checkout/third_party/Webkit/LayoutTests/w3c/OWNERS': '', |
41 '/blink/w3c/dir/has_shebang.txt': '#!', | 42 '/blink/w3c/dir/has_shebang.txt': '#!', |
42 '/blink/w3c/dir/README.txt': '', | 43 '/blink/w3c/dir/README.txt': '', |
43 '/blink/w3c/dir/OWNERS': '', | 44 '/blink/w3c/dir/OWNERS': '', |
44 '/blink/w3c/dir/reftest.list': '', | 45 '/blink/w3c/dir/reftest.list': '', |
45 '/blink/w3c/dir1/OWNERS': '', | 46 '/blink/w3c/dir1/OWNERS': '', |
46 '/blink/w3c/dir1/reftest.list': '', | 47 '/blink/w3c/dir1/reftest.list': '', |
47 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', | 48 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', |
48 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', | 49 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 class TestImporterTest(unittest.TestCase): | 53 class TestImporterTest(LoggingTestCase): |
53 | 54 |
54 @staticmethod | 55 @staticmethod |
55 def options(**kwargs): | 56 def options(**kwargs): |
56 """Returns a set of option values for TestImporter.""" | 57 """Returns a set of option values for TestImporter.""" |
57 options = { | 58 options = { |
58 "overwrite": False, | 59 "overwrite": False, |
59 "destination": "w3c", | 60 "destination": "w3c", |
60 "ignore_expectations": False, | 61 "ignore_expectations": False, |
61 "dry_run": False, | 62 "dry_run": False, |
62 } | 63 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 host = MockHost() | 159 host = MockHost() |
159 host.filesystem = MockFileSystem(files={ | 160 host.filesystem = MockFileSystem(files={ |
160 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', | 161 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', |
161 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', | 162 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', |
162 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in'
: '', | 163 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in'
: '', |
163 }) | 164 }) |
164 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) | 165 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) |
165 importer.find_importable_tests() | 166 importer.find_importable_tests() |
166 self.assertEqual(importer.import_list, []) | 167 self.assertEqual(importer.import_list, []) |
167 | 168 |
| 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 |
168 def test_should_try_to_convert_positive_cases(self): | 192 def test_should_try_to_convert_positive_cases(self): |
169 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.css', 'Layou
tTests/imported/csswg-test/x')) | 193 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.css', 'Layou
tTests/imported/csswg-test/x')) |
170 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.htm', 'Layou
tTests/imported/csswg-test/x')) | 194 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.htm', 'Layou
tTests/imported/csswg-test/x')) |
171 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.html', 'Layo
utTests/imported/csswg-test/x')) | 195 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.html', 'Layo
utTests/imported/csswg-test/x')) |
172 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xht', 'Layou
tTests/imported/csswg-test/x')) | 196 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xht', 'Layou
tTests/imported/csswg-test/x')) |
173 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xhtml', 'Lay
outTests/imported/csswg-test/x')) | 197 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xhtml', 'Lay
outTests/imported/csswg-test/x')) |
174 | 198 |
175 def test_should_not_try_to_convert_js_test(self): | 199 def test_should_not_try_to_convert_js_test(self): |
176 self.assertFalse(TestImporter.should_try_to_convert({'is_jstest': True},
'foo.html', 'LayoutTests/imported/csswg-test/x')) | 200 self.assertFalse(TestImporter.should_try_to_convert({'is_jstest': True},
'foo.html', 'LayoutTests/imported/csswg-test/x')) |
177 | 201 |
178 def test_should_not_try_to_convert_test_in_wpt(self): | 202 def test_should_not_try_to_convert_test_in_wpt(self): |
179 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.html', 'Lay
outTests/imported/wpt/foo')) | 203 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.html', 'Lay
outTests/imported/wpt/foo')) |
180 | 204 |
181 def test_should_not_try_to_convert_other_file_types(self): | 205 def test_should_not_try_to_convert_other_file_types(self): |
182 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.bar', 'Layo
utTests/imported/csswg-test/x')) | 206 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.bar', 'Layo
utTests/imported/csswg-test/x')) |
183 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.js', 'Layou
tTests/imported/csswg-test/x')) | 207 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.js', 'Layou
tTests/imported/csswg-test/x')) |
184 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.md', 'Layou
tTests/imported/csswg-test/x')) | 208 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.md', 'Layou
tTests/imported/csswg-test/x')) |
185 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.png', 'Layo
utTests/imported/csswg-test/x')) | 209 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.png', 'Layo
utTests/imported/csswg-test/x')) |
186 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svg', 'Layo
utTests/imported/csswg-test/x')) | 210 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svg', 'Layo
utTests/imported/csswg-test/x')) |
187 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svgz', 'Lay
outTests/imported/csswg-test/x')) | 211 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svgz', 'Lay
outTests/imported/csswg-test/x')) |
OLD | NEW |