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

Side by Side Diff: unittests/test_test.py

Issue 2828823003: Detect duplicate recipe tests (Closed)
Patch Set: Created 3 years, 8 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
« recipe_engine/test.py ('K') | « recipe_engine/test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The LUCI Authors. All rights reserved. 2 # Copyright 2017 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import json 6 import json
7 import os 7 import os
8 import shutil 8 import shutil
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 mw = RecipeModuleWriter(self._root_dir, 'foo_module') 1078 mw = RecipeModuleWriter(self._root_dir, 'foo_module')
1079 mw.test_methods['baz'] = ['pass'] 1079 mw.test_methods['baz'] = ['pass']
1080 mw.write() 1080 mw.write()
1081 mw.example.DEPS = ['foo_module'] 1081 mw.example.DEPS = ['foo_module']
1082 mw.example.GenTestsLines = ['api.foo_module.baz()', 'yield api.test("basic") '] 1082 mw.example.GenTestsLines = ['api.foo_module.baz()', 'yield api.test("basic") ']
1083 mw.example.add_expectation('basic') 1083 mw.example.add_expectation('basic')
1084 mw.example.write() 1084 mw.example.write()
1085 self._run_recipes('test', 'run', '--json', self.json_path) 1085 self._run_recipes('test', 'run', '--json', self.json_path)
1086 self.assertEqual(self.json_generator.get(), self.json_contents) 1086 self.assertEqual(self.json_generator.get(), self.json_contents)
1087 1087
1088 def test_test_duplicate(self):
1089 rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
1090 rw.RunStepsLines = ['pass']
1091 rw.GenTestsLines = ['yield api.test("basic")'] * 2
1092 rw.add_expectation('basic')
1093 rw.write()
1094 with self.assertRaises(subprocess.CalledProcessError) as cm:
1095 self._run_recipes('test', 'run')
1096 self.assertIn(
1097 'Exception: While generating results for \'foo\': '
1098 'ValueError: Duplicate test found: basic',
1099 cm.exception.output)
1100
1088 def test_diff_basic(self): 1101 def test_diff_basic(self):
1089 g1 = self.json_generator 1102 g1 = self.json_generator
1090 g2 = self.json_generator 1103 g2 = self.json_generator
1091 self._run_recipes( 1104 self._run_recipes(
1092 'test', 'diff', 1105 'test', 'diff',
1093 '--baseline', g1.write(), 1106 '--baseline', g1.write(),
1094 '--actual', g2.write(), 1107 '--actual', g2.write(),
1095 '--json', self.json_path) 1108 '--json', self.json_path)
1096 self.assertEqual(self.json_generator.get(), self.json_contents) 1109 self.assertEqual(self.json_generator.get(), self.json_contents)
1097 1110
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 .check_failure('bar_check', 'bar_file', 2, 'bar_func', ['bar_args']) 1172 .check_failure('bar_check', 'bar_file', 2, 'bar_func', ['bar_args'])
1160 .internal_failure('bar_internal') 1173 .internal_failure('bar_internal')
1161 .uncovered_module('bar_module') 1174 .uncovered_module('bar_module')
1162 .unused_expectation('bar_expectation') 1175 .unused_expectation('bar_expectation')
1163 .get(), 1176 .get(),
1164 self.json_contents) 1177 self.json_contents)
1165 1178
1166 1179
1167 if __name__ == '__main__': 1180 if __name__ == '__main__':
1168 sys.exit(unittest.main()) 1181 sys.exit(unittest.main())
OLDNEW
« recipe_engine/test.py ('K') | « recipe_engine/test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698