Fixes for tests following the Repository/BuildDir refactoring. (Charles Crain).
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 19 Oct 2002 06:36:57 +0000 (06:36 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 19 Oct 2002 06:36:57 +0000 (06:36 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@485 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Script/__init__.py
test/BuildDir.py
test/CPPPATH.py
test/Repository/BuildDir.py
test/option--U.py
test/option--implicit-cache.py

index aa6482dfe50dc3945e9990acba6d1d224f8c7109..fac962711606f922df7d4a7315a8b28aa2f85d43 100644 (file)
@@ -688,6 +688,13 @@ class Dir(Entry):
             self._sconsign = SCons.Sig.SConsignFile(self)
         return self._sconsign
 
+    def srcnode(self):
+        """Dir has a special need for srcnode()...if we
+        have a srcdir attribute set, then that *is* our srcnode."""
+        if self.srcdir:
+            return self.srcdir
+        return Entry.srcnode(self)
+
 # XXX TODO?
 # base_suf
 # suffix
index 1610ec699ffbfe391679075938b87fc2101529c0..8f9f5e4406e7a0a4bdf6dc8312b0c501cbe731f6 100644 (file)
@@ -82,15 +82,19 @@ class BuildDirTestCase(unittest.TestCase):
         f1 = fs.File('build/test1')
         fs.BuildDir('build', 'src')
         f2 = fs.File('build/test2')
+        d1 = fs.Dir('build')
         assert f1.srcnode().path == os.path.normpath('src/test1'), f1.srcnode().path
         assert f2.srcnode().path == os.path.normpath('src/test2'), f2.srcnode().path
+        assert d1.srcnode().path == 'src', d1.srcnode().path
 
         fs = SCons.Node.FS.FS()
         f1 = fs.File('build/test1')
         fs.BuildDir('build', '.')
         f2 = fs.File('build/test2')
+        d1 = fs.Dir('build')
         assert f1.srcnode().path == 'test1', f1.srcnode().path
         assert f2.srcnode().path == 'test2', f2.srcnode().path
+        assert d1.srcnode().path == '.', d1.srcnode().path
 
         fs = SCons.Node.FS.FS()
         fs.BuildDir('build/var1', 'src')
index a0bab35d7218eaac3b5e67aff7003793355b1436..fd43b9a24b96803bed02b30917f604e3ca482e2d 100644 (file)
@@ -997,9 +997,8 @@ def _main():
             # -U with default targets
             default_targets = SCons.Script.SConscript.default_targets
             def check_dir(x):
-                reps = SCons.Node.FS.default_fs.Rsearchall(str(x.cwd), must_exist=0,
-                                                           clazz=SCons.Node.FS.Dir)
-                return target_top in reps
+                cwd = x.cwd.srcnode()
+                return cwd == target_top
             default_targets = filter(check_dir, default_targets)
             SCons.Script.SConscript.default_targets = default_targets
             target_top = None
index 349ed51c534af364c2eee85d02d0b44e5b25428f..e4c69438c3ca2450ae17d093127821922c87fed1 100644 (file)
@@ -80,11 +80,11 @@ var6 = Dir('../build/var6')
 
 
 BuildDir('build/var1', src)
-BuildDir(var2, src, duplicate=0)
-BuildDir(var3, src)
+BuildDir(var2, src)
+BuildDir(var3, src, duplicate=0)
 BuildDir(var4, src, duplicate=0)
-BuildDir(var5, src)
-BuildDir(var6, src, duplicate=0)
+BuildDir(var5, src, duplicate=0)
+BuildDir(var6, src)
 
 env = Environment(CPPPATH='#src', F77PATH='#src')
 SConscript('build/var1/SConscript', "env")
@@ -256,6 +256,31 @@ 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"
index 45216c86146edfcf523fd78908d00b470a4da9a4..a2cae10bec747b8766723a6329e8f39ba5e5be58 100644 (file)
@@ -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', duplicate=0)
+BuildDir('variant', 'subdir', 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')
+BuildDir('variant', 'subdir', 0)
 include = Dir('include')
 env = Environment(CPPPATH=['inc2', include])
 SConscript('variant/SConscript', "env")
index 905c61898dc6767222cb5d1bdf03131c70fc20f8..6687937434f5ccb0c6703516a531b0a2f74852a9 100644 (file)
@@ -38,8 +38,8 @@ opts = "-Y " + test.workpath('repository')
 
 #
 test.write(['repository', 'SConstruct'], r"""
-BuildDir('build0', 'src')
-BuildDir('build1', 'src', duplicate=0)
+BuildDir('build0', 'src', duplicate=0)
+BuildDir('build1', 'src', duplicate=1)
 SConscript('build0/SConscript')
 SConscript('build1/SConscript')
 """)
@@ -78,9 +78,9 @@ repository/src/bbb.in
 repository/src/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(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.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(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.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(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(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(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.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(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.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(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,17 +144,17 @@ test.writable('repository', 0)
 #
 test.run(chdir = 'work2', options = opts, arguments = '.')
 
-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.in'))
+test.fail_test(os.path.exists('work2/build0/bbb.in'))
+test.fail_test(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'))
 test.fail_test(os.path.exists('work2/build0/output'))
 
-test.fail_test(os.path.exists('work2/build1/aaa.in'))
-test.fail_test(os.path.exists('work2/build1/bbb.in'))
-test.fail_test(os.path.exists('work2/build1/ccc.in'))
+test.fail_test(not os.path.exists('work2/build1/aaa.in'))
+test.fail_test(not os.path.exists('work2/build1/bbb.in'))
+test.fail_test(not os.path.exists('work2/build1/ccc.in'))
 test.fail_test(os.path.exists('work2/build1/aaa.mid'))
 test.fail_test(os.path.exists('work2/build1/bbb.mid'))
 test.fail_test(os.path.exists('work2/build1/ccc.mid'))
@@ -173,9 +173,9 @@ work2/src/bbb.in
 repository/src/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.in'))
+test.fail_test(os.path.exists('work2/build0/bbb.in'))
+test.fail_test(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'))
@@ -186,9 +186,9 @@ work2/src/bbb.in
 repository/src/ccc.in
 """)
 
-test.fail_test(os.path.exists('work2/build1/aaa.in'))
-test.fail_test(os.path.exists('work2/build1/bbb.in'))
-test.fail_test(os.path.exists('work2/build1/ccc.in'))
+test.fail_test(not os.path.exists('work2/build1/aaa.in'))
+test.fail_test(not os.path.exists('work2/build1/bbb.in'))
+test.fail_test(not 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'))
 test.fail_test(os.path.exists('work2/build1/ccc.mid'))
index 016001577ebad117550a3f510c6cad784e426f73..23e82b18c30c2f78684fd92e94d7ba5401782d8b 100644 (file)
@@ -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', duplicate=0)
+BuildDir('sub2b', 'sub2')
 SConscript('sub2b/SConscript')
 Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in'))
 SConscript('SConscript')
index 186b63757f278b99b8f263e1bc321d70ec197b53..4e5cf1e5a6f067102798036d46175c06ce157ba5 100644 (file)
@@ -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')
+BuildDir('variant', 'subdir', 0)
 include = Dir('include')
 env = Environment(CPPPATH=['inc2', include])
 SConscript('variant/SConscript', "env")