| Index: unittests/test_test.py
|
| diff --git a/unittests/test_test.py b/unittests/test_test.py
|
| index 11bf5d276b9ffd37c716c9fb53c014a172574a02..bbbe652ed42565e2a0f9e19b1648a34a41e7d7b7 100755
|
| --- a/unittests/test_test.py
|
| +++ b/unittests/test_test.py
|
| @@ -449,6 +449,92 @@ class TestTest(unittest.TestCase):
|
| self.assertIn('CHECK(FAIL)', cm.exception.output)
|
| self.assertIn('foo.basic failed', cm.exception.output)
|
|
|
| + def test_unused_expectation_file_test(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.add_expectation('basic')
|
| + rw.add_expectation('unused')
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'unused.json')
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| + with self.assertRaises(subprocess.CalledProcessError) as cm:
|
| + self._run_recipes('test', 'run')
|
| + self.assertIn(
|
| + 'FATAL: unused expectations found:\n%s' % expectation_file,
|
| + cm.exception.output)
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| +
|
| + def test_unused_expectation_file_train(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.add_expectation('basic')
|
| + rw.add_expectation('unused')
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'unused.json')
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| + self._run_recipes('test', 'run', '--train')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| +
|
| + def test_drop_expectation_test(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.GenTestsLines = [
|
| + 'yield api.test("basic") + \\',
|
| + ' api.post_process(post_process.DropExpectation)'
|
| + ]
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'basic.json')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| + self._run_recipes('test', 'run')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| +
|
| + def test_drop_expectation_train(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.GenTestsLines = [
|
| + 'yield api.test("basic") + \\',
|
| + ' api.post_process(post_process.DropExpectation)'
|
| + ]
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'basic.json')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| + self._run_recipes('test', 'run', '--train')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| +
|
| + def test_drop_expectation_test_unused(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.GenTestsLines = [
|
| + 'yield api.test("basic") + \\',
|
| + ' api.post_process(post_process.DropExpectation)'
|
| + ]
|
| + rw.add_expectation('basic')
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'basic.json')
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| + with self.assertRaises(subprocess.CalledProcessError) as cm:
|
| + self._run_recipes('test', 'run')
|
| + self.assertIn(
|
| + 'FATAL: unused expectations found:\n%s\n%s' % (
|
| + rw.expect_dir, expectation_file),
|
| + cm.exception.output)
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| +
|
| + def test_drop_expectation_train_unused(self):
|
| + rw = RecipeWriter(os.path.join(self._root_dir, 'recipes'), 'foo')
|
| + rw.RunStepsLines = ['pass']
|
| + rw.GenTestsLines = [
|
| + 'yield api.test("basic") + \\',
|
| + ' api.post_process(post_process.DropExpectation)'
|
| + ]
|
| + rw.add_expectation('basic')
|
| + rw.write()
|
| + expectation_file = os.path.join(rw.expect_dir, 'basic.json')
|
| + self.assertTrue(os.path.exists(expectation_file))
|
| + self._run_recipes('test', 'run', '--train')
|
| + self.assertFalse(os.path.exists(expectation_file))
|
| + self.assertFalse(os.path.exists(rw.expect_dir))
|
| +
|
|
|
| if __name__ == '__main__':
|
| sys.exit(unittest.main())
|
|
|