From 1ecc3628a8fe24d8ed189ee23ca41f2b385b3d8e Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Fri, 16 Sep 2016 09:04:20 +0100 Subject: [PATCH] tests: Add support for functional only tests Modify the ClassicTest class to only emit a stat verification test unit if there is a reference stat file. This makes it possible to design tests that don't care about stat changes. To generate purely functional tests, we need to be able to create empty test reference directories. This does not work well with many revision control systems. As a workaround, add a file named EMPTY to the list of ignored files in the test harness. This file can be used as a placeholder in otherwise empty test directories. Change-Id: I583c8c4e55479f0d48fa99d0b0d1eac9221e6652 Signed-off-by: Andreas Sandberg Reviewed-by: Curtis Dunham --- tests/testing/tests.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/testing/tests.py b/tests/testing/tests.py index 48e034bba..6f887ff80 100644 --- a/tests/testing/tests.py +++ b/tests/testing/tests.py @@ -236,6 +236,7 @@ class ClassicTest(Test): # and other files that we don't care about. ref_ignore_files = FileIgnoreList( names=( + "EMPTY", ), rex=( # Mercurial sometimes leaves backups when applying MQ patches r"\.orig$", @@ -284,17 +285,21 @@ class ClassicTest(Test): ] def verify_units(self): - return [ - DiffStatFile(ref_dir=self.ref_dir, test_dir=self.output_dir, - skip=self.skip_diff_stat) - ] + [ + ref_files = set(self.ref_files()) + units = [] + if "stats.txt" in ref_files: + units.append( + DiffStatFile(ref_dir=self.ref_dir, test_dir=self.output_dir, + skip=self.skip_diff_stat)) + units += [ DiffOutFile(f, ref_dir=self.ref_dir, test_dir=self.output_dir, skip=self.skip_diff_out) - for f in self.ref_files() - if f not in ClassicTest.diff_ignore_files + for f in ref_files if f not in ClassicTest.diff_ignore_files ] + return units + def update_ref(self): for fname in self.ref_files(): shutil.copy(