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