From ee869fcc10bfd903b37606f45d324d7c5428f67e Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sat, 7 Apr 2012 19:00:37 -0400 Subject: Fix test failures in test/explain/basic.py on Windows due to drive-name case problems (C: vs. c:) Added new test match function, match_caseinsensitive to handle this and probably other similar cases. --- QMTest/TestCmd.py | 24 ++++++++++++++++++++++++ test/explain/basic.py | 2 ++ 2 files changed, 26 insertions(+) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 1d5e4d0..a27df27 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -128,6 +128,7 @@ There are a bunch of methods that let you do different things: test.match_exact("actual 1\nactual 2\n", "expected 1\nexpected 2\n") test.match_exact(["actual 1\n", "actual 2\n"], ["expected 1\n", "expected 2\n"]) + test.match_caseinsensitive("Actual 1\nACTUAL 2\n", "expected 1\nEXPECTED 2\n") test.match_re("actual 1\nactual 2\n", regex_string) test.match_re(["actual 1\n", "actual 2\n"], list_of_regexes) @@ -180,6 +181,8 @@ matching in the same way as the match_*() methods described above. test = TestCmd.TestCmd(match = TestCmd.match_exact) + test = TestCmd.TestCmd(match = TestCmd.match_caseinsensitive) + test = TestCmd.TestCmd(match = TestCmd.match_re) test = TestCmd.TestCmd(match = TestCmd.match_re_dotall) @@ -190,6 +193,8 @@ These functions are also available as static methods: test = TestCmd.TestCmd(match = TestCmd.TestCmd.match_exact) + test = TestCmd.TestCmd(match = TestCmd.TestCmd.match_caseinsensitive) + test = TestCmd.TestCmd(match = TestCmd.TestCmd.match_re) test = TestCmd.TestCmd(match = TestCmd.TestCmd.match_re_dotall) @@ -200,6 +205,8 @@ These static methods can be accessed by a string naming the method: test = TestCmd.TestCmd(match = 'match_exact') + test = TestCmd.TestCmd(match = 'match_caseinsensitive') + test = TestCmd.TestCmd(match = 'match_re') test = TestCmd.TestCmd(match = 'match_re_dotall') @@ -328,6 +335,7 @@ __all__ = [ 'no_result', 'pass_test', 'match_exact', + 'match_caseinsensitive', 'match_re', 'match_re_dotall', 'python', @@ -466,6 +474,20 @@ def match_exact(lines = None, matches = None): return return 1 +def match_caseinsensitive(lines = None, matches = None): + """ + """ + if not is_List(lines): + lines = lines.split("\n") + if not is_List(matches): + matches = matches.split("\n") + if len(lines) != len(matches): + return + for i in range(len(lines)): + if lines[i].lower() != matches[i].lower(): + return + return 1 + def match_re(lines = None, res = None): """ """ @@ -1127,6 +1149,8 @@ class TestCmd(object): match_exact = staticmethod(match_exact) + match_caseinsensitive = staticmethod(match_caseinsensitive) + match_re = staticmethod(match_re) match_re_dotall = staticmethod(match_re_dotall) diff --git a/test/explain/basic.py b/test/explain/basic.py index bca8436..1f0a16c 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -305,7 +305,9 @@ scons: rebuilding `file3' because `zzz' is a new dependency %(_python_)s %(cat_py)s file3 xxx yyy zzz """ % locals()) +test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) +test.set_match_function(TestSCons.match_exact) test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n") -- cgit v0.12