From 126af528ca47e95057e8f7d40ae3bcdd8df98ee8 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sun, 28 Jun 2020 20:14:00 -0400 Subject: 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. --- CHANGES.txt | 2 ++ test/Interactive/configure.py | 76 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1b7fde4..2be6667 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -40,6 +40,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER when msvc debug output is enabled (GH Issue #3699). - MSVS test updates: Tests for building a program using generated MSVS project and solution files using MSVS 2015 and later now work as expected on x86 hosts. + - Test update: Reduce the number of "false negative" test failures for the interactive + configuration test (test/interactive/configure.py). From William Deegan: - Fix broken clang + MSVC 2019 combination by using MSVC configuration logic to 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() -- cgit v0.12