diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Alias/errors.py | 2 | ||||
-rw-r--r-- | test/Configure/Action-error.py | 2 | ||||
-rw-r--r-- | test/Errors/Exception.py | 2 | ||||
-rw-r--r-- | test/GetBuildFailures/serial.py | 160 | ||||
-rw-r--r-- | test/Libs/SharedLibrary.py | 4 | ||||
-rw-r--r-- | test/Parallel/multiple-parents.py | 2 | ||||
-rw-r--r-- | test/RCS/diskcheck.py | 2 | ||||
-rw-r--r-- | test/Scanner/exception.py | 2 | ||||
-rw-r--r-- | test/builderrors.py | 26 | ||||
-rw-r--r-- | test/exceptions.py | 4 | ||||
-rw-r--r-- | test/nonexistent.py | 16 | ||||
-rw-r--r-- | test/option/debug-stacktrace.py | 4 | ||||
-rw-r--r-- | test/symlink/dangling-include.py | 5 | ||||
-rw-r--r-- | test/symlink/dangling-source.py | 2 |
14 files changed, 193 insertions, 40 deletions
diff --git a/test/Alias/errors.py b/test/Alias/errors.py index 1205b29..36876c4 100644 --- a/test/Alias/errors.py +++ b/test/Alias/errors.py @@ -40,7 +40,7 @@ env.Alias('A', 'B') """) test.run(arguments='A', - stderr="scons: *** Source `D' not found, needed by target `C'. Stop.\n", + stderr="scons: *** [C] Source `D' not found, needed by target `C'.\n", status=2) test.pass_test() diff --git a/test/Configure/Action-error.py b/test/Configure/Action-error.py index 0abcc7c..22ea7c7 100644 --- a/test/Configure/Action-error.py +++ b/test/Configure/Action-error.py @@ -41,7 +41,7 @@ env = Environment(BUILDERS = {'MyAction' : env.MyAction('target', []) """) -expect = "scons: *** Calling Configure from Builders is not supported.\n" +expect = "scons: *** [target] Calling Configure from Builders is not supported.\n" test.run(status=2, stderr=expect) diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index 710c819..8485ce5 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -53,7 +53,7 @@ test.write('exit.in', 'exit\n') # no longer exists or that line in the source file no longer exists, # so make sure the proper variations are supported in the following # regexp. -expect = """scons: \*\*\* \[exit.out\] Exception +expect = """scons: \*\*\* \[exit.out\] Exception : exit Traceback \((most recent call|innermost) last\): ( File ".+", line \d+, in \S+ [^\n]+ diff --git a/test/GetBuildFailures/serial.py b/test/GetBuildFailures/serial.py index c8205ed..b5d8e44 100644 --- a/test/GetBuildFailures/serial.py +++ b/test/GetBuildFailures/serial.py @@ -31,6 +31,7 @@ attributes we expect to be most commonly used. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import re _python_ = TestSCons._python_ @@ -59,19 +60,43 @@ test.write('mypass.py', contents) test.write('myfail.py', contents) test.write('SConstruct', """\ -Command('f3', 'f3.in', r'@%(_python_)s mypass.py - f3 $TARGET $SOURCE') -Command('f4', 'f4.in', r'@%(_python_)s myfail.py f3 f4 $TARGET $SOURCE') -Command('f5', 'f5.in', r'@%(_python_)s myfail.py f4 f5 $TARGET $SOURCE') -Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') +Command('f03', 'f03.in', r'@%(_python_)s mypass.py - f03 $TARGET $SOURCE') +Command('f04', 'f04.in', r'@%(_python_)s myfail.py f03 f04 $TARGET $SOURCE') +Command('f05', 'f05.in', r'@%(_python_)s myfail.py f04 f05 $TARGET $SOURCE') +Command('f06', 'f06.in', r'@%(_python_)s mypass.py f05 - $TARGET $SOURCE') +Command('f07', 'f07.in', r'@%(_python_)s mypass.py f07 - $TARGET $SOURCE') + +import SCons.Errors +def raiseExcAction(exc): + def action(env, target, source): + raise exc + return action +def returnExcAction(exc): + def action(env, target, source): + return exc + return action +class MyBuildError(SCons.Errors.BuildError): + pass + +Command('f08', 'f08.in', raiseExcAction(SCons.Errors.UserError("My User Error"))) +Command('f09', 'f09.in', returnExcAction(SCons.Errors.UserError("My User Error"))) +Command('f10', 'f10.in', raiseExcAction(MyBuildError(errstr="My Build Error", status=7))) +Command('f11', 'f11.in', returnExcAction(MyBuildError(errstr="My Build Error", status=7))) +Command('f12', 'f12.in', raiseExcAction(EnvironmentError(123, "My EnvironmentError", "f12"))) +Command('f13', 'f13.in', returnExcAction(EnvironmentError(123, "My EnvironmentError", "f13"))) +Command('f14', 'f14.in', raiseExcAction(SCons.Errors.InternalError("My InternalError"))) +Command('f15', 'f15.in', returnExcAction(SCons.Errors.InternalError("My InternalError"))) def print_build_failures(): from SCons.Script import GetBuildFailures import string bf_list = GetBuildFailures() - bf_list.sort(lambda a,b: cmp(a.filename, b.filename)) + bf_list.sort(lambda a,b: cmp(str(a.node), str(b.node))) for bf in bf_list: - print "%%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr) - print " %%s" %% string.join(bf.command) + assert( isinstance(bf, SCons.Errors.BuildError) ) + print "BF: %%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr) + if bf.command: + print "BF: %%s" %% string.join(Flatten(bf.command)) try: import atexit @@ -82,22 +107,31 @@ else: atexit.register(print_build_failures) """ % locals()) -test.write('f3.in', "f3.in\n") -test.write('f4.in', "f4.in\n") -test.write('f5.in', "f5.in\n") -test.write('f6.in', "f6.in\n") +test.write('f03.in', "f03.in\n") +test.write('f04.in', "f04.in\n") +test.write('f05.in', "f05.in\n") +test.write('f06.in', "f06.in\n") +# f07.in is intentionally missing... +test.write('f08.in', "f08.in\n") +test.write('f09.in', "f09.in\n") +test.write('f10.in', "f10.in\n") +test.write('f11.in', "f11.in\n") +test.write('f12.in', "f12.in\n") +test.write('f13.in', "f13.in\n") +test.write('f14.in', "f14.in\n") +test.write('f15.in', "f15.in\n") expect_stdout = """\ scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... scons: building terminated because of errors. -f4 failed (1): Error 1 - %(_python_)s myfail.py f3 f4 "f4" "f4.in" +BF: f04 failed (1): Error 1 +BF: %(_python_)s myfail.py f03 f04 "f04" "f04.in" """ % locals() expect_stderr = """\ -scons: *** [f4] Error 1 +scons: *** [f04] Error 1 """ test.run(arguments = '.', @@ -105,11 +139,101 @@ test.run(arguments = '.', stdout = expect_stdout, stderr = expect_stderr) -test.must_match(test.workpath('f3'), 'f3.in\n') -test.must_not_exist(test.workpath('f4')) -test.must_not_exist(test.workpath('f5')) -test.must_not_exist(test.workpath('f6')) +test.must_match(test.workpath('f03'), 'f03.in\n') +test.must_not_exist(test.workpath('f04')) +test.must_not_exist(test.workpath('f05')) +test.must_not_exist(test.workpath('f06')) +test.must_not_exist(test.workpath('f07')) +test.must_not_exist(test.workpath('f08')) +test.must_not_exist(test.workpath('f09')) +test.must_not_exist(test.workpath('f10')) +test.must_not_exist(test.workpath('f11')) +test.must_not_exist(test.workpath('f12')) +test.must_not_exist(test.workpath('f13')) +test.must_not_exist(test.workpath('f14')) +test.must_not_exist(test.workpath('f15')) + + +expect_stdout = re.escape("""\ +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +action(["f08"], ["f08.in"]) +action(["f09"], ["f09.in"]) +action(["f10"], ["f10.in"]) +action(["f11"], ["f11.in"]) +action(["f12"], ["f12.in"]) +action(["f13"], ["f13.in"]) +action(["f14"], ["f14.in"]) +action(["f15"], ["f15.in"]) +scons: done building targets (errors occurred during build). +BF: f04 failed (1): Error 1 +BF: %(_python_)s myfail.py f03 f04 "f04" "f04.in" +BF: f05 failed (1): Error 1 +BF: %(_python_)s myfail.py f04 f05 "f05" "f05.in" +BF: f07 failed (2): Source `f07.in' not found, needed by target `f07'. +BF: f08 failed (2): My User Error +BF: action(["f08"], ["f08.in"]) +BF: f09 failed (2): My User Error +BF: action(["f09"], ["f09.in"]) +BF: f10 failed (7): My Build Error +BF: action(["f10"], ["f10.in"]) +BF: f11 failed (7): My Build Error +BF: action(["f11"], ["f11.in"]) +BF: f12 failed (123): My EnvironmentError +BF: action(["f12"], ["f12.in"]) +BF: f13 failed (123): My EnvironmentError +BF: action(["f13"], ["f13.in"]) +BF: f14 failed (2): InternalError : My InternalError +BF: action(["f14"], ["f14.in"]) +BF: f15 failed (2): InternalError : My InternalError +BF: action(["f15"], ["f15.in"]) +""" % locals()) +expect_stderr = re.escape("""\ +scons: *** [f04] Error 1 +scons: *** [f05] Error 1 +scons: *** [f07] Source `f07.in' not found, needed by target `f07'. +scons: *** [f08] My User Error +scons: *** [f09] My User Error +scons: *** [f10] My Build Error +scons: *** [f11] My Build Error +scons: *** [f12] f12: My EnvironmentError +scons: *** [f13] f13: My EnvironmentError +scons: *** [f14] InternalError : My InternalError +""") + \ +"""\ +Traceback \((most recent call|innermost) last\): +( File ".+", line \d+, in \S+ + [^\n]+ +)*( File ".+", line \d+, in \S+ +)*( File ".+", line \d+, in \S+ + [^\n]+ +)*\S.+ +""" + \ +re.escape("""\ +scons: *** [f15] InternalError : My InternalError +""") + +test.run(arguments = '-k .', + status = 2, + stdout = expect_stdout, + stderr = expect_stderr, + match = TestSCons.match_re_dotall) + +test.must_match(test.workpath('f03'), 'f03.in\n') +test.must_not_exist(test.workpath('f04')) +test.must_not_exist(test.workpath('f05')) +test.must_match(test.workpath('f06'), 'f06.in\n') +test.must_not_exist(test.workpath('f07')) +test.must_not_exist(test.workpath('f08')) +test.must_not_exist(test.workpath('f09')) +test.must_not_exist(test.workpath('f10')) +test.must_not_exist(test.workpath('f11')) +test.must_not_exist(test.workpath('f12')) +test.must_not_exist(test.workpath('f13')) +test.must_not_exist(test.workpath('f14')) +test.must_not_exist(test.workpath('f15')) test.pass_test() diff --git a/test/Libs/SharedLibrary.py b/test/Libs/SharedLibrary.py index f8447ca..554f8df 100644 --- a/test/Libs/SharedLibrary.py +++ b/test/Libs/SharedLibrary.py @@ -213,13 +213,13 @@ if sys.platform == 'win32' or string.find(sys.platform, 'irix') != -1: test.run(arguments = '-f SConstructFoo') else: test.run(arguments = '-f SConstructFoo', status=2, stderr='''\ -scons: \*\*\* Source file: foo\..* is static and is not compatible with shared target: .* +scons: \*\*\* \[.*\] Source file: foo\..* is static and is not compatible with shared target: .* ''', match=TestSCons.match_re_dotall) # Run it again to make sure that we still get the error # even though the static objects already exist. test.run(arguments = '-f SConstructFoo', status=2, stderr='''\ -scons: \*\*\* Source file: foo\..* is static and is not compatible with shared target: .* +scons: \*\*\* \[.*\] Source file: foo\..* is static and is not compatible with shared target: .* ''', match=TestSCons.match_re_dotall) diff --git a/test/Parallel/multiple-parents.py b/test/Parallel/multiple-parents.py index d9c414f..cfcad73 100644 --- a/test/Parallel/multiple-parents.py +++ b/test/Parallel/multiple-parents.py @@ -143,7 +143,7 @@ Default(all) re_error = """\ (scons: \\*\\*\\* \\[failed\\d+] Error 2\\n)|\ -(scons: \\*\\*\\* Source `MissingSrc' not found, needed by target `missing\\d+'\\.( Stop\\.)?\\n)|\ +(scons: \\*\\*\\* \\[missing\\d+] Source `MissingSrc' not found, needed by target `missing\\d+'\\.( Stop\\.)?\\n)|\ (scons: \\*\\*\\* \\[\\w+] Build interrupted\.\\n)\ """ diff --git a/test/RCS/diskcheck.py b/test/RCS/diskcheck.py index 07cb170..99ba7ed 100644 --- a/test/RCS/diskcheck.py +++ b/test/RCS/diskcheck.py @@ -122,7 +122,7 @@ expect = """\ scons: warning: Ignoring missing SConscript '%(sub_SConscript)s' %(SConstruct_file_line)s -scons: *** Source `aaa.in' not found, needed by target `aaa.out'. Stop. +scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'. """ % locals() test.run(status=2, stderr=expect) diff --git a/test/Scanner/exception.py b/test/Scanner/exception.py index d8204db..5d10fd7 100644 --- a/test/Scanner/exception.py +++ b/test/Scanner/exception.py @@ -109,7 +109,7 @@ test.write('zzz', "zzz 1\n") test.run(arguments = '.', status = 2, stderr = """\ -scons: *** kfile_scan error: yyy 1 +scons: *** [foo] Exception : kfile_scan error: yyy 1 """) test.pass_test() diff --git a/test/builderrors.py b/test/builderrors.py index 28c9a0a..deb52a0 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -181,5 +181,31 @@ test.fail_test(string.find(err, 'Exception') != -1 or \ string.find(err, 'Traceback') != -1) +# Test SConscript with errors and an atexit function. +# Should not give traceback; the task error should get converted +# to a BuildError. +test.write('SConstruct', """ +import atexit + +env = Environment() +env2 = env.Clone() + +env.Install("target", "dir1/myFile") +env2.Install("target", "dir2/myFile") + +def print_build_failures(): + from SCons.Script import GetBuildFailures + for bf in GetBuildFailures(): + print bf.action + +atexit.register(print_build_failures) +""") + +test.run(status=2, stderr=None) +err = test.stderr() +test.fail_test(string.find(err, 'Exception') != -1 or \ + string.find(err, 'Traceback') != -1) + + # No tests failed; OK. test.pass_test() diff --git a/test/exceptions.py b/test/exceptions.py index b0939c0..98e3e83 100644 --- a/test/exceptions.py +++ b/test/exceptions.py @@ -47,7 +47,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.write('foo.in', "foo.in\n") -expected_stderr = """scons: \*\*\* \[foo.out\] Exception +expected_stderr = """scons: \*\*\* \[foo.out\] Exception : func exception Traceback \((most recent call|innermost) last\): ( File ".+", line \d+, in \S+ [^\n]+ @@ -109,7 +109,7 @@ test.run(arguments = '.', status = 2, stderr = expected_stderr) expected_stderr_list = [ "scons: *** [out.f1] Error 1\n", - "scons: *** Source `in.f2' not found, needed by target `out.f2'.\n", + "scons: *** [out.f2] Source `in.f2' not found, needed by target `out.f2'.\n", "scons: *** [out.f3] Error 1\n", ] diff --git a/test/nonexistent.py b/test/nonexistent.py index 3e47cbe..b130a1a 100644 --- a/test/nonexistent.py +++ b/test/nonexistent.py @@ -46,20 +46,21 @@ Dir('ddd') """) test.run(arguments = 'foo', - stderr = "scons: *** Do not know how to make target `foo'. Stop.\n", - status = 2) + stderr = "scons: \\*\\*\\* Do not know how to make target `foo'.( *Stop.)?\n", + status = 2, + match=TestSCons.match_re_dotall) test.run(arguments = '-k foo/bar foo', stderr = "scons: *** Do not know how to make target `%s'.\n" % foo_bar, status = 2) test.run(arguments = "aaa.out", - stderr = "scons: *** Source `aaa.in' not found, needed by target `aaa.out'. Stop.\n", + stderr = "scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'.\n", status = 2) test.run(arguments = "-k bbb.out aaa.out", - stderr = """scons: *** Source `bbb.in' not found, needed by target `bbb.out'. -scons: *** Source `aaa.in' not found, needed by target `aaa.out'. + stderr = """scons: *** [bbb.out] Source `bbb.in' not found, needed by target `bbb.out'. +scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'. """, status = 2) @@ -71,8 +72,9 @@ scons: *** Do not know how to make target `bbb.in'. test.run(arguments = 'xxx', - stderr = "scons: *** Do not know how to make target `xxx'. Stop.\n", - status = 2) + stderr = "scons: \\*\\*\\* Do not know how to make target `xxx'.( *Stop.)?\n", + status = 2, + match=TestSCons.match_re_dotall) test.run(arguments = 'ddd') diff --git a/test/option/debug-stacktrace.py b/test/option/debug-stacktrace.py index cf7b81d..93cb206 100644 --- a/test/option/debug-stacktrace.py +++ b/test/option/debug-stacktrace.py @@ -65,14 +65,14 @@ env.Command('foo', 'foo.k', Copy('$TARGET', '$SOURCE')) test.write('foo.k', "foo.k\n") -test.run(status = 2, stderr = "scons: *** kfile_scan error\n") +test.run(status = 2, stderr = "scons: *** [foo] Exception : kfile_scan error\n") test.run(arguments = "--debug=stacktrace", status = 2, stderr = None) lines = [ - "scons: *** kfile_scan error", + "scons: *** [foo] Exception : kfile_scan error", "scons: internal stack trace:", 'raise Exception, "kfile_scan error"', ] diff --git a/test/symlink/dangling-include.py b/test/symlink/dangling-include.py index 61ef07d..9c9d93a 100644 --- a/test/symlink/dangling-include.py +++ b/test/symlink/dangling-include.py @@ -51,9 +51,10 @@ test.write('foo.c', """\ test.symlink('nonexistent', 'foo.h') expect = """\ -scons: *** Implicit dependency `foo.h' not found, needed by target `%s'. Stop. +scons: \\*\\*\\* \\[foo.o(bj)?\\] Implicit dependency `foo.h' not found, needed by target `%s'.( Stop.)? """% foo_obj -test.run(arguments = '.', status = 2, stderr = expect) +test.run(arguments = '.', status = 2, stderr = expect, + match=TestSCons.match_re_dotall) test.pass_test() diff --git a/test/symlink/dangling-source.py b/test/symlink/dangling-source.py index e242e61..366b742 100644 --- a/test/symlink/dangling-source.py +++ b/test/symlink/dangling-source.py @@ -45,7 +45,7 @@ Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) test.symlink('nonexistent', 'file.in') expect = """\ -scons: *** Source `file.in' not found, needed by target `file.out'. Stop. +scons: *** [file.out] Source `file.in' not found, needed by target `file.out'. """ test.run(arguments = '.', status = 2, stderr = expect) |