if not self.builder is MkdirBuilder:
apply(SCons.Node.Node.build, [self,], kw)
+ def _create(self):
+ """Create this directory, silently and without worrying about
+ whether the builder is the default or not."""
+ listDirs = []
+ parent = self
+ while parent:
+ if parent.exists():
+ break
+ listDirs.append(parent)
+ p = parent.up()
+ if isinstance(p, ParentOfRoot):
+ raise SCons.Errors.StopError, parent.path
+ parent = p
+ listDirs.reverse()
+ for dirnode in listDirs:
+ try:
+ # Don't call dirnode.build(), call the base Node method
+ # directly because we definitely *must* create this
+ # directory. The dirnode.build() method will suppress
+ # the build if it's the default builder.
+ SCons.Node.Node.build(dirnode)
+ dirnode.get_executor().nullify()
+ # The build() action may or may not have actually
+ # created the directory, depending on whether the -n
+ # option was used or not. Delete the _exists and
+ # _rexists attributes so they can be reevaluated.
+ dirnode.clear()
+ except OSError:
+ pass
+
def multiple_side_effect_has_builder(self):
global MkdirBuilder
return not self.builder is MkdirBuilder and self.has_builder()
def _createDir(self):
# ensure that the directories for this node are
# created.
-
- listDirs = []
- parent=self.dir
- while parent:
- if parent.exists():
- break
- listDirs.append(parent)
- p = parent.up()
- if isinstance(p, ParentOfRoot):
- raise SCons.Errors.StopError, parent.path
- parent = p
- listDirs.reverse()
- for dirnode in listDirs:
- try:
- # Don't call dirnode.build(), call the base Node method
- # directly because we definitely *must* create this
- # directory. The dirnode.build() method will suppress
- # the build if it's the default builder.
- SCons.Node.Node.build(dirnode)
- dirnode.get_executor().nullify()
- # The build() action may or may not have actually
- # created the directory, depending on whether the -n
- # option was used or not. Delete the _exists and
- # _rexists attributes so they can be reevaluated.
- dirnode.clear()
- except OSError:
- pass
+ self.dir._create()
def retrieve_from_cache(self):
"""Try to retrieve the node's content from a cache
test.subdir('test')
-test.write('test/SConstruct', """
+test.write(['test', 'SConstruct'], """
src = Dir('src')
alt = Dir('alt')
var1 = Dir('build/var1')
all_src = "test/src/aaa.in\ntest/src/bbb.in\ntest/src/ccc.in\n"
all_alt = "test/alt/aaa.in\ntest/alt/bbb.in\ntest/alt/ccc.in\n"
-test.fail_test(test.read(all1) != all_src)
-test.fail_test(test.read(all2) != all_src)
-test.fail_test(test.read(all3) != all_src)
+test.must_match(all1, all_src)
+test.must_match(all2, all_src)
+test.must_match(all3, all_src)
#XXX We can't support var4 and var5 yet, because our BuildDir linkage
#XXX is to an entire source directory. We haven't yet generalized our
#XXX infrastructure to be able to take the SConscript file from one source
#XXX directory, but the rest of the files from a different one.
-#XXX test.fail_test(test.read(all4) != all_alt)
-#XXX test.fail_test(test.read(all5) != all_alt)
-test.fail_test(test.read(all6) != all_src)
-test.fail_test(test.read(all7) != all_src)
-test.fail_test(test.read(all8) != all_src)
-test.fail_test(test.read(all9) != all_src)
+#XXX test.must_match(all4, all_alt)
+#XXX test.must_match(all5, all_alt)
+test.must_match(all6, all_src)
+test.must_match(all7, all_src)
+test.must_match(all8, all_src)
+test.must_match(all9, all_src)
import os
import stat
# Make sure we did duplicate the source files in build/var1,
# and that their stats are the same:
for file in ['aaa.in', 'bbb.in', 'ccc.in']:
- test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var1', file)))
+ test.must_exist(test.workpath('test', 'build', 'var1', file))
test.fail_test(not equal_stats(test.workpath('test', 'build', 'var1', file),
test.workpath('test', 'src', file)))
# Make sure we did duplicate the source files in build/var2,
# and that their stats are the same:
for file in ['aaa.in', 'bbb.in', 'ccc.in']:
- test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var2', file)))
+ test.must_exist(test.workpath('test', 'build', 'var2', file))
test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', file),
test.workpath('test', 'src', file)))
# Make sure we didn't duplicate the source files in build/var3.
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'aaa.in')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'bbb.in')))
-test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'ccc.in')))
+test.must_not_exist(test.workpath('test', 'build', 'var3', 'aaa.in'))
+test.must_not_exist(test.workpath('test', 'build', 'var3', 'bbb.in'))
+test.must_not_exist(test.workpath('test', 'build', 'var3', 'ccc.in'))
#XXX We can't support var4 and var5 yet, because our BuildDir linkage
#XXX is to an entire source directory. We haven't yet generalized our
#XXX infrastructure to be able to take the SConscript file from one source
#XXX directory, but the rest of the files from a different one.
#XXX Make sure we didn't duplicate the source files in build/var4.
-#XXXtest.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'aaa.in')))
-#XXXtest.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'bbb.in')))
-#XXXtest.fail_test(os.path.exists(test.workpath('test', 'build', 'var4', 'ccc.in')))
+#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'aaa.in'))
+#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'bbb.in'))
+#XXXtest.must_not_exist(test.workpath('test', 'build', 'var4', 'ccc.in'))
#XXX We can't support var4 and var5 yet, because our BuildDir linkage
#XXX is to an entire source directory. We haven't yet generalized our
#XXX Make sure we did duplicate the source files in build/var5,
#XXX and that their stats are the same:
#XXXfor file in ['aaa.in', 'bbb.in', 'ccc.in']:
-#XXX test.fail_test(not os.path.exists(test.workpath('build', 'var5', file)))
+#XXX test.must_exist(test.workpath('build', 'var5', file))
#XXX test.fail_test(not equal_stats(test.workpath('build', 'var5', file),
#XXX test.workpath('test', 'src', file)))
# Make sure we did duplicate the source files in build/var6,
# and that their stats are the same:
for file in ['aaa.in', 'bbb.in', 'ccc.in']:
- test.fail_test(not os.path.exists(test.workpath('build', 'var6', file)))
+ test.must_exist(test.workpath('build', 'var6', file))
test.fail_test(not equal_stats(test.workpath('build', 'var6', file),
test.workpath('test', 'src', file)))
# Make sure we didn't duplicate the source files in build/var7.
-test.fail_test(os.path.exists(test.workpath('build', 'var7', 'aaa.in')))
-test.fail_test(os.path.exists(test.workpath('build', 'var7', 'bbb.in')))
-test.fail_test(os.path.exists(test.workpath('build', 'var7', 'ccc.in')))
+test.must_not_exist(test.workpath('build', 'var7', 'aaa.in'))
+test.must_not_exist(test.workpath('build', 'var7', 'bbb.in'))
+test.must_not_exist(test.workpath('build', 'var7', 'ccc.in'))
# Make sure we didn't duplicate the source files in build/var8.
-test.fail_test(os.path.exists(test.workpath('build', 'var8', 'aaa.in')))
-test.fail_test(os.path.exists(test.workpath('build', 'var8', 'bbb.in')))
-test.fail_test(os.path.exists(test.workpath('build', 'var8', 'ccc.in')))
+test.must_not_exist(test.workpath('build', 'var8', 'aaa.in'))
+test.must_not_exist(test.workpath('build', 'var8', 'bbb.in'))
+test.must_not_exist(test.workpath('build', 'var8', 'ccc.in'))
###################
test.subdir('test2')
_obj = TestSCons._obj
-test.fail_test(os.path.exists(test.workpath('test2', 'foo' + _obj)))
-test.fail_test(os.path.exists(test.workpath('test2', 'bar' + _obj)))
-test.fail_test(not os.path.exists(test.workpath('test2', 'Build', 'foo' + _obj)))
-test.fail_test(not os.path.exists(test.workpath('test2', 'Build', 'bar' + _obj)))
+test.must_not_exist(test.workpath('test2', 'foo' + _obj))
+test.must_not_exist(test.workpath('test2', 'bar' + _obj))
+test.must_exist(test.workpath('test2', 'Build', 'foo' + _obj))
+test.must_exist(test.workpath('test2', 'Build', 'bar' + _obj))
+
+###################
+# Make sure that directories for subsidiary SConscript() calls
+# in a build_dir get created if they don't already exist.
+test.subdir('test3')
+
+test.subdir(['test3', 'src'], ['test3', 'src', '_glscry'])
+
+test.write(['test3', 'SConstruct'], """\
+SConscript(dirs=['src'], build_dir='build', duplicate=0)
+""")
+
+test.write(['test3', 'src', 'SConscript'], """\
+SConscript(dirs=['_glscry'])
+""")
+
+test.write(['test3', 'src', '_glscry', 'SConscript'], """\
+""")
+
+test.write(['test3', 'src', 'file.in'], "file.in\n")
+
+test.write(['test3', 'src', '_glscry', 'file.in'], "file.in\n")
+
+test.run(chdir='test3')
+
test.pass_test()