Make match_exact the default match function for TestSCons.
[scons.git] / test / exitfns.py
1 #!/usr/bin/env python
2
3 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
4
5 import TestSCons
6
7 test = TestSCons.TestSCons()
8
9 sconstruct = """
10 from SCons.exitfuncs import *
11
12 def x1():
13     print "running x1"
14 def x2(n):
15     print "running x2(%s)" % `n`
16 def x3(n, kwd=None):
17     print "running x3(%s, kwd=%s)" % (`n`, `kwd`)
18
19 register(x3, "no kwd args")
20 register(x1)
21 register(x2, 12)
22 register(x3, 5, kwd="bar")
23 register(x3, "no kwd args")
24
25 """
26
27 expected_output = """running x3('no kwd args', kwd=None)
28 running x3(5, kwd='bar')
29 running x2(12)
30 running x1
31 running x3('no kwd args', kwd=None)
32 """
33
34 test.write('SConstruct', sconstruct)
35
36 test.run(arguments='-f SConstruct', stdout = expected_output)
37
38 test.write('SConstruct', """import sys
39 def f():
40     pass
41
42 sys.exitfunc = f
43 """ + sconstruct)
44
45 test.run(arguments='-f SConstruct', stdout = expected_output)
46
47 test.pass_test()