Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_copier_unittest.py

Issue 2656903002: Move test_importer -> test_copier, deps_updater -> test_importer. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 24 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
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 unittest 28 import unittest
29 29
30 from webkitpy.common.host_mock import MockHost 30 from webkitpy.common.host_mock import MockHost
31 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError 31 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError
32 from webkitpy.common.system.filesystem_mock import MockFileSystem 32 from webkitpy.common.system.filesystem_mock import MockFileSystem
33 from webkitpy.w3c.test_importer import TestImporter 33 from webkitpy.w3c.test_copier import TestCopier
34 34
35 35
36 FAKE_SOURCE_REPO_DIR = '/blink' 36 FAKE_SOURCE_REPO_DIR = '/blink'
37 37
38 FAKE_FILES = { 38 FAKE_FILES = {
39 '/mock-checkout/third_party/Webkit/LayoutTests/external/OWNERS': '', 39 '/mock-checkout/third_party/Webkit/LayoutTests/external/OWNERS': '',
40 '/blink/w3c/dir/has_shebang.txt': '#!', 40 '/blink/w3c/dir/has_shebang.txt': '#!',
41 '/blink/w3c/dir/README.txt': '', 41 '/blink/w3c/dir/README.txt': '',
42 '/blink/w3c/dir/OWNERS': '', 42 '/blink/w3c/dir/OWNERS': '',
43 '/blink/w3c/dir/reftest.list': '', 43 '/blink/w3c/dir/reftest.list': '',
44 '/blink/w3c/dir1/OWNERS': '', 44 '/blink/w3c/dir1/OWNERS': '',
45 '/blink/w3c/dir1/reftest.list': '', 45 '/blink/w3c/dir1/reftest.list': '',
46 '/mock-checkout/third_party/WebKit/LayoutTests/external/README.txt': '', 46 '/mock-checkout/third_party/WebKit/LayoutTests/external/README.txt': '',
47 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', 47 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '',
48 } 48 }
49 49
50 50
51 class TestImporterTest(unittest.TestCase): 51 class TestCopierTest(unittest.TestCase):
52 52
53 def test_import_dir_with_no_tests(self): 53 def test_import_dir_with_no_tests(self):
54 host = MockHost() 54 host = MockHost()
55 host.executive = MockExecutive(exception=ScriptError('error')) 55 host.executive = MockExecutive(exception=ScriptError('error'))
56 host.filesystem = MockFileSystem(files=FAKE_FILES) 56 host.filesystem = MockFileSystem(files=FAKE_FILES)
57 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, 'destination') 57 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR, 'destination')
58 importer.do_import() # No exception raised. 58 copier.do_import() # No exception raised.
59 59
60 def test_path_too_long_true(self): 60 def test_path_too_long_true(self):
61 host = MockHost() 61 host = MockHost()
62 host.filesystem = MockFileSystem(files=FAKE_FILES) 62 host.filesystem = MockFileSystem(files=FAKE_FILES)
63 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 63 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
64 self.assertTrue(importer.path_too_long(FAKE_SOURCE_REPO_DIR + '/' + ('x' * 150) + '.html')) 64 self.assertTrue(copier.path_too_long(FAKE_SOURCE_REPO_DIR + '/' + ('x' * 150) + '.html'))
65 65
66 def test_path_too_long_false(self): 66 def test_path_too_long_false(self):
67 host = MockHost() 67 host = MockHost()
68 host.filesystem = MockFileSystem(files=FAKE_FILES) 68 host.filesystem = MockFileSystem(files=FAKE_FILES)
69 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 69 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
70 self.assertFalse(importer.path_too_long(FAKE_SOURCE_REPO_DIR + '/x.html' )) 70 self.assertFalse(copier.path_too_long(FAKE_SOURCE_REPO_DIR + '/x.html'))
71 71
72 def test_does_not_import_owner_files(self): 72 def test_does_not_import_owner_files(self):
73 host = MockHost() 73 host = MockHost()
74 host.filesystem = MockFileSystem(files=FAKE_FILES) 74 host.filesystem = MockFileSystem(files=FAKE_FILES)
75 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 75 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
76 importer.find_importable_tests() 76 copier.find_importable_tests()
77 self.assertEqual( 77 self.assertEqual(
78 importer.import_list, 78 copier.import_list,
79 [ 79 [
80 { 80 {
81 'copy_list': [ 81 'copy_list': [
82 {'dest': 'has_shebang.txt', 'src': '/blink/w3c/dir/has_s hebang.txt'}, 82 {'dest': 'has_shebang.txt', 'src': '/blink/w3c/dir/has_s hebang.txt'},
83 {'dest': 'README.txt', 'src': '/blink/w3c/dir/README.txt '} 83 {'dest': 'README.txt', 'src': '/blink/w3c/dir/README.txt '}
84 ], 84 ],
85 'dirname': '/blink/w3c/dir', 85 'dirname': '/blink/w3c/dir',
86 'jstests': 0, 86 'jstests': 0,
87 'reftests': 0, 87 'reftests': 0,
88 'total_tests': 0, 88 'total_tests': 0,
89 } 89 }
90 ]) 90 ])
91 91
92 def test_does_not_import_reftestlist_file(self): 92 def test_does_not_import_reftestlist_file(self):
93 host = MockHost() 93 host = MockHost()
94 host.filesystem = MockFileSystem(files=FAKE_FILES) 94 host.filesystem = MockFileSystem(files=FAKE_FILES)
95 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 95 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
96 importer.find_importable_tests() 96 copier.find_importable_tests()
97 self.assertEqual( 97 self.assertEqual(
98 importer.import_list, 98 copier.import_list,
99 [ 99 [
100 { 100 {
101 'copy_list': [ 101 'copy_list': [
102 {'dest': 'has_shebang.txt', 'src': '/blink/w3c/dir/has_s hebang.txt'}, 102 {'dest': 'has_shebang.txt', 'src': '/blink/w3c/dir/has_s hebang.txt'},
103 {'dest': 'README.txt', 'src': '/blink/w3c/dir/README.txt '} 103 {'dest': 'README.txt', 'src': '/blink/w3c/dir/README.txt '}
104 ], 104 ],
105 'dirname': '/blink/w3c/dir', 105 'dirname': '/blink/w3c/dir',
106 'jstests': 0, 106 'jstests': 0,
107 'reftests': 0, 107 'reftests': 0,
108 'total_tests': 0, 108 'total_tests': 0,
109 } 109 }
110 ]) 110 ])
111 111
112 def test_files_with_shebang_are_made_executable(self): 112 def test_files_with_shebang_are_made_executable(self):
113 host = MockHost() 113 host = MockHost()
114 host.filesystem = MockFileSystem(files=FAKE_FILES) 114 host.filesystem = MockFileSystem(files=FAKE_FILES)
115 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 115 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
116 importer.do_import() 116 copier.do_import()
117 self.assertEqual( 117 self.assertEqual(
118 host.filesystem.executable_files, 118 host.filesystem.executable_files,
119 set(['/mock-checkout/third_party/WebKit/LayoutTests/external/blink/w 3c/dir/has_shebang.txt'])) 119 set(['/mock-checkout/third_party/WebKit/LayoutTests/external/blink/w 3c/dir/has_shebang.txt']))
120 120
121 def test_ref_test_with_ref_is_copied(self): 121 def test_ref_test_with_ref_is_copied(self):
122 host = MockHost() 122 host = MockHost()
123 host.filesystem = MockFileSystem(files={ 123 host.filesystem = MockFileSystem(files={
124 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h ref="ref-file.html" />test</head></html>', 124 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h ref="ref-file.html" />test</head></html>',
125 '/blink/w3c/dir1/ref-file.html': '<html><head>test</head></html>', 125 '/blink/w3c/dir1/ref-file.html': '<html><head>test</head></html>',
126 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations ': '', 126 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations ': '',
127 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in' : '', 127 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in' : '',
128 }) 128 })
129 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 129 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
130 importer.find_importable_tests() 130 copier.find_importable_tests()
131 self.assertEqual( 131 self.assertEqual(
132 importer.import_list, 132 copier.import_list,
133 [ 133 [
134 { 134 {
135 'copy_list': [ 135 'copy_list': [
136 {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'ref-fi le.html'}, 136 {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'ref-fi le.html'},
137 {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'my-ref -test-expected.html', 'reference_support_info': {}}, 137 {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'my-ref -test-expected.html', 'reference_support_info': {}},
138 {'src': '/blink/w3c/dir1/my-ref-test.html', 'dest': 'my- ref-test.html'} 138 {'src': '/blink/w3c/dir1/my-ref-test.html', 'dest': 'my- ref-test.html'}
139 ], 139 ],
140 'dirname': '/blink/w3c/dir1', 140 'dirname': '/blink/w3c/dir1',
141 'jstests': 0, 141 'jstests': 0,
142 'reftests': 1, 142 'reftests': 1,
143 'total_tests': 1 143 'total_tests': 1
144 } 144 }
145 ]) 145 ])
146 146
147 def test_ref_test_without_ref_is_skipped(self): 147 def test_ref_test_without_ref_is_skipped(self):
148 host = MockHost() 148 host = MockHost()
149 host.filesystem = MockFileSystem(files={ 149 host.filesystem = MockFileSystem(files={
150 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h ref="not-here.html" /></head></html>', 150 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h ref="not-here.html" /></head></html>',
151 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations ': '', 151 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations ': '',
152 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in' : '', 152 '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in' : '',
153 }) 153 })
154 importer = TestImporter(host, FAKE_SOURCE_REPO_DIR) 154 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
155 importer.find_importable_tests() 155 copier.find_importable_tests()
156 self.assertEqual(importer.import_list, []) 156 self.assertEqual(copier.import_list, [])
157 157
158 def test_should_try_to_convert_positive_cases(self): 158 def test_should_try_to_convert_positive_cases(self):
159 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.css', 'Layou tTests/external/csswg-test/x')) 159 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.css', 'LayoutT ests/external/csswg-test/x'))
160 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.htm', 'Layou tTests/external/csswg-test/x')) 160 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.htm', 'LayoutT ests/external/csswg-test/x'))
161 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.html', 'Layo utTests/external/csswg-test/x')) 161 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.html', 'Layout Tests/external/csswg-test/x'))
162 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xht', 'Layou tTests/external/csswg-test/x')) 162 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xht', 'LayoutT ests/external/csswg-test/x'))
163 self.assertTrue(TestImporter.should_try_to_convert({}, 'foo.xhtml', 'Lay outTests/external/csswg-test/x')) 163 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xhtml', 'Layou tTests/external/csswg-test/x'))
164 164
165 def test_should_not_try_to_convert_js_test(self): 165 def test_should_not_try_to_convert_js_test(self):
166 self.assertFalse(TestImporter.should_try_to_convert({'is_jstest': True}, 'foo.html', 'LayoutTests/external/csswg-test/x')) 166 self.assertFalse(TestCopier.should_try_to_convert({'is_jstest': True}, ' foo.html', 'LayoutTests/external/csswg-test/x'))
167 167
168 def test_should_not_try_to_convert_test_in_wpt(self): 168 def test_should_not_try_to_convert_test_in_wpt(self):
169 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.html', 'Lay outTests/external/wpt/foo')) 169 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.html', 'Layou tTests/external/wpt/foo'))
170 170
171 def test_should_not_try_to_convert_other_file_types(self): 171 def test_should_not_try_to_convert_other_file_types(self):
172 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.bar', 'Layo utTests/external/csswg-test/x')) 172 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.bar', 'Layout Tests/external/csswg-test/x'))
173 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.js', 'Layou tTests/external/csswg-test/x')) 173 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.js', 'LayoutT ests/external/csswg-test/x'))
174 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.md', 'Layou tTests/external/csswg-test/x')) 174 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.md', 'LayoutT ests/external/csswg-test/x'))
175 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.png', 'Layo utTests/external/csswg-test/x')) 175 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.png', 'Layout Tests/external/csswg-test/x'))
176 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svg', 'Layo utTests/external/csswg-test/x')) 176 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svg', 'Layout Tests/external/csswg-test/x'))
177 self.assertFalse(TestImporter.should_try_to_convert({}, 'foo.svgz', 'Lay outTests/external/csswg-test/x')) 177 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svgz', 'Layou tTests/external/csswg-test/x'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698