summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-06-12 21:16:35 (GMT)
committerSteven Knight <knight@baldmt.com>2002-06-12 21:16:35 (GMT)
commit8facc7d3e757ab88aacd8d430fd7319d13d8a558 (patch)
tree9036a7ce043bb3d4508ab9dab00f214c0c6376e6 /test
parentd1b81f58263a824ca39ecc179f61ad541c5a0f7a (diff)
downloadSCons-8facc7d3e757ab88aacd8d430fd7319d13d8a558.zip
SCons-8facc7d3e757ab88aacd8d430fd7319d13d8a558.tar.gz
SCons-8facc7d3e757ab88aacd8d430fd7319d13d8a558.tar.bz2
Add a native Fortran include scanner.
Diffstat (limited to 'test')
-rw-r--r--test/BuildDir.py62
-rw-r--r--test/F77PATH.py200
2 files changed, 258 insertions, 4 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py
index c547ef9..aae3a78 100644
--- a/test/BuildDir.py
+++ b/test/BuildDir.py
@@ -47,6 +47,17 @@ foo42 = test.workpath('build', 'var4', 'foo2' + _exe)
foo51 = test.workpath('build', 'var5', 'foo1' + _exe)
foo52 = test.workpath('build', 'var5', 'foo2' + _exe)
+bar11 = test.workpath('build', 'var1', 'bar1' + _exe)
+bar12 = test.workpath('build', 'var1', 'bar2' + _exe)
+bar21 = test.workpath('build', 'var2', 'bar1' + _exe)
+bar22 = test.workpath('build', 'var2', 'bar2' + _exe)
+bar31 = test.workpath('build', 'var3', 'bar1' + _exe)
+bar32 = test.workpath('build', 'var3', 'bar2' + _exe)
+bar41 = test.workpath('build', 'var4', 'bar1' + _exe)
+bar42 = test.workpath('build', 'var4', 'bar2' + _exe)
+bar51 = test.workpath('build', 'var5', 'bar1' + _exe)
+bar52 = test.workpath('build', 'var5', 'bar2' + _exe)
+
test.write('SConstruct', """
src = Dir('src')
var2 = Dir('build/var2')
@@ -61,20 +72,20 @@ BuildDir(var3, src, duplicate=0)
BuildDir(var4, src, duplicate=0)
BuildDir(var5, src, duplicate=0)
-env = Environment(CPPPATH='#src')
+env = Environment(CPPPATH='#src', F77PATH='#src')
SConscript('build/var1/SConscript', "env")
SConscript('build/var2/SConscript', "env")
-env = Environment(CPPPATH=src)
+env = Environment(CPPPATH=src, F77PATH=src)
SConscript('build/var3/SConscript', "env")
SConscript(File('SConscript', var4), "env")
-env = Environment(CPPPATH='.')
+env = Environment(CPPPATH='.', F77PATH='.')
SConscript('build/var5/SConscript', "env")
""")
test.subdir('src')
-test.write('src/SConscript', """
+test.write(['src', 'SConscript'], """
import os
import os.path
@@ -91,6 +102,10 @@ Import("env")
env.Command(target='f2.c', source='f2.in', action=buildIt)
env.Program(target='foo2', source='f2.c')
env.Program(target='foo1', source='f1.c')
+
+env.Command(target='b2.f', source='b2.in', action=buildIt)
+env.Copy(LIBS = 'g2c').Program(target='bar2', source='b2.f')
+env.Copy(LIBS = 'g2c').Program(target='bar1', source='b1.f')
""")
test.write('src/f1.c', r"""
@@ -125,6 +140,28 @@ test.write('src/f2.h', r"""
#define F2_STR "f2.c\n"
""")
+test.write(['src', 'b1.f'], r"""
+ PROGRAM FOO
+ INCLUDE 'b1.for'
+ STOP
+ END
+""")
+
+test.write(['src', 'b2.in'], r"""
+ PROGRAM FOO
+ INCLUDE 'b2.for'
+ STOP
+ END
+""")
+
+test.write(['src', 'b1.for'], r"""
+ PRINT *, 'b1.for'
+""")
+
+test.write(['src', 'b2.for'], r"""
+ PRINT *, 'b2.for'
+""")
+
test.run(arguments = '.')
test.run(program = foo11, stdout = "f1.c\n")
@@ -138,17 +175,34 @@ test.run(program = foo42, stdout = "f2.c\n")
test.run(program = foo51, stdout = "f1.c\n")
test.run(program = foo52, stdout = "f2.c\n")
+test.run(program = bar11, stdout = " b1.for\n")
+test.run(program = bar12, stdout = " b2.for\n")
+test.run(program = bar21, stdout = " b1.for\n")
+test.run(program = bar22, stdout = " b2.for\n")
+test.run(program = bar31, stdout = " b1.for\n")
+test.run(program = bar32, stdout = " b2.for\n")
+test.run(program = bar41, stdout = " b1.for\n")
+test.run(program = bar42, stdout = " b2.for\n")
+test.run(program = bar51, stdout = " b1.for\n")
+test.run(program = bar52, stdout = " b2.for\n")
+
# Make sure we didn't duplicate the source files in build/var3.
test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f1.c')))
test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f2.in')))
+test.fail_test(os.path.exists(test.workpath('build', 'var3', 'b1.f')))
+test.fail_test(os.path.exists(test.workpath('build', 'var3', 'b2.in')))
# Make sure we didn't duplicate the source files in build/var4.
test.fail_test(os.path.exists(test.workpath('build', 'var4', 'f1.c')))
test.fail_test(os.path.exists(test.workpath('build', 'var4', 'f2.in')))
+test.fail_test(os.path.exists(test.workpath('build', 'var4', 'b1.f')))
+test.fail_test(os.path.exists(test.workpath('build', 'var4', 'b2.in')))
# Make sure we didn't duplicate the source files in build/var5.
test.fail_test(os.path.exists(test.workpath('build', 'var5', 'f1.c')))
test.fail_test(os.path.exists(test.workpath('build', 'var5', 'f2.in')))
+test.fail_test(os.path.exists(test.workpath('build', 'var5', 'b1.f')))
+test.fail_test(os.path.exists(test.workpath('build', 'var5', 'b2.in')))
test.pass_test()
diff --git a/test/F77PATH.py b/test/F77PATH.py
new file mode 100644
index 0000000..e8b540f
--- /dev/null
+++ b/test/F77PATH.py
@@ -0,0 +1,200 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# 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
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+else:
+ _exe = ''
+
+prog = 'prog' + _exe
+subdir_prog = os.path.join('subdir', 'prog' + _exe)
+variant_prog = os.path.join('variant', 'prog' + _exe)
+
+args = prog + ' ' + subdir_prog + ' ' + variant_prog
+
+test = TestSCons.TestSCons()
+
+test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
+
+test.write('SConstruct', """
+env = Environment(F77PATH = ['include'], LIBS = 'g2c')
+obj = env.Object(target='foobar/prog', source='subdir/prog.f')
+env.Program(target='prog', source=obj)
+SConscript('subdir/SConscript', "env")
+
+BuildDir('variant', 'subdir', 0)
+include = Dir('include')
+env = Environment(F77PATH=[include], LIBS = 'g2c')
+SConscript('variant/SConscript', "env")
+""")
+
+test.write(['subdir', 'SConscript'],
+"""
+Import("env")
+env.Program(target='prog', source='prog.f')
+""")
+
+test.write(['include', 'foo.f'],
+r"""
+ PRINT *, 'include/foo.f 1'
+ INCLUDE 'bar.f'
+""")
+
+test.write(['include', 'bar.f'],
+r"""
+ PRINT *, 'include/bar.f 1'
+""")
+
+test.write(['subdir', 'prog.f'],
+r"""
+ PROGRAM PROG
+ PRINT *, 'subdir/prog.f'
+ INCLUDE 'foo.f'
+ STOP
+ END
+""")
+
+test.write(['subdir', 'include', 'foo.f'],
+r"""
+ PRINT *, 'subdir/include/foo.f 1'
+ INCLUDE 'bar.f'
+""")
+
+test.write(['subdir', 'include', 'bar.f'],
+r"""
+ PRINT *, 'subdir/include/bar.f 1'
+""")
+
+
+
+test.run(arguments = args)
+
+test.run(program = test.workpath(prog),
+ stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n")
+
+test.run(program = test.workpath(subdir_prog),
+ stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+
+test.run(program = test.workpath(variant_prog),
+ stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n")
+
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.f')))
+
+test.up_to_date(arguments = args)
+
+test.write(['include', 'foo.f'],
+r"""
+ PRINT *, 'include/foo.f 2'
+ INCLUDE 'bar.f'
+""")
+
+test.run(arguments = args)
+
+test.run(program = test.workpath(prog),
+ stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n")
+
+test.run(program = test.workpath(subdir_prog),
+ stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+
+test.run(program = test.workpath(variant_prog),
+ stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n")
+
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.f')))
+
+test.up_to_date(arguments = args)
+
+#
+test.write(['include', 'bar.f'],
+r"""
+ PRINT *, 'include/bar.f 2'
+""")
+
+test.run(arguments = args)
+
+test.run(program = test.workpath(prog),
+ stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+
+test.run(program = test.workpath(subdir_prog),
+ stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+
+test.run(program = test.workpath(variant_prog),
+ stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.f')))
+
+test.up_to_date(arguments = args)
+
+# Change F77PATH and make sure we don't rebuild because of it.
+test.write('SConstruct', """
+env = Environment(F77PATH = Split('inc2 include'), LIBS = 'g2c')
+obj = env.Object(target='foobar/prog', source='subdir/prog.f')
+env.Program(target='prog', source=obj)
+SConscript('subdir/SConscript', "env")
+
+BuildDir('variant', 'subdir', 0)
+include = Dir('include')
+env = Environment(F77PATH=['inc2', include], LIBS = 'g2c')
+SConscript('variant/SConscript', "env")
+""")
+
+test.up_to_date(arguments = args)
+
+#
+test.write(['inc2', 'foo.f'],
+r"""
+ PRINT *, 'inc2/foo.f 1'
+ INCLUDE 'bar.f'
+""")
+
+test.run(arguments = args)
+
+test.run(program = test.workpath(prog),
+ stdout = " subdir/prog.f\n inc2/foo.f 1\n include/bar.f 2\n")
+
+test.run(program = test.workpath(subdir_prog),
+ stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+
+test.run(program = test.workpath(variant_prog),
+ stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+
+test.up_to_date(arguments = args)
+
+# Check that a null-string F77PATH doesn't blow up.
+test.write('SConstruct', """
+env = Environment(F77PATH = '', LIBS = 'g2c')
+env.Library('foo', source = '')
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()