diff options
author | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2020-06-29 00:14:00 (GMT) |
---|---|---|
committer | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2020-06-29 00:14:00 (GMT) |
commit | 126af528ca47e95057e8f7d40ae3bcdd8df98ee8 (patch) | |
tree | 793d0409295d6da164d9306dbf0432f608ef23b9 /test/Interactive | |
parent | 32c474d5e6b9a41f23d05b932dd1722370502f9a (diff) | |
download | SCons-126af528ca47e95057e8f7d40ae3bcdd8df98ee8.zip SCons-126af528ca47e95057e8f7d40ae3bcdd8df98ee8.tar.gz SCons-126af528ca47e95057e8f7d40ae3bcdd8df98ee8.tar.bz2 |
Reduce the number of "false negative" test failures for Interactive/configure.py due to unreliable ordering of statements in the actual stdout output. Replace the expected literal text with a series of regular expressions in a custom match function. Update CHANGES.txt as well.
Diffstat (limited to 'test/Interactive')
-rw-r--r-- | test/Interactive/configure.py | 76 |
1 files changed, 68 insertions, 8 deletions
diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py index 44a53eb..dfe1c7f 100644 --- a/test/Interactive/configure.py +++ b/test/Interactive/configure.py @@ -32,6 +32,73 @@ Also tests that "b" can be used as a synonym for "build". __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import TestCmd +import re + +# The order of the statements in the expected stdout is unreliable. + +# case 1 +# scons>>> .*foo\.cpp.* +# scons>>> scons: `foo.obj' is up to date. +# scons>>> .*foo\.cpp.* +# scons>>> scons: `foo.obj' is up to date. +# scons>>>\s* + +# case 2 +# scons>>> .*foo\.cpp.* +# scons>>> .*foo\.cpp.* +# scons>>> scons: `foo.obj' is up to date. +# scons>>> scons: `foo.obj' is up to date. +# scons>>>\s* + +# The order of this list is related to the order of the counts below +expected_patterns = [ + re.compile("^scons>>> .*foo\.cpp.*$"), + re.compile("^scons>>> scons: `foo.obj' is up to date\.$"), + re.compile("^scons>>>\s*$"), +] + +# The order of this list is related to the order of the regular expressions above +expected_counts = [ + [2,2,1], # case 1 and 2 +] + +# This is used for the diff output when the test fails and to distinguish between +# stdout and stderr in the match function below. +expect_stdout = r"""scons>>> .*foo\.cpp.* +scons>>> .*foo\.cpp.* +scons>>> scons: `foo.obj' is up to date. +scons>>> scons: `foo.obj' is up to date. +scons>>>\s* +""" + +def match_custom(lines, expect): + + if expect != expect_stdout: + # stderr + if lines == expect: + return 1 + return None + + # taken directly from TestCmd + if not TestCmd.is_List(lines): + # CRs mess up matching (Windows) so split carefully + lines = re.split('\r?\n', lines) + + # record number of matches for each regex + n_actual = [0] * len(expected_patterns) + for line in lines: + for i, regex in enumerate(expected_patterns): + if regex.search(line): + n_actual[i] += 1 + break + + # compare actual counts to expected counts + for n_expect in expected_counts: + if n_actual == n_expect: + return 1 + + return None _python_ = TestSCons._python_ @@ -108,14 +175,7 @@ scons.send("b foo.obj\n") scons.send("build foo.obj\n") -expect_stdout = r"""scons>>> .*foo\.cpp.* -scons>>> .*foo\.cpp.* -scons>>> scons: `foo.obj' is up to date. -scons>>> scons: `foo.obj' is up to date. -scons>>>\s* -""" - -test.finish(scons, stdout = expect_stdout, match=TestSCons.match_re) +test.finish(scons, stdout = expect_stdout, stderr = '', match = match_custom) test.pass_test() |