summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2013-03-17 00:43:54 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2013-03-17 00:43:54 (GMT)
commite8f1182787dc7f1187759224830815a85a5e3446 (patch)
tree59b29967d98fea2403c729c0aa31e98d2c39d227 /test
parent1d3de8cda278418e624c7c808e12ab069d514c69 (diff)
parentede4ee9b3306ca546c2f04bcabff9f970ed1cb9a (diff)
downloadSCons-e8f1182787dc7f1187759224830815a85a5e3446.zip
SCons-e8f1182787dc7f1187759224830815a85a5e3446.tar.gz
SCons-e8f1182787dc7f1187759224830815a85a5e3446.tar.bz2
Merged in carandraug/scons (pull request #67).
Added test for CheckContext custom result types. Also allow test.must_match() to take a match type.
Diffstat (limited to 'test')
-rw-r--r--test/Configure/custom-tests.py90
1 files changed, 87 insertions, 3 deletions
diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py
index 9cefa2d..f79ea0d 100644
--- a/test/Configure/custom-tests.py
+++ b/test/Configure/custom-tests.py
@@ -69,13 +69,13 @@ def CheckCustom(test):
resOK = resOK and retActOK and int(outputActOK)==0
resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!=""
resFAIL = resFAIL or retActFAIL or outputActFAIL!=""
- test.Result( int(resOK and not resFAIL) )
+ test.Result( resOK and not resFAIL )
return resOK and not resFAIL
env = Environment()
import os
env.AppendENVPath('PATH', os.environ['PATH'])
-conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} )
+conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} )
conf.CheckCustom()
env = conf.Finish()
""" % locals())
@@ -83,7 +83,7 @@ env = conf.Finish()
test.run()
test.checkLogAndStdout(["Executing MyTest ... "],
- ["yes"],
+ ["yes"],
[[(('.c', NCR), (_obj, NCR)),
(('.c', NCR), (_obj, NCF)),
(('.c', NCR), (_obj, NCR), (_exe, NCR)),
@@ -96,6 +96,7 @@ test.checkLogAndStdout(["Executing MyTest ... "],
test.run()
+# Try again to check caching
test.checkLogAndStdout(["Executing MyTest ... "],
["yes"],
[[(('.c', CR), (_obj, CR)),
@@ -108,6 +109,89 @@ test.checkLogAndStdout(["Executing MyTest ... "],
(('', CF),)]],
"config.log", ".sconf_temp", "SConstruct")
+# Test other customs:
+test.write('SConstruct', """\
+def CheckList(test):
+ test.Message( 'Display of list ...' )
+ res = [1, 2, 3, 4]
+ test.Result( res )
+ return res
+
+def CheckEmptyList(test):
+ test.Message( 'Display of empty list ...' )
+ res = list()
+ test.Result( res )
+ return res
+
+def CheckRandomStr(test):
+ test.Message( 'Display of random string ...' )
+ res = "a random string"
+ test.Result( res )
+ return res
+
+def CheckEmptyStr(test):
+ test.Message( 'Display of empty string ...' )
+ res = ""
+ test.Result( res )
+ return res
+
+def CheckDict(test):
+ test.Message( 'Display of dictionary ...' )
+ res = {"key1" : 1, "key2" : "text"}
+ test.Result( res )
+ return res
+
+def CheckEmptyDict(test):
+ test.Message( 'Display of empty dictionary ...' )
+ res = dict
+ test.Result( res )
+ return res
+
+env = Environment()
+import os
+env.AppendENVPath('PATH', os.environ['PATH'])
+conf = Configure( env, custom_tests={'CheckList' : CheckList,
+ 'CheckEmptyList' : CheckEmptyList,
+ 'CheckRandomStr' : CheckRandomStr,
+ 'CheckEmptyStr' : CheckEmptyStr,
+ 'CheckDict' : CheckDict,
+ 'CheckEmptyDict' : CheckEmptyDict} )
+conf.CheckList()
+conf.CheckEmptyList()
+conf.CheckRandomStr()
+conf.CheckEmptyStr()
+conf.CheckDict()
+conf.CheckEmptyDict()
+env = conf.Finish()
+""" % locals())
+
+test.run()
+
+test.must_match('config.log',
+""".*
+.*
+scons: Configure: Display of list ...
+scons: Configure: \(cached\) yes
+
+scons: Configure: Display of empty list ...
+scons: Configure: \(cached\) no
+
+scons: Configure: Display of random string ...
+scons: Configure: \(cached\) a random string
+
+scons: Configure: Display of empty string ...
+scons: Configure: \(cached\).
+
+scons: Configure: Display of dictionary ...
+scons: Configure: \(cached\) yes
+
+scons: Configure: Display of empty dictionary ...
+scons: Configure: \(cached\) yes
+
+
+""",
+match=TestSCons.match_re)
+
test.pass_test()
# Local Variables: