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

Unified Diff: unittests/test_test.py

Issue 2845133002: Add friendly error message when GenTests is missing or misspelled (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 side-by-side diff with in-line comments
Download patch
« recipe_engine/test.py ('K') | « recipe_engine/test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unittests/test_test.py
diff --git a/unittests/test_test.py b/unittests/test_test.py
index 9ef908f2cbc8e600a7c9041f5df46e74446cda12..9f7ac6638a46d27d75ef1db1c1e40ba19baf6936 100755
--- a/unittests/test_test.py
+++ b/unittests/test_test.py
@@ -70,10 +70,12 @@ class RecipeWriter(object):
'DEPS = %r' % self.DEPS,
'',
'def RunSteps(api):',
- ] + [' %s' % l for l in self.RunStepsLines] + [
- '',
- 'def GenTests(api):',
- ] + [' %s' % l for l in self.GenTestsLines]))
+ ] + [' %s' % l for l in self.RunStepsLines] + ['']))
+ if self.GenTestsLines:
+ f.write('\n'.join([
+ '',
+ 'def GenTests(api):',
+ ] + [' %s' % l for l in self.GenTestsLines]))
for test_name, test_contents in self.expectations.iteritems():
name = ''.join('_' if c in '<>:"\\/|?*\0' else c for c in test_name)
with open(os.path.join(self.expect_dir, '%s.json' % name), 'w') as f:
@@ -401,6 +403,17 @@ class TestTest(unittest.TestCase):
self._run_recipes('test', 'run', '--json', self.json_path)
self.assertEqual(self.json_generator.get(), self.json_contents)
+ def test_test_missing_gentests(self):
+ rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
+ rw.RunStepsLines = ['pass']
+ rw.GenTestsLines = None
+ rw.add_expectation('basic')
+ rw.write()
+ with self.assertRaises(subprocess.CalledProcessError) as cm:
+ self._run_recipes('test', 'run', '--json', self.json_path)
+ self.assertIn('Missing or misspelled GenTests function',
+ cm.exception.output)
+
def test_test_recipe_not_covered(self):
rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
rw.RunStepsLines = ['if False:', ' pass']
« 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