summaryrefslogtreecommitdiff
path: root/test/Interactive/configure.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/Interactive/configure.py')
-rw-r--r--test/Interactive/configure.py76
1 files changed, 68 insertions, 8 deletions
diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py
index 44a53eb70..dfe1c7f6d 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()