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

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

Issue 2029823002: Fix MockFileSystem.walk and add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Import Expectations Modified Created 4 years, 6 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.
qyearsley 2016/06/02 14:24:38 These tests should go in test_importer_unittest.py
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
(...skipping 20 matching lines...) Expand all
32 from webkitpy.common.system.filesystem_mock import MockFileSystem 32 from webkitpy.common.system.filesystem_mock import MockFileSystem
33 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError 33 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
34 from webkitpy.common.system.outputcapture import OutputCapture 34 from webkitpy.common.system.outputcapture import OutputCapture
35 from webkitpy.w3c.test_importer import TestImporter 35 from webkitpy.w3c.test_importer import TestImporter
36 36
37 37
38 FAKE_SOURCE_DIR = '/blink/w3c' 38 FAKE_SOURCE_DIR = '/blink/w3c'
39 FAKE_REPO_DIR = '/blink' 39 FAKE_REPO_DIR = '/blink'
40 40
41 FAKE_FILES = { 41 FAKE_FILES = {
42 '/mock-checkout/third_party/Webkit/LayoutTests/w3c/OWNERS': '',
42 '/blink/w3c/empty_dir/README.txt': '', 43 '/blink/w3c/empty_dir/README.txt': '',
44 '/blink/w3c/empty_dir/OWNERS': '',
qyearsley 2016/06/02 14:24:38 It's slightly confusing that there's a non-empty d
45 '/blink/w3c/dir1/OWNERS': '',
43 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '', 46 '/mock-checkout/third_party/WebKit/LayoutTests/w3c/README.txt': '',
44 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', 47 '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '',
45 } 48 }
46 49
47 50
48 class TestImporterTest(unittest.TestCase): 51 class TestImporterTest(unittest.TestCase):
49 52
50 @staticmethod 53 @staticmethod
51 def options(**kwargs): 54 def options(**kwargs):
52 """Returns a set of option values for TestImporter.""" 55 """Returns a set of option values for TestImporter."""
53 options = { 56 options = {
54 "overwrite": False, 57 "overwrite": False,
55 "destination": "w3c", 58 "destination": "w3c",
56 "ignore_expectations": False, 59 "ignore_expectations": False,
57 } 60 }
58 options.update(kwargs) 61 options.update(kwargs)
59 return optparse.Values(options) 62 return optparse.Values(options)
60 63
61 def test_import_dir_with_no_tests(self): 64 def test_does_not_import_owner_files(self):
62 host = MockHost() 65 host = MockHost()
63 host.executive = MockExecutive2(exception=ScriptError(
64 "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts /webkitpy/w3c'"))
65 host.filesystem = MockFileSystem(files=FAKE_FILES) 66 host.filesystem = MockFileSystem(files=FAKE_FILES)
66 67
67 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, self.optio ns()) 68 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, self.optio ns())
68 69 importer.find_importable_tests(FAKE_REPO_DIR)
69 oc = OutputCapture() 70 self.assertEqual(importer.import_list, [{'copy_list': [{'dest': 'README. txt', 'src': '/blink/w3c/empty_dir/README.txt'}],
70 oc.capture_output() 71 'dirname': '/blink/w3c/empty_di r',
71 try: 72 'jstests': 0,
72 importer.do_import() 73 'reftests': 0,
73 finally: 74 'total_tests': 0, }])
qyearsley 2016/06/02 14:24:38 Formatting nit: line 70 is quite long, and line 74
74 oc.restore_output()
75
76 def test_path_too_long_true(self):
77 importer = TestImporter(MockHost(), FAKE_SOURCE_DIR, FAKE_REPO_DIR, self .options())
78 self.assertTrue(importer.path_too_long(FAKE_REPO_DIR + '/' + ('x' * 150) + '.html'))
79
80 def test_path_too_long_false(self):
81 importer = TestImporter(MockHost(), FAKE_SOURCE_DIR, FAKE_REPO_DIR, self .options())
82 self.assertFalse(importer.path_too_long(FAKE_REPO_DIR + '/x.html'))
83
84 # FIXME: Needs more tests.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698