summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2015-11-13 15:01:44 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2015-11-13 15:01:44 (GMT)
commit4a0683af8a414b8143dbc369d59f4349d99089ac (patch)
tree3d4643d1382f4fb3c0cf79b97a7caa10a6023711 /QMTest
parentc2d974ea65afe9ab1968a16c797155fd799527ca (diff)
parent04b306103a2c37b90f2d764112c0cb5527313849 (diff)
downloadSCons-4a0683af8a414b8143dbc369d59f4349d99089ac.zip
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.gz
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.bz2
Merged in williamblevins/scons_20150323 (pull request #244)
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCommon.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 4e90e16..c4a5373 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -36,6 +36,8 @@ provided by the TestCommon class:
test.must_contain('file', 'required text\n')
+ test.must_contain_all(output, input, ['title', find])
+
test.must_contain_all_lines(output, lines, ['title', find])
test.must_contain_any_line(output, lines, ['title', find])
@@ -305,6 +307,36 @@ class TestCommon(TestCmd):
print file_contents
self.fail_test(not contains)
+ def must_contain_all(self, output, input, title=None, find=None):
+ """Ensures that the specified output string (first argument)
+ contains all of the specified input as a block (second argument).
+
+ An optional third argument can be used to describe the type
+ of output being searched, and only shows up in failure output.
+
+ An optional fourth argument can be used to supply a different
+ function, of the form "find(line, output), to use when searching
+ for lines in the output.
+ """
+ if find is None:
+ def find(o, i):
+ try:
+ return o.index(i)
+ except ValueError:
+ return None
+
+ if is_List(output):
+ output = os.newline.join(output)
+
+ if find(output, input) is None:
+ if title is None:
+ title = 'output'
+ print 'Missing expected input from %s:' % title
+ print input
+ print self.banner(title + ' ')
+ print output
+ self.fail_test()
+
def must_contain_all_lines(self, output, lines, title=None, find=None):
"""Ensures that the specified output string (first argument)
contains all of the specified lines (second argument).