diff options
Diffstat (limited to 'test/Errors')
| -rw-r--r-- | test/Errors/AttributeError.py | 53 | ||||
| -rw-r--r-- | test/Errors/Exception.py | 82 | ||||
| -rw-r--r-- | test/Errors/InternalError.py | 59 | ||||
| -rw-r--r-- | test/Errors/NameError.py | 53 | ||||
| -rw-r--r-- | test/Errors/SyntaxError.py | 57 | ||||
| -rw-r--r-- | test/Errors/TypeError.py | 53 | ||||
| -rw-r--r-- | test/Errors/UserError.py | 56 | ||||
| -rw-r--r-- | test/Errors/execute-a-directory.py | 115 | ||||
| -rw-r--r-- | test/Errors/exit-status.py | 60 | ||||
| -rw-r--r-- | test/Errors/non-executable-file.py | 109 | ||||
| -rw-r--r-- | test/Errors/nonexistent-executable.py | 83 | ||||
| -rw-r--r-- | test/Errors/permission-denied.py | 70 | ||||
| -rw-r--r-- | test/Errors/preparation.py | 81 |
13 files changed, 931 insertions, 0 deletions
diff --git a/test/Errors/AttributeError.py b/test/Errors/AttributeError.py new file mode 100644 index 0000000..c666a2d --- /dev/null +++ b/test/Errors/AttributeError.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws an AttributeError. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +a = 1 +a.append(2) +""") + +test.run(status = 2, stderr = """\ +(AttributeError|<type 'exceptions\.AttributeError'>): 'int' object has no attribute 'append': + File ".+SConstruct", line 2: + a.append\(2\) +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py new file mode 100644 index 0000000..cc36035 --- /dev/null +++ b/test/Errors/Exception.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +def foo(env, target, source): + print str(target[0]) + open(str(target[0]), 'wt').write('foo') + +def exit(env, target, source): + raise Exception('exit') + +env = Environment(BUILDERS = { 'foo' : Builder(action=foo), + 'exit' : Builder(action=exit) }) + +env.foo('foo.out', 'foo.in') +env.exit('exit.out', 'exit.in') +""") + +test.write('foo.in', 'foo\n') + +test.write('exit.in', 'exit\n') + +# print_exception doesn't always show a source line if the source file +# 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 : exit +Traceback \((most recent call|innermost) last\): +( File ".+", line \d+, in \S+ + [^\n]+ +)*( File ".+", line \d+, in \S+ +)*( File ".+", line \d+, in \S+ + [^\n]+ +)*\S.+ +""" + +# Build foo.out first, and expect an error when we try to build exit.out. +test.run(arguments='foo.out exit.out', stderr=expect, status=2) + +# Rebuild. foo.out should be up to date, and we should get the +# expected error building exit.out. +test.run(arguments='foo.out exit.out', stderr=expect, status=2) + +stdout = test.stdout() + +expect = "scons: `foo.out' is up to date." +test.must_contain_all_lines(test.stdout(), [expect]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/InternalError.py b/test/Errors/InternalError.py new file mode 100644 index 0000000..8ed6da1 --- /dev/null +++ b/test/Errors/InternalError.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws an InternalError. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +# Test InternalError. +test.write('SConstruct', """ +assert "InternalError" not in globals() +from SCons.Errors import InternalError +raise InternalError('error inside') +""") + +test.run(stdout = "scons: Reading SConscript files ...\ninternal error\n", + stderr = r"""Traceback \((most recent call|innermost) last\): + File ".+", line \d+, in .+ + File ".+", line \d+, in .+ + File ".+", line \d+, in .+ + File ".+SConstruct", line \d+, in .+ + raise InternalError\('error inside'\) +InternalError: error inside +""", status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/NameError.py b/test/Errors/NameError.py new file mode 100644 index 0000000..0281253 --- /dev/null +++ b/test/Errors/NameError.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws a NameError (tries to reference a Python variable that +doesn't exist). +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +a == 1 +""") + +test.run(status = 2, stderr = """\ +NameError: [^\n]* + File ".+SConstruct", line 1: + a == 1 +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/SyntaxError.py b/test/Errors/SyntaxError.py new file mode 100644 index 0000000..1b7f650 --- /dev/null +++ b/test/Errors/SyntaxError.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws a SyntaxError (contains improper Python code). +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """ +a ! x +""") + +test.run(stdout = "scons: Reading SConscript files ...\n", + stderr = """ File ".+SConstruct", line 2 + + a ! x + + \^ + +SyntaxError: invalid syntax + +""", status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/TypeError.py b/test/Errors/TypeError.py new file mode 100644 index 0000000..286fa26 --- /dev/null +++ b/test/Errors/TypeError.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws a TypeError. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +a = 1 +a[2] = 3 +""") + +test.run(status = 2, stderr = """\ +TypeError:( 'int')? object does not support item assignment: + File ".+SConstruct", line 2: + a\[2\] = 3 +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/UserError.py b/test/Errors/UserError.py new file mode 100644 index 0000000..669260d --- /dev/null +++ b/test/Errors/UserError.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an SConstruct file +throws a UserError. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """ +assert "UserError" not in globals() +import SCons.Errors +raise SCons.Errors.UserError('Depends() requires both sources and targets.') +""") + +expect = """ +scons: \*\*\* Depends\(\) requires both sources and targets. +""" + TestSCons.file_expr + +test.run(stdout = "scons: Reading SConscript files ...\n", + stderr = expect, + status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/execute-a-directory.py b/test/Errors/execute-a-directory.py new file mode 100644 index 0000000..1d2036e --- /dev/null +++ b/test/Errors/execute-a-directory.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +not_executable = test.workpath("not_executable") + +test.write(not_executable, "\n") + +test.write("f3.in", "\n") + +test.write('SConstruct', r""" +bld = Builder(action = '%s $SOURCES $TARGET') +env = Environment(BUILDERS = { 'bld' : bld }) +env.bld(target = 'f3', source = 'f3.in') +""" % test.workdir.replace('\\', '\\\\')) + +test.run(arguments='.', + stdout = test.wrap_stdout("%s f3.in f3\n" % test.workdir, error=1), + stderr = None, + status = 2) + +bad_command = """\ +Bad command or file name +""" + +unrecognized = """\ +'.+' is not recognized as an internal or external command, +operable program or batch file. +scons: \*\*\* \[%s\] Error 1 +""" + +unspecified = """\ +The name specified is not recognized as an +internal or external command, operable program or batch file. +scons: \*\*\* \[%s\] Error 1 +""" + +cannot_execute = """\ +(sh: )*.+: cannot execute +scons: \*\*\* \[%s\] Error %s +""" + +permission_denied = """\ +.+: (p|P)ermission denied +scons: \*\*\* \[%s\] Error %s +""" + +is_a_directory = """\ +.+: (i|I)s a directory +scons: \*\*\* \[%s\] Error %s +""" + +konnte_nicht_gefunden_werden = """\ +Der Befehl ".+" ist entweder falsch geschrieben oder +konnte nicht gefunden werden. +scons: \*\*\* \[%s\] Error %s +""" + +test.description_set("Incorrect STDERR:\n%s\n" % test.stderr()) +if os.name == 'nt': + errs = [ + bad_command, + unrecognized % 'f3', + konnte_nicht_gefunden_werden % ('f3', 1), + unspecified % 'f3' + ] +elif sys.platform.find('sunos') != -1: + errs = [ + cannot_execute % ('f3', 1), + ] +else: + errs = [ + cannot_execute % ('f3', 126), + is_a_directory % ('f3', 126), + permission_denied % ('f3', 126), + ] + +test.must_contain_any_line(test.stderr(), errs, find=TestSCons.search_re) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/exit-status.py b/test/Errors/exit-status.py new file mode 100644 index 0000000..554f394 --- /dev/null +++ b/test/Errors/exit-status.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the exit status and error output if an external command throws +a non-zero exit status. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('build.py', ''' +import sys +sys.exit(7) +''') + +test.write('SConstruct', """ +env=Environment() +Default(env.Command(['one.out', 'two.out'], + ['foo.in'], + action=r'%(_python_)s build.py')) +""" % locals()) + +test.write('foo.in', "foo.in\n") + +test.run(status=2, stderr="scons: \\*\\*\\* \\[one.out\\] Error 7\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/non-executable-file.py b/test/Errors/non-executable-file.py new file mode 100644 index 0000000..e1b8f4e --- /dev/null +++ b/test/Errors/non-executable-file.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +not_executable = test.workpath("not_executable") + +test.write(not_executable, "\n") + +test.write("f1.in", "\n") + +bad_command = """\ +Bad command or file name +""" + +unrecognized = """\ +'.+' is not recognized as an internal or external command, +operable program or batch file. +scons: \*\*\* \[%s\] Error 1 +""" + +unspecified = """\ +The name specified is not recognized as an +internal or external command, operable program or batch file. +scons: \*\*\* \[%s\] Error 1 +""" + +cannot_execute = """\ +(sh: )*.+: cannot execute +scons: \*\*\* \[%s\] Error %s +""" + +permission_denied = """\ +.+: (p|P)ermission denied +scons: \*\*\* \[%s\] Error %s +""" + +konnte_nicht_gefunden_werden = """\ +Der Befehl ".+" ist entweder falsch geschrieben oder +konnte nicht gefunden werden. +scons: \*\*\* \[%s\] Error %s +""" + +test.write('SConstruct', r""" +bld = Builder(action = '%s $SOURCES $TARGET') +env = Environment(BUILDERS = { 'bld': bld }) +env.bld(target = 'f1', source = 'f1.in') +""" % not_executable.replace('\\', '\\\\')) + +test.run(arguments='.', + stdout = test.wrap_stdout("%s f1.in f1\n" % not_executable, error=1), + stderr = None, + status = 2) + +test.description_set("Incorrect STDERR:\n%s\n" % test.stderr()) +if os.name == 'nt': + errs = [ + bad_command, + unrecognized % 'f1', + konnte_nicht_gefunden_werden % ('f1', 1), + unspecified % 'f1' + ] +elif sys.platform.find('sunos') != -1: + errs = [ + cannot_execute % ('f1', 1), + ] +else: + errs = [ + cannot_execute % ('f1', 126), + permission_denied % ('f1', 126), + ] + +test.must_contain_any_line(test.stderr(), errs, find=TestSCons.search_re) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/nonexistent-executable.py b/test/Errors/nonexistent-executable.py new file mode 100644 index 0000000..acaaaeb --- /dev/null +++ b/test/Errors/nonexistent-executable.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +no_such_file = test.workpath("no_such_file") + +test.write("f1.in", "\n") + +test.write('SConstruct', r""" +bld = Builder(action = '%s $SOURCES $TARGET') +env = Environment(BUILDERS = { 'bld' : bld }) +env.bld(target = 'f1', source = 'f1.in') +""" % no_such_file.replace('\\', '\\\\')) + +test.run(arguments='.', + stdout = test.wrap_stdout("%s f1.in f1\n" % no_such_file, error=1), + stderr = None, + status = 2) + +bad_command = """Bad command or file name""" +unrecognized = r"""'.+' is not recognized as an internal or external command,\s+operable program or batch file.\sscons: \*\*\* \[%s\] Error 1""" +unspecified = r"""The name specified is not recognized as an\s+internal or external command, operable program or batch file.\s+scons: \*\*\* \[%s\] Error 1""" +not_found_space = r"""sh: (\d: )*.+: \s*not found\s+scons: \*\*\* \[%s\] Error %s""" +No_such = r""".+: No such file or directory\s+scons: \*\*\* \[%s\] Error %s""" +konnte_nicht_gefunden_werden = r"""Der Befehl ".+" ist entweder falsch geschrieben oder\s+konnte nicht gefunden werden.\s+scons: \*\*\* \[%s\] Error %s""" + +test.description_set("Incorrect STDERR:\n%s\n" % test.stderr()) +if os.name == 'nt': + errs = [ + bad_command, + unrecognized % 'f1', + konnte_nicht_gefunden_werden % ('f1', 1), + unspecified % 'f1' + ] +elif sys.platform.find('sunos') != -1: + errs = [ + not_found_space % ('f1', 1), + ] +else: + errs = [ + not_found_space % ('f1', 1), + not_found_space % ('f1', 127), + No_such % ('f1', 127), + ] + +test.must_contain_any_line(test.stderr(), errs, find=TestSCons.search_re) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/permission-denied.py b/test/Errors/permission-denied.py new file mode 100644 index 0000000..0134803 --- /dev/null +++ b/test/Errors/permission-denied.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', r""" +env = Environment() +env.Command('test.out', 'test.in', Copy('$TARGET', '$SOURCE')) +env.InstallAs('test2.out', 'test.out') +# Mark test2.out as precious so we'll handle the exception in +# FunctionAction() rather than when the target is cleaned before building. +env.Precious('test2.out') +env.Default('test2.out') +""") + +test.write('test.in', "test.in 1\n") + +test.run(arguments = '.') + +test.write('test.in', "test.in 2\n") + +test.writable('test2.out', 0) +f = open(test.workpath('test2.out')) + +test.run(arguments = '.', + stderr = None, + status = 2) + +f.close() +test.writable('test2.out', 1) + +test.description_set("Incorrect STDERR:\n%s" % test.stderr()) +errs = [ + "scons: *** [test2.out] test2.out: Permission denied\n", + "scons: *** [test2.out] test2.out: permission denied\n", +] +test.fail_test(test.stderr() not in errs) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/preparation.py b/test/Errors/preparation.py new file mode 100644 index 0000000..914827a --- /dev/null +++ b/test/Errors/preparation.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +A currently disabled test that used to verify that we print a useful +message (and exit non-zero) if an external error occurs while deciding +if a Node is current or not. + +This behavior changed when the Big Signature Refactoring changed when +signature calculation happens to *after* a Node has been visited (and +therefore visiting source Nodes in turn). Creating an analogous situation +in the new code isn't obvious, and It's not clear whether we need it +anyway, so we're going to leave this checked in but disabled for now. +""" + +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_test('Test not useful with current code; skipping.\n') + +work_file_out = test.workpath('work', 'file.out') + +test.subdir('install', 'work') + +test.write(['work', 'SConstruct'], """\ +file_out = Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +Alias("install", file_out) + +# Make a directory where we expect the File() to be. This causes an +# IOError or OSError when we try to open it to read its signature. +import os +os.mkdir('file.in') +""" % locals()) + +if sys.platform == 'win32': + error_message = "Permission denied" +else: + error_message = "Is a directory" + +expect = """\ +scons: *** [install] %(work_file_out)s: %(error_message)s +""" % locals() + +test.run(chdir = 'work', + arguments = 'install', + status = 2, + stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |
