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

Unified Diff: unittests/test_test.py

Issue 2845133002: Add friendly error message when GenTests is missing or misspelled (Closed)
Patch Set: RunSteps Created 3 years, 7 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
« no previous file with comments | « 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 ab5216aae57d45a5c32264b5479f944402d65897..42ca105da5edca63971281195768d014501be908 100755
--- a/unittests/test_test.py
+++ b/unittests/test_test.py
@@ -69,11 +69,17 @@ 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]))
+ ]))
+ if self.RunStepsLines:
+ f.write('\n'.join([
+ 'def RunSteps(api):',
+ ] + [' %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 +407,27 @@ 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_runsteps(self):
+ rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
+ rw.RunStepsLines = 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 RunSteps function',
+ cm.exception.output)
+
+ 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']
« no previous file with comments | « recipe_engine/test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698