summaryrefslogtreecommitdiffstats
path: root/test/BuildDir.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/BuildDir.py')
-rw-r--r--test/BuildDir.py143
1 files changed, 94 insertions, 49 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py
index c10ef3e..25bbd25 100644
--- a/test/BuildDir.py
+++ b/test/BuildDir.py
@@ -39,31 +39,31 @@ test = TestSCons.TestSCons()
f77 = test.detect('F77')
-foo11 = test.workpath('test', 'build', 'var1', 'foo1' + _exe)
-foo12 = test.workpath('test', 'build', 'var1', 'foo2' + _exe)
-foo21 = test.workpath('test', 'build', 'var2', 'foo1' + _exe)
-foo22 = test.workpath('test', 'build', 'var2', 'foo2' + _exe)
-foo31 = test.workpath('test', 'build', 'var3', 'foo1' + _exe)
-foo32 = test.workpath('test', 'build', 'var3', 'foo2' + _exe)
-foo41 = test.workpath('test', 'build', 'var4', 'foo1' + _exe)
-foo42 = test.workpath('test', 'build', 'var4', 'foo2' + _exe)
+foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe)
+foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe)
+foo21 = test.workpath('work1', 'build', 'var2', 'foo1' + _exe)
+foo22 = test.workpath('work1', 'build', 'var2', 'foo2' + _exe)
+foo31 = test.workpath('work1', 'build', 'var3', 'foo1' + _exe)
+foo32 = test.workpath('work1', 'build', 'var3', 'foo2' + _exe)
+foo41 = test.workpath('work1', 'build', 'var4', 'foo1' + _exe)
+foo42 = test.workpath('work1', 'build', 'var4', 'foo2' + _exe)
foo51 = test.workpath('build', 'var5', 'foo1' + _exe)
foo52 = test.workpath('build', 'var5', 'foo2' + _exe)
-bar11 = test.workpath('test', 'build', 'var1', 'bar1' + _exe)
-bar12 = test.workpath('test', 'build', 'var1', 'bar2' + _exe)
-bar21 = test.workpath('test', 'build', 'var2', 'bar1' + _exe)
-bar22 = test.workpath('test', 'build', 'var2', 'bar2' + _exe)
-bar31 = test.workpath('test', 'build', 'var3', 'bar1' + _exe)
-bar32 = test.workpath('test', 'build', 'var3', 'bar2' + _exe)
-bar41 = test.workpath('test', 'build', 'var4', 'bar1' + _exe)
-bar42 = test.workpath('test', 'build', 'var4', 'bar2' + _exe)
+bar11 = test.workpath('work1', 'build', 'var1', 'bar1' + _exe)
+bar12 = test.workpath('work1', 'build', 'var1', 'bar2' + _exe)
+bar21 = test.workpath('work1', 'build', 'var2', 'bar1' + _exe)
+bar22 = test.workpath('work1', 'build', 'var2', 'bar2' + _exe)
+bar31 = test.workpath('work1', 'build', 'var3', 'bar1' + _exe)
+bar32 = test.workpath('work1', 'build', 'var3', 'bar2' + _exe)
+bar41 = test.workpath('work1', 'build', 'var4', 'bar1' + _exe)
+bar42 = test.workpath('work1', 'build', 'var4', 'bar2' + _exe)
bar51 = test.workpath('build', 'var5', 'bar1' + _exe)
bar52 = test.workpath('build', 'var5', 'bar2' + _exe)
-test.subdir('test')
+test.subdir('work1', 'work2')
-test.write('test/SConstruct', """
+test.write(['work1', 'SConstruct'], """
src = Dir('src')
var2 = Dir('build/var2')
var3 = Dir('build/var3')
@@ -100,8 +100,8 @@ if string.find(sys.platform, 'irix') != -1:
else:
fortran_runtime = 'g2c'
-test.subdir(['test', 'src'])
-test.write(['test', 'src', 'SConscript'], """
+test.subdir(['work1', 'src'])
+test.write(['work1', 'src', 'SConscript'], """
import os
import os.path
@@ -137,7 +137,7 @@ if f77 and env.Detect(env['F77']):
env.Copy(LIBS = [r'%s']).Program(target='bar1', source='b1.f')
""" % (fortran_runtime, fortran_runtime))
-test.write('test/src/f1.c', r"""
+test.write(['work1', 'src', 'f1.c'], r"""
#include "f1.h"
int
@@ -149,7 +149,7 @@ main(int argc, char *argv[])
}
""")
-test.write('test/src/f2.in', r"""
+test.write(['work1', 'src', 'f2.in'], r"""
#include "f2.h"
int
@@ -161,7 +161,7 @@ main(int argc, char *argv[])
}
""")
-test.write('test/src/f3.c', r"""
+test.write(['work1', 'src', 'f3.c'], r"""
#include "f3.h"
int
@@ -173,7 +173,7 @@ main(int argc, char *argv[])
}
""")
-test.write('test/src/f4.in', r"""
+test.write(['work1', 'src', 'f4.in'], r"""
#include "f4.h"
int
@@ -185,45 +185,45 @@ main(int argc, char *argv[])
}
""")
-test.write('test/src/f1.h', r"""
+test.write(['work1', 'src', 'f1.h'], r"""
#define F1_STR "f1.c\n"
""")
-test.write('test/src/f2.h', r"""
+test.write(['work1', 'src', 'f2.h'], r"""
#define F2_STR "f2.c\n"
""")
-test.write('test/src/f3h.in', r"""
+test.write(['work1', 'src', 'f3h.in'], r"""
#define F3_STR "f3.c\n"
""")
-test.write('test/src/f4h.in', r"""
+test.write(['work1', 'src', 'f4h.in'], r"""
#define F4_STR "f4.c\n"
""")
-test.write(['test', 'src', 'b1.f'], r"""
+test.write(['work1', 'src', 'b1.f'], r"""
PROGRAM FOO
INCLUDE 'b1.for'
STOP
END
""")
-test.write(['test', 'src', 'b2.in'], r"""
+test.write(['work1', 'src', 'b2.in'], r"""
PROGRAM FOO
INCLUDE 'b2.for'
STOP
END
""")
-test.write(['test', 'src', 'b1.for'], r"""
+test.write(['work1', 'src', 'b1.for'], r"""
PRINT *, 'b1.for'
""")
-test.write(['test', 'src', 'b2.for'], r"""
+test.write(['work1', 'src', 'b2.for'], r"""
PRINT *, 'b2.for'
""")
-test.run(chdir='test', arguments = '. ../build')
+test.run(chdir='work1', arguments = '. ../build')
test.run(program = foo11, stdout = "f1.c\n")
test.run(program = foo12, stdout = "f2.c\n")
@@ -248,6 +248,10 @@ if f77:
test.run(program = bar51, stdout = " b1.for\n")
test.run(program = bar52, stdout = " b2.for\n")
+test.run(chdir='work1', arguments='. ../build', stdout=test.wrap_stdout("""\
+scons: "." is up to date.
+scons: "%s" is up to date.
+""" % test.workpath('build')))
import os
import stat
@@ -259,22 +263,22 @@ def equal_stats(x,y):
# Make sure we did duplicate the source files in build/var2,
# and that their stats are the same:
-test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var2', 'f1.c')))
-test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var2', 'f2.in')))
-test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', 'f1.c'), test.workpath('test', 'src', 'f1.c')))
-test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', 'f2.in'), test.workpath('test', 'src', 'f2.in')))
+test.fail_test(not os.path.exists(test.workpath('work1', 'build', 'var2', 'f1.c')))
+test.fail_test(not os.path.exists(test.workpath('work1', 'build', 'var2', 'f2.in')))
+test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f1.c'), test.workpath('work1', 'src', 'f1.c')))
+test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f2.in'), test.workpath('work1', 'src', 'f2.in')))
# Make sure we didn't duplicate the source files in build/var3.
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'f1.c')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'f2.in')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'b1.f')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'b2.in')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var3', 'f1.c')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var3', 'f2.in')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var3', 'b1.f')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var3', 'b2.in')))
# Make sure we didn't duplicate the source files in build/var4.
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'f1.c')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'f2.in')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'b1.f')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'b2.in')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var4', 'f1.c')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var4', 'f2.in')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'var4', 'b1.f')))
+test.fail_test(os.path.exists(test.workpath('work1', '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')))
@@ -283,19 +287,19 @@ test.fail_test(os.path.exists(test.workpath('build', 'var5', 'b1.f')))
test.fail_test(os.path.exists(test.workpath('build', 'var5', 'b2.in')))
# verify that header files in the source directory are scanned properly:
-test.write(['test', 'src', 'f1.h'], r"""
+test.write(['work1', 'src', 'f1.h'], r"""
#define F1_STR "f1.c 2\n"
""")
-test.write(['test', 'src', 'f3h.in'], r"""
+test.write(['work1', 'src', 'f3h.in'], r"""
#define F3_STR "f3.c 2\n"
""")
-test.write(['test', 'src', 'f4h.in'], r"""
+test.write(['work1', 'src', 'f4h.in'], r"""
#define F4_STR "f4.c 2\n"
""")
-test.run(chdir='test', arguments = '../build/var5')
+test.run(chdir='work1', arguments = '../build/var5')
test.run(program = foo51, stdout = "f1.c 2\n")
test.run(program = test.workpath('build', 'var5', 'foo3' + _exe),
@@ -303,4 +307,45 @@ test.run(program = test.workpath('build', 'var5', 'foo3' + _exe),
test.run(program = test.workpath('build', 'var5', 'foo4' + _exe),
stdout = "f4.c 2\n")
+test.run(chdir='work1', arguments='../build/var5', stdout=test.wrap_stdout("""\
+scons: "%s" is up to date.
+""" % test.workpath('build', 'var5')))
+
+#
+test.write(['work2', 'SConstruct'], """\
+env = Environment()
+env.Program('prog.c')
+""")
+
+test.write(['work2', 'prog.c'], r"""
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("work2/prog.c\n");
+ exit (0);
+}
+""")
+
+test.run(chdir='work2', arguments='.')
+
+test.up_to_date(chdir='work2', arguments='.')
+
+#
+test.write(['work2', 'SConstruct'], """\
+env = Environment()
+BuildDir('build', '.')
+Export('env')
+SConscript('build/SConscript')
+""")
+
+test.write(['work2', 'SConscript'], """\
+Import('env')
+env.Program('prog.c')
+""")
+
+test.run(chdir='work2', arguments='.')
+
+test.up_to_date(chdir='work2', arguments='.')
+
test.pass_test()