| 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']
|
|
|