OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 | 6 |
7 from webkitpy.common.checkout.git_mock import MockGit | 7 from webkitpy.common.checkout.git_mock import MockGit |
8 from webkitpy.common.host_mock import MockHost | 8 from webkitpy.common.host_mock import MockHost |
9 from webkitpy.common.system.executive_mock import MockExecutive | 9 from webkitpy.common.system.executive_mock import MockExecutive |
10 from webkitpy.common.system.log_testing import LoggingTestCase | 10 from webkitpy.common.system.log_testing import LoggingTestCase |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 'NOEXPORT=true') | 73 'NOEXPORT=true') |
74 | 74 |
75 def test_cl_description_with_empty_environ(self): | 75 def test_cl_description_with_empty_environ(self): |
76 host = MockHost() | 76 host = MockHost() |
77 host.executive = MockExecutive(output='Last commit message\n\n') | 77 host.executive = MockExecutive(output='Last commit message\n\n') |
78 importer = TestImporter(host) | 78 importer = TestImporter(host) |
79 description = importer._cl_description(directory_owners={}) | 79 description = importer._cl_description(directory_owners={}) |
80 self.assertEqual( | 80 self.assertEqual( |
81 description, | 81 description, |
82 ('Last commit message\n\n' | 82 ('Last commit message\n\n' |
83 'TBR=jeffcarp@chromium.org\n' | 83 'TBR=qyearsley@chromium.org\n' |
84 'NOEXPORT=true')) | 84 'NOEXPORT=true')) |
85 self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%
B']]) | 85 self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%
B']]) |
86 | 86 |
87 def test_cl_description_with_environ_variables(self): | 87 def test_cl_description_with_environ_variables(self): |
88 host = MockHost() | 88 host = MockHost() |
89 host.executive = MockExecutive(output='Last commit message\n') | 89 host.executive = MockExecutive(output='Last commit message\n') |
90 importer = TestImporter(host) | 90 importer = TestImporter(host) |
91 importer.host.environ['BUILDBOT_MASTERNAME'] = 'my.master' | 91 importer.host.environ['BUILDBOT_MASTERNAME'] = 'my.master' |
92 importer.host.environ['BUILDBOT_BUILDERNAME'] = 'b' | 92 importer.host.environ['BUILDBOT_BUILDERNAME'] = 'b' |
93 importer.host.environ['BUILDBOT_BUILDNUMBER'] = '123' | 93 importer.host.environ['BUILDBOT_BUILDNUMBER'] = '123' |
94 description = importer._cl_description(directory_owners={}) | 94 description = importer._cl_description(directory_owners={}) |
95 self.assertEqual( | 95 self.assertEqual( |
96 description, | 96 description, |
97 ('Last commit message\n' | 97 ('Last commit message\n' |
98 'Build: https://build.chromium.org/p/my.master/builders/b/builds/12
3\n\n' | 98 'Build: https://build.chromium.org/p/my.master/builders/b/builds/12
3\n\n' |
99 'TBR=jeffcarp@chromium.org\n' | 99 'TBR=qyearsley@chromium.org\n' |
100 'NOEXPORT=true')) | 100 'NOEXPORT=true')) |
101 self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%
B']]) | 101 self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%
B']]) |
102 | 102 |
103 def test_cl_description_moves_noexport_tag(self): | 103 def test_cl_description_moves_noexport_tag(self): |
104 host = MockHost() | 104 host = MockHost() |
105 host.executive = MockExecutive(output='Summary\n\nNOEXPORT=true\n\n') | 105 host.executive = MockExecutive(output='Summary\n\nNOEXPORT=true\n\n') |
106 importer = TestImporter(host) | 106 importer = TestImporter(host) |
107 description = importer._cl_description(directory_owners={}) | 107 description = importer._cl_description(directory_owners={}) |
108 self.assertEqual( | 108 self.assertEqual( |
109 description, | 109 description, |
110 ('Summary\n\n' | 110 ('Summary\n\n' |
111 'TBR=jeffcarp@chromium.org\n' | 111 'TBR=qyearsley@chromium.org\n' |
112 'NOEXPORT=true')) | 112 'NOEXPORT=true')) |
113 | 113 |
114 def test_cl_description_with_directory_owners(self): | 114 def test_cl_description_with_directory_owners(self): |
115 host = MockHost() | 115 host = MockHost() |
116 host.executive = MockExecutive(output='Last commit message\n\n') | 116 host.executive = MockExecutive(output='Last commit message\n\n') |
117 importer = TestImporter(host) | 117 importer = TestImporter(host) |
118 description = importer._cl_description(directory_owners={ | 118 description = importer._cl_description(directory_owners={ |
119 ('someone@chromium.org',): ['external/wpt/foo', 'external/wpt/bar'], | 119 ('someone@chromium.org',): ['external/wpt/foo', 'external/wpt/bar'], |
120 ('x@chromium.org', 'y@chromium.org'): ['external/wpt/baz'], | 120 ('x@chromium.org', 'y@chromium.org'): ['external/wpt/baz'], |
121 }) | 121 }) |
122 self.assertEqual( | 122 self.assertEqual( |
123 description, | 123 description, |
124 ('Last commit message\n\n' | 124 ('Last commit message\n\n' |
125 'Directory owners for changes in this CL:\n' | 125 'Directory owners for changes in this CL:\n' |
126 'someone@chromium.org:\n' | 126 'someone@chromium.org:\n' |
127 ' external/wpt/foo\n' | 127 ' external/wpt/foo\n' |
128 ' external/wpt/bar\n' | 128 ' external/wpt/bar\n' |
129 'x@chromium.org, y@chromium.org:\n' | 129 'x@chromium.org, y@chromium.org:\n' |
130 ' external/wpt/baz\n\n' | 130 ' external/wpt/baz\n\n' |
131 'TBR=jeffcarp@chromium.org\n' | 131 'TBR=qyearsley@chromium.org\n' |
132 'NOEXPORT=true')) | 132 'NOEXPORT=true')) |
133 | 133 |
134 def test_generate_manifest_successful_run(self): | 134 def test_generate_manifest_successful_run(self): |
135 # This test doesn't test any aspect of the real manifest script, it just | 135 # This test doesn't test any aspect of the real manifest script, it just |
136 # asserts that TestImporter._generate_manifest would invoke the script. | 136 # asserts that TestImporter._generate_manifest would invoke the script. |
137 host = MockHost() | 137 host = MockHost() |
138 importer = TestImporter(host) | 138 importer = TestImporter(host) |
139 blink_path = '/mock-checkout/third_party/WebKit' | 139 blink_path = '/mock-checkout/third_party/WebKit' |
140 host.filesystem.write_text_file(blink_path + '/LayoutTests/external/wpt/
MANIFEST.json', '{}') | 140 host.filesystem.write_text_file(blink_path + '/LayoutTests/external/wpt/
MANIFEST.json', '{}') |
141 importer._generate_manifest(blink_path + '/LayoutTests/external/wpt') | 141 importer._generate_manifest(blink_path + '/LayoutTests/external/wpt') |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 host.filesystem.write_text_file(dest_path + '/foo-test.html', '') | 204 host.filesystem.write_text_file(dest_path + '/foo-test.html', '') |
205 host.filesystem.write_text_file(dest_path + '/foo-test-expected.txt', ''
) | 205 host.filesystem.write_text_file(dest_path + '/foo-test-expected.txt', ''
) |
206 host.filesystem.write_text_file(dest_path + '/OWNERS', '') | 206 host.filesystem.write_text_file(dest_path + '/OWNERS', '') |
207 host.filesystem.write_text_file(dest_path + '/bar/baz/OWNERS', '') | 207 host.filesystem.write_text_file(dest_path + '/bar/baz/OWNERS', '') |
208 importer = TestImporter(host) | 208 importer = TestImporter(host) |
209 importer._clear_out_dest_path(dest_path) | 209 importer._clear_out_dest_path(dest_path) |
210 self.assertFalse(host.filesystem.exists(dest_path + '/foo-test.html')) | 210 self.assertFalse(host.filesystem.exists(dest_path + '/foo-test.html')) |
211 self.assertTrue(host.filesystem.exists(dest_path + '/foo-test-expected.t
xt')) | 211 self.assertTrue(host.filesystem.exists(dest_path + '/foo-test-expected.t
xt')) |
212 self.assertTrue(host.filesystem.exists(dest_path + '/OWNERS')) | 212 self.assertTrue(host.filesystem.exists(dest_path + '/OWNERS')) |
213 self.assertTrue(host.filesystem.exists(dest_path + '/bar/baz/OWNERS')) | 213 self.assertTrue(host.filesystem.exists(dest_path + '/bar/baz/OWNERS')) |
OLD | NEW |