| 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 |
| 11 # copyright notice, this list of conditions and the following | 11 # copyright notice, this list of conditions and the following |
| 12 # disclaimer in the documentation and/or other materials | 12 # disclaimer in the documentation and/or other materials |
| 13 # provided with the distribution. | 13 # provided with the distribution. |
| 14 # | 14 # |
| 15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | 15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY |
| 16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | 18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE |
| 19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | 19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
| 20 # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 | |
| 29 | |
| 30 from webkitpy.common.host_mock import MockHost | 28 from webkitpy.common.host_mock import MockHost |
| 31 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError | 29 from webkitpy.common.system.executive_mock import MockExecutive, ScriptError |
| 32 from webkitpy.common.system.filesystem_mock import MockFileSystem | 30 from webkitpy.common.system.filesystem_mock import MockFileSystem |
| 33 from webkitpy.w3c.test_copier import TestCopier | 31 from webkitpy.w3c.test_copier import TestCopier |
| 32 from webkitpy.common.system.log_testing import LoggingTestCase |
| 34 | 33 |
| 35 | 34 |
| 36 FAKE_SOURCE_REPO_DIR = '/blink' | 35 FAKE_SOURCE_REPO_DIR = '/blink' |
| 37 | 36 |
| 38 FAKE_FILES = { | 37 FAKE_FILES = { |
| 39 '/mock-checkout/third_party/Webkit/LayoutTests/external/OWNERS': '', | 38 '/mock-checkout/third_party/Webkit/LayoutTests/external/OWNERS': '', |
| 40 '/blink/w3c/dir/has_shebang.txt': '#!', | 39 '/blink/w3c/dir/has_shebang.txt': '#!', |
| 41 '/blink/w3c/dir/README.txt': '', | 40 '/blink/w3c/dir/README.txt': '', |
| 42 '/blink/w3c/dir/OWNERS': '', | 41 '/blink/w3c/dir/OWNERS': '', |
| 43 '/blink/w3c/dir/reftest.list': '', | 42 '/blink/w3c/dir/reftest.list': '', |
| 44 '/blink/w3c/dir1/OWNERS': '', | |
| 45 '/blink/w3c/dir1/reftest.list': '', | |
| 46 '/mock-checkout/third_party/WebKit/LayoutTests/external/README.txt': '', | 43 '/mock-checkout/third_party/WebKit/LayoutTests/external/README.txt': '', |
| 47 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', | 44 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', |
| 48 } | 45 } |
| 49 | 46 |
| 50 | 47 |
| 51 class TestCopierTest(unittest.TestCase): | 48 class TestCopierTest(LoggingTestCase): |
| 52 | 49 |
| 53 def test_import_dir_with_no_tests(self): | 50 def test_import_dir_with_no_tests(self): |
| 54 host = MockHost() | 51 host = MockHost() |
| 55 host.executive = MockExecutive(exception=ScriptError('error')) | 52 host.executive = MockExecutive(exception=ScriptError('error')) |
| 56 host.filesystem = MockFileSystem(files=FAKE_FILES) | 53 host.filesystem = MockFileSystem(files=FAKE_FILES) |
| 57 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR, 'destination') | 54 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR, 'destination') |
| 58 copier.do_import() # No exception raised. | 55 copier.do_import() # No exception raised. |
| 59 | 56 |
| 60 def test_path_too_long_true(self): | |
| 61 host = MockHost() | |
| 62 host.filesystem = MockFileSystem(files=FAKE_FILES) | |
| 63 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) | |
| 64 self.assertTrue(copier.path_too_long(FAKE_SOURCE_REPO_DIR + '/' + ('x' *
150) + '.html')) | |
| 65 | |
| 66 def test_path_too_long_false(self): | |
| 67 host = MockHost() | |
| 68 host.filesystem = MockFileSystem(files=FAKE_FILES) | |
| 69 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) | |
| 70 self.assertFalse(copier.path_too_long(FAKE_SOURCE_REPO_DIR + '/x.html')) | |
| 71 | |
| 72 def test_does_not_import_owner_files(self): | 57 def test_does_not_import_owner_files(self): |
| 73 host = MockHost() | 58 host = MockHost() |
| 74 host.filesystem = MockFileSystem(files=FAKE_FILES) | 59 host.filesystem = MockFileSystem(files=FAKE_FILES) |
| 75 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) | 60 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) |
| 76 copier.find_importable_tests() | 61 copier.find_importable_tests() |
| 77 self.assertEqual( | 62 self.assertEqual( |
| 78 copier.import_list, | 63 copier.import_list, |
| 79 [ | 64 [ |
| 80 { | 65 { |
| 81 'copy_list': [ | 66 'copy_list': [ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 130 |
| 146 def test_ref_test_without_ref_is_skipped(self): | 131 def test_ref_test_without_ref_is_skipped(self): |
| 147 host = MockHost() | 132 host = MockHost() |
| 148 host.filesystem = MockFileSystem(files={ | 133 host.filesystem = MockFileSystem(files={ |
| 149 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', | 134 '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" h
ref="not-here.html" /></head></html>', |
| 150 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', | 135 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations
': '', |
| 151 }) | 136 }) |
| 152 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) | 137 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) |
| 153 copier.find_importable_tests() | 138 copier.find_importable_tests() |
| 154 self.assertEqual(copier.import_list, []) | 139 self.assertEqual(copier.import_list, []) |
| 140 self.assertLog([ |
| 141 'WARNING: Skipping: /blink/w3c/dir1/my-ref-test.html\n', |
| 142 'WARNING: Reason: Ref file "my-ref-test-expected.html" was not fou
nd.\n' |
| 143 ]) |
| 144 |
| 145 def test_files_with_long_path_are_skipped(self): |
| 146 host = MockHost() |
| 147 host.filesystem = MockFileSystem(files=FAKE_FILES) |
| 148 long_file_path = '%s/%s.html' % (FAKE_SOURCE_REPO_DIR, 'x' * 150) |
| 149 short_file_path = '%s/x.html' % FAKE_SOURCE_REPO_DIR |
| 150 host.filesystem.write_text_file(long_file_path, '<html></html>') |
| 151 host.filesystem.write_text_file(short_file_path, '<html></html>') |
| 152 copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) |
| 153 copier.find_importable_tests() |
| 154 self.assertLog([ |
| 155 'WARNING: Skipping: %s\n' % long_file_path, |
| 156 'WARNING: Reason: Long path. Max length 140; see http://crbug.com/
609871.\n', |
| 157 'INFO: Skipping: /blink/w3c/dir/reftest.list\n', |
| 158 'INFO: Reason: This file may cause Chromium presubmit to fail.\n', |
| 159 'INFO: Skipping: /blink/w3c/dir/OWNERS\n', |
| 160 'INFO: Reason: This file may cause Chromium presubmit to fail.\n', |
| 161 ]) |
| 155 | 162 |
| 156 def test_should_try_to_convert_positive_cases(self): | 163 def test_should_try_to_convert_positive_cases(self): |
| 157 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.css', 'LayoutT
ests/external/csswg-test/x')) | 164 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.css', 'LayoutT
ests/external/csswg-test/x')) |
| 158 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.htm', 'LayoutT
ests/external/csswg-test/x')) | 165 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.htm', 'LayoutT
ests/external/csswg-test/x')) |
| 159 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.html', 'Layout
Tests/external/csswg-test/x')) | 166 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.html', 'Layout
Tests/external/csswg-test/x')) |
| 160 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xht', 'LayoutT
ests/external/csswg-test/x')) | 167 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xht', 'LayoutT
ests/external/csswg-test/x')) |
| 161 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xhtml', 'Layou
tTests/external/csswg-test/x')) | 168 self.assertTrue(TestCopier.should_try_to_convert({}, 'foo.xhtml', 'Layou
tTests/external/csswg-test/x')) |
| 162 | 169 |
| 163 def test_should_not_try_to_convert_js_test(self): | 170 def test_should_not_try_to_convert_js_test(self): |
| 164 self.assertFalse(TestCopier.should_try_to_convert({'is_jstest': True}, '
foo.html', 'LayoutTests/external/csswg-test/x')) | 171 self.assertFalse(TestCopier.should_try_to_convert({'is_jstest': True}, '
foo.html', 'LayoutTests/external/csswg-test/x')) |
| 165 | 172 |
| 166 def test_should_not_try_to_convert_test_in_wpt(self): | 173 def test_should_not_try_to_convert_test_in_wpt(self): |
| 167 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.html', 'Layou
tTests/external/wpt/foo')) | 174 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.html', 'Layou
tTests/external/wpt/foo')) |
| 168 | 175 |
| 169 def test_should_not_try_to_convert_other_file_types(self): | 176 def test_should_not_try_to_convert_other_file_types(self): |
| 170 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.bar', 'Layout
Tests/external/csswg-test/x')) | 177 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.bar', 'Layout
Tests/external/csswg-test/x')) |
| 171 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.js', 'LayoutT
ests/external/csswg-test/x')) | 178 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.js', 'LayoutT
ests/external/csswg-test/x')) |
| 172 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.md', 'LayoutT
ests/external/csswg-test/x')) | 179 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.md', 'LayoutT
ests/external/csswg-test/x')) |
| 173 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.png', 'Layout
Tests/external/csswg-test/x')) | 180 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.png', 'Layout
Tests/external/csswg-test/x')) |
| 174 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svg', 'Layout
Tests/external/csswg-test/x')) | 181 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svg', 'Layout
Tests/external/csswg-test/x')) |
| 175 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svgz', 'Layou
tTests/external/csswg-test/x')) | 182 self.assertFalse(TestCopier.should_try_to_convert({}, 'foo.svgz', 'Layou
tTests/external/csswg-test/x')) |
| OLD | NEW |