summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-10-16 04:13:14 (GMT)
committerSteven Knight <knight@baldmt.com>2002-10-16 04:13:14 (GMT)
commitbd91e792df09aebec78f7972e17eab873dc71246 (patch)
tree5b544223c15435fac1669b7d0f2c978483cf61fa /test
parent3f747760055842fd7ea89770cc568761d5729117 (diff)
downloadSCons-bd91e792df09aebec78f7972e17eab873dc71246.zip
SCons-bd91e792df09aebec78f7972e17eab873dc71246.tar.gz
SCons-bd91e792df09aebec78f7972e17eab873dc71246.tar.bz2
Refactor Repository and BuildDir. (Charles Crain)
Diffstat (limited to 'test')
-rw-r--r--test/BuildDir.py88
-rw-r--r--test/CPPPATH.py4
-rw-r--r--test/Repository/BuildDir.py42
-rw-r--r--test/Repository/LIBPATH.py121
-rw-r--r--test/Repository/variants.py186
-rw-r--r--test/option--U.py2
-rw-r--r--test/option--implicit-cache.py2
7 files changed, 391 insertions, 54 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py
index b8e073b..349ed51 100644
--- a/test/BuildDir.py
+++ b/test/BuildDir.py
@@ -76,13 +76,15 @@ var2 = Dir('build/var2')
var3 = Dir('build/var3')
var4 = Dir('build/var4')
var5 = Dir('../build/var5')
+var6 = Dir('../build/var6')
BuildDir('build/var1', src)
-BuildDir(var2, src)
-BuildDir(var3, src, duplicate=0)
+BuildDir(var2, src, duplicate=0)
+BuildDir(var3, src)
BuildDir(var4, src, duplicate=0)
-BuildDir(var5, src, duplicate=0)
+BuildDir(var5, src)
+BuildDir(var6, src, duplicate=0)
env = Environment(CPPPATH='#src', F77PATH='#src')
SConscript('build/var1/SConscript', "env")
@@ -94,6 +96,7 @@ SConscript(File('SConscript', var4), "env")
env = Environment(CPPPATH='.', F77PATH='.')
SConscript('../build/var5/SConscript', "env")
+SConscript('../build/var6/SConscript', "env")
""")
test.subdir(['test', 'src'])
@@ -114,6 +117,13 @@ 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='f3.h', source='f3h.in', action=buildIt)
+env.Command(target='f4.h', source='f4h.in', action=buildIt)
+env.Command(target='f4.c', source='f4.in', action=buildIt)
+
+env2=env.Copy(CPPPATH='.')
+env2.Program(target='foo3', source='f3.c')
+env2.Program(target='foo4', source='f4.c')
try:
f77 = env['F77']
@@ -122,8 +132,8 @@ except:
if f77 and WhereIs(env['F77']):
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')
+ env.Copy(LIBS = ['g2c']).Program(target='bar2', source='b2.f')
+ env.Copy(LIBS = ['g2c']).Program(target='bar1', source='b1.f')
""")
test.write('test/src/f1.c', r"""
@@ -150,6 +160,30 @@ main(int argc, char *argv[])
}
""")
+test.write('test/src/f3.c', r"""
+#include "f3.h"
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf(F3_STR);
+ exit (0);
+}
+""")
+
+test.write('test/src/f4.in', r"""
+#include "f4.h"
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf(F4_STR);
+ exit (0);
+}
+""")
+
test.write('test/src/f1.h', r"""
#define F1_STR "f1.c\n"
""")
@@ -158,6 +192,14 @@ test.write('test/src/f2.h', r"""
#define F2_STR "f2.c\n"
""")
+test.write('test/src/f3h.in', r"""
+#define F3_STR "f3.c\n"
+""")
+
+test.write('test/src/f4h.in', r"""
+#define F4_STR "f4.c\n"
+""")
+
test.write(['test', 'src', 'b1.f'], r"""
PROGRAM FOO
INCLUDE 'b1.for'
@@ -214,37 +256,25 @@ def equal_stats(x,y):
return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and
x[stat.ST_MTIME] == y[stat.ST_MTIME])
-# 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')))
-
-# 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')))
-
-# 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')))
-
-# 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')))
-
# verify that header files in the source directory are scanned properly:
test.write(['test', 'src', 'f1.h'], r"""
#define F1_STR "f1.c 2\n"
""")
+test.write(['test', 'src', 'f3h.in'], r"""
+#define F3_STR "f3.c 2\n"
+""")
+
+test.write(['test', 'src', 'f4h.in'], r"""
+#define F4_STR "f4.c 2\n"
+""")
+
test.run(chdir='test', arguments = '../build/var5')
test.run(program = foo51, stdout = "f1.c 2\n")
+test.run(program = test.workpath('build', 'var5', 'foo3' + _exe),
+ stdout = "f3.c 2\n")
+test.run(program = test.workpath('build', 'var5', 'foo4' + _exe),
+ stdout = "f4.c 2\n")
test.pass_test()
diff --git a/test/CPPPATH.py b/test/CPPPATH.py
index a2cae10..45216c8 100644
--- a/test/CPPPATH.py
+++ b/test/CPPPATH.py
@@ -49,7 +49,7 @@ obj = env.Object(target='foobar/prog', source='subdir/prog.c')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
-BuildDir('variant', 'subdir', 0)
+BuildDir('variant', 'subdir', duplicate=0)
include = Dir('include')
env = Environment(CPPPATH=[include])
SConscript('variant/SConscript', "env")
@@ -168,7 +168,7 @@ obj = env.Object(target='foobar/prog', source='subdir/prog.c')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
-BuildDir('variant', 'subdir', 0)
+BuildDir('variant', 'subdir')
include = Dir('include')
env = Environment(CPPPATH=['inc2', include])
SConscript('variant/SConscript', "env")
diff --git a/test/Repository/BuildDir.py b/test/Repository/BuildDir.py
index 2d75590..905c618 100644
--- a/test/Repository/BuildDir.py
+++ b/test/Repository/BuildDir.py
@@ -38,8 +38,8 @@ opts = "-Y " + test.workpath('repository')
#
test.write(['repository', 'SConstruct'], r"""
-BuildDir('build0', 'src', duplicate=0)
-BuildDir('build1', 'src', duplicate=1)
+BuildDir('build0', 'src')
+BuildDir('build1', 'src', duplicate=0)
SConscript('build0/SConscript')
SConscript('build1/SConscript')
""")
@@ -78,9 +78,9 @@ repository/src/bbb.in
repository/src/ccc.in
""")
-test.fail_test(os.path.exists('work1/build0/aaa.in'))
-test.fail_test(os.path.exists('work1/build0/bbb.in'))
-test.fail_test(os.path.exists('work1/build0/ccc.in'))
+test.fail_test(not os.path.exists('work1/build0/aaa.in'))
+test.fail_test(not os.path.exists('work1/build0/bbb.in'))
+test.fail_test(not os.path.exists('work1/build0/ccc.in'))
test.fail_test(not os.path.exists('work1/build0/aaa.mid'))
test.fail_test(not os.path.exists('work1/build0/bbb.mid'))
test.fail_test(not os.path.exists('work1/build0/ccc.mid'))
@@ -91,9 +91,9 @@ repository/src/bbb.in
repository/src/ccc.in
""")
-test.fail_test(not os.path.exists('work1/build1/aaa.in'))
-test.fail_test(not os.path.exists('work1/build1/bbb.in'))
-test.fail_test(not os.path.exists('work1/build1/ccc.in'))
+test.fail_test(os.path.exists('work1/build1/aaa.in'))
+test.fail_test(os.path.exists('work1/build1/bbb.in'))
+test.fail_test(os.path.exists('work1/build1/ccc.in'))
test.fail_test(not os.path.exists('work1/build1/aaa.mid'))
test.fail_test(not os.path.exists('work1/build1/bbb.mid'))
test.fail_test(not os.path.exists('work1/build1/ccc.mid'))
@@ -111,9 +111,9 @@ work1/src/bbb.in
repository/src/ccc.in
""")
-test.fail_test(os.path.exists('work1/build0/aaa.in'))
-test.fail_test(os.path.exists('work1/build0/bbb.in'))
-test.fail_test(os.path.exists('work1/build0/ccc.in'))
+test.fail_test(not os.path.exists('work1/build0/aaa.in'))
+test.fail_test(not os.path.exists('work1/build0/bbb.in'))
+test.fail_test(not os.path.exists('work1/build0/ccc.in'))
test.fail_test(not os.path.exists('work1/build0/aaa.mid'))
test.fail_test(not os.path.exists('work1/build0/bbb.mid'))
test.fail_test(not os.path.exists('work1/build0/ccc.mid'))
@@ -124,9 +124,9 @@ work1/src/bbb.in
repository/src/ccc.in
""")
-test.fail_test(not os.path.exists('work1/build1/aaa.in'))
-test.fail_test(not os.path.exists('work1/build1/bbb.in'))
-test.fail_test(not os.path.exists('work1/build1/ccc.in'))
+test.fail_test(os.path.exists('work1/build1/aaa.in'))
+test.fail_test(os.path.exists('work1/build1/bbb.in'))
+test.fail_test(os.path.exists('work1/build1/ccc.in'))
test.fail_test(not os.path.exists('work1/build1/aaa.mid'))
test.fail_test(not os.path.exists('work1/build1/bbb.mid'))
test.fail_test(not os.path.exists('work1/build1/ccc.mid'))
@@ -144,9 +144,9 @@ test.writable('repository', 0)
#
test.run(chdir = 'work2', options = opts, arguments = '.')
-test.fail_test(os.path.exists('work2/build0/aaa.in'))
-test.fail_test(os.path.exists('work2/build0/bbb.in'))
-test.fail_test(os.path.exists('work2/build0/ccc.in'))
+test.fail_test(not os.path.exists('work2/build0/aaa.in'))
+test.fail_test(not os.path.exists('work2/build0/bbb.in'))
+test.fail_test(not os.path.exists('work2/build0/ccc.in'))
test.fail_test(os.path.exists('work2/build0/aaa.mid'))
test.fail_test(os.path.exists('work2/build0/bbb.mid'))
test.fail_test(os.path.exists('work2/build0/ccc.mid'))
@@ -173,9 +173,9 @@ work2/src/bbb.in
repository/src/ccc.in
""")
-test.fail_test(os.path.exists('work2/build0/aaa.in'))
-test.fail_test(os.path.exists('work2/build0/bbb.in'))
-test.fail_test(os.path.exists('work2/build0/ccc.in'))
+test.fail_test(not os.path.exists('work2/build0/aaa.in'))
+test.fail_test(not os.path.exists('work2/build0/bbb.in'))
+test.fail_test(not os.path.exists('work2/build0/ccc.in'))
test.fail_test(os.path.exists('work2/build0/aaa.mid'))
test.fail_test(not os.path.exists('work2/build0/bbb.mid'))
test.fail_test(os.path.exists('work2/build0/ccc.mid'))
@@ -187,7 +187,7 @@ repository/src/ccc.in
""")
test.fail_test(os.path.exists('work2/build1/aaa.in'))
-test.fail_test(not os.path.exists('work2/build1/bbb.in'))
+test.fail_test(os.path.exists('work2/build1/bbb.in'))
test.fail_test(os.path.exists('work2/build1/ccc.in'))
test.fail_test(os.path.exists('work2/build1/aaa.mid'))
test.fail_test(not os.path.exists('work2/build1/bbb.mid'))
diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py
new file mode 100644
index 0000000..a385410
--- /dev/null
+++ b/test/Repository/LIBPATH.py
@@ -0,0 +1,121 @@
+#!/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 string
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('foo', ['foo', 'zzz'], 'bar', ['bar', 'yyy'], 'work')
+
+workpath_foo = test.workpath('foo')
+workpath_foo_yyy = test.workpath('foo', 'yyy')
+workpath_foo_zzz = test.workpath('foo', 'zzz')
+workpath_bar = test.workpath('bar')
+workpath_bar_yyy = test.workpath('bar', 'yyy')
+workpath_bar_zzz = test.workpath('bar', 'zzz')
+workpath_work = test.workpath('work')
+
+test.write(['work', 'SConstruct'], r"""
+import string
+env_zzz = Environment(LIBPATH = ['.', 'zzz'])
+env_yyy = Environment(LIBPATH = ['yyy', '.'])
+aaa_exe = env_zzz.Program('aaa', 'aaa.c')
+bbb_exe = env_yyy.Program('bbb', 'bbb.c')
+def write_LIBDIRFLAGS(env, target, source):
+ pre = env.subst('$LIBDIRPREFIX')
+ suf = env.subst('$LIBDIRSUFFIX')
+ f = open(str(target[0]), 'wb')
+ for arg in string.split(env.subst('$_LIBDIRFLAGS')):
+ if arg[:len(pre)] == pre:
+ arg = arg[len(pre):]
+ if arg[-len(suf):] == suf:
+ arg = arg[:-len(pre)]
+ f.write(arg + '\n')
+ f.close()
+ return 0
+env_zzz.Command('zzz.out', aaa_exe, write_LIBDIRFLAGS)
+env_yyy.Command('yyy.out', bbb_exe, write_LIBDIRFLAGS)
+""")
+
+test.write(['work', 'aaa.c'], r"""
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("work/aaa.c\n");
+ exit (0);
+}
+""")
+
+test.write(['work', 'bbb.c'], r"""
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("work/bbb.c\n");
+ exit (0);
+}
+""")
+
+#
+opts = "-Y %s -Y %s -Y %s" % (workpath_foo, workpath_work, workpath_bar)
+test.run(chdir = 'work', options = opts, arguments = ".")
+
+#dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz]
+dirs = ['.', workpath_foo, workpath_bar,
+ 'zzz', workpath_foo_zzz, workpath_bar_zzz]
+test.fail_test(test.read(['work', 'zzz.out']) !=
+ string.join(dirs, '\n') + '\n')
+
+#dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar]
+dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy,
+ '.', workpath_foo, workpath_bar]
+test.fail_test(test.read(['work', 'yyy.out']) !=
+ string.join(dirs, '\n') + '\n')
+
+#
+test.run(chdir = 'work', options = '-c', arguments = ".")
+
+test.subdir(['work', 'zzz'], ['work', 'yyy'])
+
+#
+test.run(chdir = 'work', options = opts, arguments = ".")
+
+#dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz]
+dirs = ['.', workpath_foo, workpath_bar,
+ 'zzz', workpath_foo_zzz, workpath_bar_zzz]
+test.fail_test(test.read(['work', 'zzz.out']) !=
+ string.join(dirs, '\n') + '\n')
+
+#dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar]
+dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy,
+ '.', workpath_foo, workpath_bar]
+test.fail_test(test.read(['work', 'yyy.out']) !=
+ string.join(dirs, '\n') + '\n')
+
+#
+test.pass_test()
diff --git a/test/Repository/variants.py b/test/Repository/variants.py
new file mode 100644
index 0000000..d91235f
--- /dev/null
+++ b/test/Repository/variants.py
@@ -0,0 +1,186 @@
+#!/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.path
+import time
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('repository', ['repository', 'src'],
+ 'work1', ['work1', 'src'],
+ 'work2', ['work2', 'src'])
+
+repository_build_foo_xxx = test.workpath('repository', 'build', 'foo', 'xxx')
+work1_build_foo_xxx = test.workpath('work1', 'build', 'foo', 'xxx')
+work1_build_bar_xxx = test.workpath('work1', 'build', 'bar', 'xxx')
+
+opts = "-Y " + test.workpath('repository')
+
+#
+test.write(['repository', 'SConstruct'], r"""
+OS = ARGUMENTS['OS']
+build_os = "#build/" + OS
+ccflags = {
+ 'foo' : '-DFOO',
+ 'bar' : '-DBAR',
+}
+env = Environment(CCFLAGS = ccflags[OS],
+ CPPPATH = build_os)
+BuildDir(build_os, 'src')
+SConscript(build_os + '/SConscript', "env")
+""")
+
+test.write(['repository', 'src', 'SConscript'], r"""
+Import("env")
+env.Program('xxx', ['aaa.c', 'bbb.c', 'main.c'])
+""")
+
+test.write(['repository', 'src', 'iii.h'], r"""
+#ifdef FOO
+#define STRING "REPOSITORY_FOO"
+#endif
+#ifdef BAR
+#define STRING "REPOSITORY_BAR"
+#endif
+""")
+
+test.write(['repository', 'src', 'aaa.c'], r"""
+#include <iii.h>
+void
+aaa(void)
+{
+ printf("repository/src/aaa.c: %s\n", STRING);
+}
+""")
+
+test.write(['repository', 'src', 'bbb.c'], r"""
+#include <iii.h>
+void
+bbb(void)
+{
+ printf("repository/src/bbb.c: %s\n", STRING);
+}
+""")
+
+test.write(['repository', 'src', 'main.c'], r"""
+#include <iii.h>
+extern void aaa(void);
+extern void bbb(void);
+int
+main(int argc, char *argv[])
+{
+#ifdef BAR
+ printf("Only when -DBAR.\n");
+#endif
+ aaa();
+ bbb();
+ printf("repository/src/main.c: %s\n", STRING);
+ exit (0);
+}
+""")
+
+#
+test.run(chdir = 'repository', options = opts + " OS=foo", arguments = '.')
+
+test.run(program = repository_build_foo_xxx, stdout =
+"""repository/src/aaa.c: REPOSITORY_FOO
+repository/src/bbb.c: REPOSITORY_FOO
+repository/src/main.c: REPOSITORY_FOO
+""")
+
+test.fail_test(os.path.exists(test.workpath('repository', 'src', '.sconsign')))
+test.fail_test(os.path.exists(test.workpath('src', '.sconsign')))
+
+# Make the entire repository non-writable, so we'll detect
+# if we try to write into it accidentally.
+test.writable('repository', 0)
+
+#
+test.up_to_date(chdir = 'work1', options = opts + " OS=foo", arguments = '.')
+
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'foo', 'aaa.o')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'foo', 'bbb.o')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'foo', 'main.o')))
+test.fail_test(os.path.exists(test.workpath('work1', 'build', 'foo', 'xxx')))
+
+#
+test.run(chdir = 'work1', options = opts, arguments = 'OS=bar .')
+
+test.run(program = work1_build_bar_xxx, stdout =
+"""Only when -DBAR.
+repository/src/aaa.c: REPOSITORY_BAR
+repository/src/bbb.c: REPOSITORY_BAR
+repository/src/main.c: REPOSITORY_BAR
+""")
+
+test.fail_test(os.path.exists(test.workpath('repository', 'src', '.sconsign')))
+test.fail_test(os.path.exists(test.workpath('src', '.sconsign')))
+
+test.up_to_date(chdir = 'work1', options = opts + " OS=bar", arguments = '.')
+
+#
+time.sleep(2)
+test.write(['work1', 'src', 'iii.h'], r"""
+#ifdef FOO
+#define STRING "WORK_FOO"
+#endif
+#ifdef BAR
+#define STRING "WORK_BAR"
+#endif
+""")
+
+#
+test.run(chdir = 'work1', options = opts + " OS=bar", arguments = '.')
+
+test.run(program = work1_build_bar_xxx, stdout =
+"""Only when -DBAR.
+repository/src/aaa.c: WORK_BAR
+repository/src/bbb.c: WORK_BAR
+repository/src/main.c: WORK_BAR
+""")
+
+test.fail_test(os.path.exists(test.workpath('repository', 'src', '.sconsign')))
+test.fail_test(os.path.exists(test.workpath('src', '.sconsign')))
+
+test.up_to_date(chdir = 'work1', options = opts + " OS=bar", arguments = '.')
+
+#
+test.run(chdir = 'work1', options = opts + " OS=foo", arguments = '.')
+
+test.run(program = work1_build_foo_xxx, stdout =
+"""repository/src/aaa.c: WORK_FOO
+repository/src/bbb.c: WORK_FOO
+repository/src/main.c: WORK_FOO
+""")
+
+test.fail_test(os.path.exists(test.workpath('repository', 'src', '.sconsign')))
+test.fail_test(os.path.exists(test.workpath('src', '.sconsign')))
+
+test.up_to_date(chdir = 'work1', options = opts + " OS=foo", arguments = '.')
+
+#
+test.pass_test()
diff --git a/test/option--U.py b/test/option--U.py
index 23e82b1..0160015 100644
--- a/test/option--U.py
+++ b/test/option--U.py
@@ -52,7 +52,7 @@ Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in'))
Export('env')
SConscript('sub2/SConscript')
Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in'))
-BuildDir('sub2b', 'sub2')
+BuildDir('sub2b', 'sub2', duplicate=0)
SConscript('sub2b/SConscript')
Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in'))
SConscript('SConscript')
diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py
index 4e5cf1e..186b637 100644
--- a/test/option--implicit-cache.py
+++ b/test/option--implicit-cache.py
@@ -52,7 +52,7 @@ obj = env.Object(target='prog', source='subdir/prog.c')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
-BuildDir('variant', 'subdir', 0)
+BuildDir('variant', 'subdir')
include = Dir('include')
env = Environment(CPPPATH=['inc2', include])
SConscript('variant/SConscript', "env")