summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CXX/CCFLAGS.py2
-rw-r--r--test/CXX/CXXFILESUFFIX.py2
-rw-r--r--test/CXX/CXXFLAGS.py2
-rw-r--r--test/File.py20
-rw-r--r--test/Fortran/link-with-cxx.py140
-rw-r--r--test/Interactive/failure.py151
-rw-r--r--test/KeyboardInterrupt.py2
-rw-r--r--test/Win32/default-drive.py (renamed from test/default-drive.py)3
-rw-r--r--test/Win32/mingw.py (renamed from test/mingw.py)0
-rw-r--r--test/Win32/scons-bat-error.py84
-rw-r--r--test/Win32/win32pathmadness.py (renamed from test/win32pathmadness.py)0
11 files changed, 397 insertions, 9 deletions
diff --git a/test/CXX/CCFLAGS.py b/test/CXX/CCFLAGS.py
index a867340..deaa2b6 100644
--- a/test/CXX/CCFLAGS.py
+++ b/test/CXX/CCFLAGS.py
@@ -51,7 +51,7 @@ test.write('prog.cpp', r"""
int
main(int argc, char *argv[])
{
- argv[argc++] = "--";
+ argv[argc++] = (char *)"--";
#ifdef FOO
printf("prog.c: FOO\n");
#endif
diff --git a/test/CXX/CXXFILESUFFIX.py b/test/CXX/CXXFILESUFFIX.py
index fbc34ff..d2a70c3 100644
--- a/test/CXX/CXXFILESUFFIX.py
+++ b/test/CXX/CXXFILESUFFIX.py
@@ -62,7 +62,7 @@ input = r"""
int
main(int argc, char *argv[])
{
- argv[argc++] = "--";
+ argv[argc++] = (char *)"--";
printf("LEX\n");
printf("%s\n");
exit (0);
diff --git a/test/CXX/CXXFLAGS.py b/test/CXX/CXXFLAGS.py
index 86f14f0..f37cdbb 100644
--- a/test/CXX/CXXFLAGS.py
+++ b/test/CXX/CXXFLAGS.py
@@ -120,7 +120,7 @@ test.write('prog.cpp', r"""
int
main(int argc, char *argv[])
{
- argv[argc++] = "--";
+ argv[argc++] = (char *)"--";
#ifdef FOO
printf("prog.c: FOO\n");
#endif
diff --git a/test/File.py b/test/File.py
index 6f634cf..583e6b4 100644
--- a/test/File.py
+++ b/test/File.py
@@ -25,9 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Verify that the File() global function and environment method work
-correctly, and that the former does not try to expand construction
-variables.
+Verify that:
+
+ -- the File() global function and environment method work correctly;
+ -- the former does not try to expand construction variables;
+ -- calling File() as a method of a File() object works correctly.
"""
import TestSCons
@@ -42,17 +44,25 @@ print File('${BAR}_$BAR')
print env.File('eee')
print env.File('$FOO')
print env.File('${BAR}_$BAR')
+f1 = env.File('f1')
+print f1
+f2 = f1.File('f2')
+print f2
""")
-test.run(stdout = test.wrap_stdout(read_str = """\
+expect = test.wrap_stdout(read_str = """\
ddd
$FOO
${BAR}_$BAR
eee
fff
bbb_bbb
+f1
+f2
""", build_str = """\
scons: `.' is up to date.
-"""))
+""")
+
+test.run(stdout = expect)
test.pass_test()
diff --git a/test/Fortran/link-with-cxx.py b/test/Fortran/link-with-cxx.py
new file mode 100644
index 0000000..6c05ae1
--- /dev/null
+++ b/test/Fortran/link-with-cxx.py
@@ -0,0 +1,140 @@
+#!/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 warnings message used when attempting to link C++ and
+Fortran object files, and the ability to suppress them with the
+right --warn= options.
+"""
+
+import re
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons(match = TestSCons.match_re)
+
+
+test.write('test_linker.py', r"""
+import sys
+outfile = open(sys.argv[2], 'wb')
+for infile in sys.argv[3:]:
+ outfile.write(open(infile, 'rb').read())
+outfile.close()
+sys.exit(0)
+""")
+
+
+test.write('test_fortran.py', r"""
+import sys
+outfile = open(sys.argv[2], 'wb')
+for infile in sys.argv[4:]:
+ outfile.write(open(infile, 'rb').read())
+outfile.close()
+sys.exit(0)
+""")
+
+
+test.write('SConstruct', """
+def copier(target, source, env):
+ s = str(source[0])
+ t = str(target[0])
+ open(t, 'wb').write(open(s, 'rb').read())
+env = Environment(CXX = r'%(_python_)s test_linker.py',
+ CXXCOM = Action(copier),
+ # We want to re-define this as follows (so as to
+ # not rely on a real Fortran compiler) but can't
+ # because $FORTRANCOM is defined with an extra space
+ # so it ends up as a CommandAction, not a LazyAction.
+ # Must look into changing that after 1.0 is out.
+ #FORTRANCOM = Action(copier))
+ FORTRAN = r'%(_python_)s test_fortran.py')
+env.Program('prog1.exe', ['f1.cpp', 'f2.f'])
+env.Program('prog2.exe', ['f1.cpp', 'f2.f'])
+if ARGUMENTS.get('NO_LINK'):
+ # Can remove no-deprecated when we drop Python1.5
+ SetOption('warn', ['no-link', 'no-deprecated'])
+if ARGUMENTS.get('NO_MIX'):
+ # Can remove no-deprecated when we drop Python1.5
+ SetOption('warn', ['no-fortran-cxx-mix', 'no-deprecated'])
+""" % locals())
+
+test.write('f1.cpp', "f1.cpp\n")
+test.write('f2.f', "f2.f\n")
+
+expect = ("""
+scons: warning: Using \\$CXX to link Fortran and C\\+\\+ code together.
+\tThis may generate a buggy executable if the '%s test_linker.py'
+\tcompiler does not know how to deal with Fortran runtimes.
+""" % re.escape(_python_)) + TestSCons.file_expr
+
+test.run(arguments = '.', stderr=expect)
+
+test.must_match('prog1.exe', "f1.cpp\nf2.f\n")
+test.must_match('prog2.exe', "f1.cpp\nf2.f\n")
+
+test.run(arguments = '-c .', stderr=expect)
+
+test.must_not_exist('prog1.exe')
+test.must_not_exist('prog2.exe')
+
+test.run(arguments = '--warning=no-link .')
+
+test.must_match('prog1.exe', "f1.cpp\nf2.f\n")
+test.must_match('prog2.exe', "f1.cpp\nf2.f\n")
+
+test.run(arguments = '-c .', stderr=expect)
+
+test.must_not_exist('prog1.exe')
+test.must_not_exist('prog2.exe')
+
+test.run(arguments = '--warning=no-fortran-cxx-mix .')
+
+test.must_match('prog1.exe', "f1.cpp\nf2.f\n")
+test.must_match('prog2.exe', "f1.cpp\nf2.f\n")
+
+test.run(arguments = '-c .', stderr=expect)
+
+test.must_not_exist('prog1.exe')
+test.must_not_exist('prog2.exe')
+
+test.run(arguments = 'NO_LINK=1 .')
+
+test.must_match('prog1.exe', "f1.cpp\nf2.f\n")
+test.must_match('prog2.exe', "f1.cpp\nf2.f\n")
+
+test.run(arguments = '-c .', stderr=expect)
+
+test.must_not_exist('prog1.exe')
+test.must_not_exist('prog2.exe')
+
+test.run(arguments = 'NO_MIX=1 .')
+
+test.must_match('prog1.exe', "f1.cpp\nf2.f\n")
+test.must_match('prog2.exe', "f1.cpp\nf2.f\n")
+
+test.pass_test()
diff --git a/test/Interactive/failure.py b/test/Interactive/failure.py
new file mode 100644
index 0000000..75f460f
--- /dev/null
+++ b/test/Interactive/failure.py
@@ -0,0 +1,151 @@
+#!/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 that when a build fails, later builds correctly report
+that their builds succeeded, and that we don't get "stuck" on
+reporting the earlier build failure.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+def fail(target, source, env):
+ return 1
+Command('f1.out', 'f1.in', Action(fail))
+Command('f2.out', 'f2.in', Copy('$TARGET', '$SOURCE'))
+Command('1', [], Touch('$TARGET'))
+Command('2', [], Touch('$TARGET'))
+Command('3', [], Touch('$TARGET'))
+Command('4', [], Touch('$TARGET'))
+""")
+
+test.write('f1.in', "f1.in 1\n")
+test.write('f2.in', "f2.in 1\n")
+
+
+
+scons = test.start(arguments = '--interactive')
+
+scons.send("build f1.out\n")
+
+scons.send("build 1\n")
+
+test.wait_for(test.workpath('1'))
+
+test.must_not_exist(test.workpath('f1.out'))
+
+
+
+scons.send("build f2.out\n")
+
+scons.send("build 2\n")
+
+test.wait_for(test.workpath('2'))
+
+test.must_match(test.workpath('f2.out'), "f2.in 1\n")
+
+
+
+scons.send("build f1.out\n")
+
+scons.send("build 3\n")
+
+test.wait_for(test.workpath('3'))
+
+test.must_not_exist(test.workpath('f1.out'))
+
+
+
+test.write('f2.in', "f2.in 2\n")
+
+scons.send("build f2.out\n")
+
+scons.send("build 4\n")
+
+test.wait_for(test.workpath('4'))
+
+test.must_match(test.workpath('f2.out'), "f2.in 2\n")
+
+
+
+expect_stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons>>> scons: Building targets ...
+fail(["f1.out"], ["f1.in"])
+scons: building terminated because of errors.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Touch("1")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Copy("f2.out", "f2.in")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Touch("2")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+fail(["f1.out"], ["f1.in"])
+scons: building terminated because of errors.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Touch("3")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Copy("f2.out", "f2.in")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>> scons: Building targets ...
+Touch("4")
+scons: done building targets.
+scons: Clearing cached node information ...
+scons: done clearing node information.
+scons>>>
+"""
+
+expect_stderr = """\
+scons: *** [f1.out] Error 1
+scons: *** [f1.out] Error 1
+"""
+
+test.finish(scons, stdout = expect_stdout, stderr = expect_stderr)
+
+
+
+test.pass_test()
diff --git a/test/KeyboardInterrupt.py b/test/KeyboardInterrupt.py
index 5a06119..d5010dd 100644
--- a/test/KeyboardInterrupt.py
+++ b/test/KeyboardInterrupt.py
@@ -114,3 +114,5 @@ for i in range(2):
runtest('-j16 --random')
runtest('-j32 --random')
runtest('-j64 --random')
+
+test.pass_test()
diff --git a/test/default-drive.py b/test/Win32/default-drive.py
index a57cde7..94d8377 100644
--- a/test/default-drive.py
+++ b/test/Win32/default-drive.py
@@ -40,7 +40,8 @@ import TestSCons
test = TestSCons.TestSCons()
if sys.platform != 'win32':
- test.pass_test()
+ msg = "Skipping drive-letter test on non-Windows platform '%s'\n" % sys.platform
+ test.skip_test(msg)
test.subdir('src')
diff --git a/test/mingw.py b/test/Win32/mingw.py
index fac8910..fac8910 100644
--- a/test/mingw.py
+++ b/test/Win32/mingw.py
diff --git a/test/Win32/scons-bat-error.py b/test/Win32/scons-bat-error.py
new file mode 100644
index 0000000..d39858b
--- /dev/null
+++ b/test/Win32/scons-bat-error.py
@@ -0,0 +1,84 @@
+#!/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.
+#
+
+"""
+Verify that the scons.bat file returns error codes as we expect.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import sys
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if sys.platform != 'win32':
+ msg = "Skipping scons.bat test on non-Windows platform '%s'\n" % sys.platform
+ test.skip_test(msg)
+
+python = test.where_is('python')
+
+if not python:
+ msg = "Skipping scons.bat test; python is not on %PATH%.\n"
+ test.skip_test(msg)
+
+scons_bat = os.path.splitext(test.program)[0] + '.bat'
+
+if not os.path.exists(scons_bat):
+ msg = "Skipping scons.bat test; %s does not exist.\n" % scons_bat
+ test.skip_test(msg)
+
+test.write('scons.bat', test.read(scons_bat))
+
+# The scons.bat file tries to import SCons.Script from its sys.prefix
+# directories first (i.e., site-packages) which means this test might
+# end up using an installed SCons in preference to something local.
+# If so, create a SConstruct file that will exit with our expected
+# error status. If there is *not* an installed SCons, we still want
+# this test to work, so we make a "SCons" package in the local
+# directory with a Script.py module that contains a main() function
+# that just exits with the expected status.
+
+test.subdir('SCons')
+
+test.write(['SCons', '__init__.py'], "")
+
+test.write(['SCons', 'Script.py'], """\
+import sys
+def main():
+ sys.exit(7)
+""")
+
+test.write('SConstruct', """\
+import sys
+sys.exit(7)
+""")
+
+test.run(program = 'scons.bat', status = 7)
+
+
+
+test.pass_test()
diff --git a/test/win32pathmadness.py b/test/Win32/win32pathmadness.py
index df350eb..df350eb 100644
--- a/test/win32pathmadness.py
+++ b/test/Win32/win32pathmadness.py