diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2021-04-05 15:29:15 (GMT) |
---|---|---|
committer | Daniel Moody <daniel.moody@mongodb.com> | 2021-04-05 15:29:15 (GMT) |
commit | ce9ea2580fa5e4bb143d5ada308c42e40512be19 (patch) | |
tree | c69516e94832f2126509ed79f31241523e021dd6 /testing/framework | |
parent | 97ccb53b8b8c8058904ce4c295affc5a99630ca5 (diff) | |
download | SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.zip SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.tar.gz SCons-ce9ea2580fa5e4bb143d5ada308c42e40512be19.tar.bz2 |
improved DoubleCacheDir test, added extra cachedir validation check.
Diffstat (limited to 'testing/framework')
-rw-r--r-- | testing/framework/TestCommon.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 1471439..34a7f6d 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -57,7 +57,7 @@ provided by the TestCommon class: test.must_not_exist('file1', ['file2', ...]) test.must_not_be_empty('file') - + test.run(options = "options to be prepended to arguments", stdout = "expected standard output from the program", stderr = "expected error output from the program", @@ -303,7 +303,7 @@ class TestCommon(TestCmd): Calling test exits FAILED if search result is false """ if 'b' in mode: - # Python 3: reading a file in binary mode returns a + # Python 3: reading a file in binary mode returns a # bytes object. We cannot find the index of a different # (str) type in that, so convert. required = to_bytes(required) @@ -369,6 +369,34 @@ class TestCommon(TestCmd): sys.stdout.write(output) self.fail_test() + def must_contain_single_instance_of(self, output, lines, title=None): + """Ensures that the specified output string (first argument) + contains one instance of the specified lines (second argument). + + An optional third argument can be used to describe the type + of output being searched, and only shows up in failure output. + + """ + missing = [] + if is_List(output): + output = '\n'.join(output) + + counts = {} + for line in lines: + count = output.count(line) + if count != 1: + counts[line] = count + + if counts: + if title is None: + title = 'output' + sys.stdout.write("Unexpected number of lines from %s:\n" % title) + for line in counts: + sys.stdout.write(' ' + repr(line) + ": found " + str(counts[line]) + '\n') + sys.stdout.write(self.banner(title + ' ') + '\n') + sys.stdout.write(output) + self.fail_test() + def must_contain_any_line(self, output, lines, title=None, find=None): """Ensures that the specified output string (first argument) contains at least one of the specified lines (second argument). @@ -581,7 +609,7 @@ class TestCommon(TestCmd): fsize = os.path.getsize(file) except OSError: fsize = 0 - + if fsize == 0: print("File is empty: `%s'" % file) self.fail_test(file) |