Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 FAKE_FILES = { | 43 FAKE_FILES = { |
| 44 '/blink/w3c/empty_dir/README.txt': '', | 44 '/blink/w3c/empty_dir/README.txt': '', |
| 45 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', | 45 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', |
| 46 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', | 46 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 class TestImporterTest(unittest.TestCase): | 50 class TestImporterTest(unittest.TestCase): |
| 51 | 51 |
| 52 @staticmethod | |
| 53 def options(**kwargs): | |
| 54 """Returns a set of option values for TestImporter.""" | |
| 55 options = { | |
| 56 "overwrite": False, | |
| 57 "destination": "w3c", | |
| 58 "ignore_expectations": False, | |
| 59 } | |
| 60 options.update(kwargs) | |
| 61 return optparse.Values(options) | |
| 62 | |
| 52 def test_import_dir_with_no_tests_and_no_hg(self): | 63 def test_import_dir_with_no_tests_and_no_hg(self): |
| 53 host = MockHost() | 64 host = MockHost() |
| 54 host.executive = MockExecutive2(exception=OSError()) | 65 host.executive = MockExecutive2(exception=OSError()) |
| 55 host.filesystem = MockFileSystem(files=FAKE_FILES) | 66 host.filesystem = MockFileSystem(files=FAKE_FILES) |
| 56 | 67 |
| 57 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.V alues( | 68 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, self.optio ns()) |
| 58 {"overwrite": False, 'destination': 'w3c', 'ignore_expectations': Fa lse})) | |
| 59 | 69 |
| 60 oc = OutputCapture() | 70 oc = OutputCapture() |
| 61 oc.capture_output() | 71 oc.capture_output() |
| 62 try: | 72 try: |
| 63 importer.do_import() | 73 importer.do_import() |
| 64 finally: | 74 finally: |
| 65 oc.restore_output() | 75 oc.restore_output() |
| 66 | 76 |
| 67 def test_import_dir_with_no_tests(self): | 77 def test_import_dir_with_no_tests(self): |
| 68 host = MockHost() | 78 host = MockHost() |
| 69 host.executive = MockExecutive2(exception=ScriptError( | 79 host.executive = MockExecutive2(exception=ScriptError( |
| 70 "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts /webkitpy/w3c' (.hg not found)!")) | 80 "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts /webkitpy/w3c' (.hg not found)!")) |
| 71 host.filesystem = MockFileSystem(files=FAKE_FILES) | 81 host.filesystem = MockFileSystem(files=FAKE_FILES) |
| 72 | 82 |
| 73 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.V alues( | 83 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, self.optio ns()) |
| 74 {"overwrite": False, 'destination': 'w3c', 'ignore_expectations': Fa lse})) | 84 |
| 75 oc = OutputCapture() | 85 oc = OutputCapture() |
| 76 oc.capture_output() | 86 oc.capture_output() |
| 77 try: | 87 try: |
| 78 importer.do_import() | 88 importer.do_import() |
| 79 finally: | 89 finally: |
| 80 oc.restore_output() | 90 oc.restore_output() |
| 81 | 91 |
| 92 def test_path_too_long_true(self): | |
| 93 importer = TestImporter(MockHost(), FAKE_SOURCE_DIR, FAKE_REPO_DIR, self .options()) | |
| 94 self.assertTrue(importer.path_too_long(FAKE_REPO_DIR + '/' + ('x' * 150) + '.html')) | |
| 95 | |
| 96 def test_path_too_long_false(self): | |
| 97 importer = TestImporter(MockHost(), FAKE_SOURCE_DIR, FAKE_REPO_DIR, self .options()) | |
| 98 self.assertFalse(importer.path_too_long(FAKE_REPO_DIR + '/x.html')) | |
| 99 | |
|
qyearsley
2016/05/11 22:27:29
Can't yet add a test that calls do_import and chec
| |
| 82 # FIXME: Needs more tests. | 100 # FIXME: Needs more tests. |
| OLD | NEW |