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