From dbe12389b6253c305749d8e2d4e1558477a15787 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 21 Feb 2003 14:55:50 +0000 Subject: Support fetching SConscript files from source code management systems. --- src/engine/SCons/Builder.py | 2 +- src/engine/SCons/BuilderTests.py | 2 +- src/engine/SCons/Node/FS.py | 4 +- src/engine/SCons/Node/FSTests.py | 15 +++++ src/engine/SCons/Node/NodeTests.py | 19 ++++++ src/engine/SCons/Node/__init__.py | 2 +- src/engine/SCons/Script/SConscript.py | 13 +++++ src/engine/SCons/Tool/RCS.py | 2 +- test/BitKeeper.py | 59 ++++++++++++++++--- test/CVS.py | 54 +++++++++++++++-- test/RCS.py | 106 ++++++++++++++++++++++++++++++---- test/SCCS.py | 40 ++++++++++++- test/Subversion.py | 56 +++++++++++++++--- 13 files changed, 333 insertions(+), 41 deletions(-) diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index aceadbc..5047a44 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -144,7 +144,7 @@ def _init_nodes(builder, env, overrides, tlist, slist): for t in tlist: if t.side_effect: raise UserError, "Multiple ways to build the same target were specified for: %s" % str(t) - if t.has_builder(): + if t.has_builder(fetch = 0): if t.env != env: raise UserError, "Two different environments were specified for the same target: %s"%str(t) elif t.overrides != overrides: diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 1c574d3..3ad6b23 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -140,7 +140,7 @@ class BuilderTestCase(unittest.TestCase): return self.name def builder_set(self, builder): self.builder = builder - def has_builder(self): + def has_builder(self, fetch=1): return not self.builder is None def env_set(self, env, safe=0): self.env = env diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 5a8687e..e2378b1 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1016,7 +1016,7 @@ class File(Entry): if self.fs.CachePath and self.fs.cache_force and os.path.exists(self.path): CachePush(self, None, None) - def has_builder(self): + def has_builder(self, fetch = 1): """Return whether this Node has a builder or not. If this Node doesn't have an explicit builder, this is where we @@ -1025,7 +1025,7 @@ class File(Entry): try: b = self.builder except AttributeError: - if not os.path.exists(self.path): + if fetch and not os.path.exists(self.path): b = self.src_builder() else: b = None diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index f1160c1..1e8bc92 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1180,6 +1180,10 @@ class has_builderTestCase(unittest.TestCase): f1 = fs.File('f1', d) f2 = fs.File('f2', d) f3 = fs.File('f3', d) + f4 = fs.File('f4', d) + f5 = fs.File('f5', d) + f6 = fs.File('f6', d) + f7 = fs.File('f7', d) h = f1.has_builder() assert not h, h @@ -1196,6 +1200,17 @@ class has_builderTestCase(unittest.TestCase): assert h, h assert f3.builder is b1, f3.builder + test.write(['sub', 'f4'], "sub/f4\n") + test.write(['sub', 'f6'], "sub/f6\n") + h = f4.has_builder(fetch = 0) + assert not h, h + h = f5.has_builder(fetch = 0) + assert not h, h + h = f6.has_builder(fetch = 1) + assert not h, h + h = f7.has_builder(fetch = 1) + assert h, h + class prepareTestCase(unittest.TestCase): def runTest(self): """Test the prepare() method""" diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index b47106d..a9fa361 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -255,6 +255,25 @@ class NodeTestCase(unittest.TestCase): node.builder_set(b) assert node.builder == b + def test_has_builder(self): + """Test the has_builder() method + """ + n1 = SCons.Node.Node() + n2 = SCons.Node.Node() + n3 = SCons.Node.Node() + + assert n1.has_builder() == 0 + assert n2.has_builder(fetch = 0) == 0 + assert n3.has_builder(fetch = 1) == 0 + + n1.builder_set(Builder()) + n2.builder_set(Builder()) + n3.builder_set(Builder()) + + assert n1.has_builder() == 1 + assert n2.has_builder(fetch = 0) == 1 + assert n3.has_builder(fetch = 1) == 1 + def test_builder_sig_adapter(self): """Test the node's adapter for builder signatures """ diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 27ff4db..0a64586 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -208,7 +208,7 @@ class Node: def builder_set(self, builder): self.builder = builder - def has_builder(self): + def has_builder(self, fetch = 1): """Return whether this Node has a builder or not. In Boolean tests, this turns out to be a *lot* more efficient diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index f2d07fd..4c54879 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -186,8 +186,21 @@ def SConscript(*ls, **kw): f = fn else: f = SCons.Node.FS.default_fs.File(str(fn)) + _file_ = None if f.rexists(): _file_ = open(f.rstr(), "r") + elif f.has_builder(): + # The SConscript file apparently exists in a source + # code management system. Build it, but then remove + # the builder so that it doesn't get built *again* + # during the actual build phase. + f.build() + f.builder_set(None) + s = str(f) + if os.path.exists(s): + _file_ = open(s, "r") + + if _file_: SCons.Node.FS.default_fs.chdir(f.dir) if sconscript_chdir: old_dir = os.getcwd() diff --git a/src/engine/SCons/Tool/RCS.py b/src/engine/SCons/Tool/RCS.py index 1f5489b..f6276c5 100644 --- a/src/engine/SCons/Tool/RCS.py +++ b/src/engine/SCons/Tool/RCS.py @@ -48,7 +48,7 @@ def generate(env, platform): env['CO'] = 'co' env['RCS'] = 'rcs' env['RCSFLAGS'] = '' - env['RCSCOM'] = '$CO $RCSFLAGS -p $TARGET,v > $TARGET' + env['RCSCOM'] = '$CO $RCSFLAGS $TARGET' def exists(env): return env.Detect('rcs') diff --git a/test/BitKeeper.py b/test/BitKeeper.py index 7994a96..0926b28 100644 --- a/test/BitKeeper.py +++ b/test/BitKeeper.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons() bk = test.where_is('bk') if not bk: print "Could not find BitKeeper, skipping test(s)." - test.no_result(1) + test.pass_test(1) try: login = os.getlogin() @@ -51,7 +51,7 @@ host = os.uname()[1] email = "%s@%s" % (login, host) -test.subdir('BitKeeper', 'import', 'work1', 'work2', 'work3') +test.subdir('BitKeeper', 'import', ['import', 'sub'], 'work1', 'work2') # Set up the BitKeeper repository. bkroot = test.workpath('BitKeeper') @@ -80,6 +80,18 @@ test.write(['import', 'aaa.in'], "import/aaa.in\n") test.write(['import', 'bbb.in'], "import/bbb.in\n") test.write(['import', 'ccc.in'], "import/ccc.in\n") +test.write(['import', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") +test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") +test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") + test.run(chdir = 'import', program = bk, arguments = 'import -q -f -tplain . %s/foo' % bkroot) @@ -99,28 +111,46 @@ env.Cat('bbb.out', 'foo/bbb.in') env.Cat('ccc.out', 'foo/ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.BitKeeper(r'%s')) +SConscript('foo/sub/SConscript', "env") """ % bkroot) test.subdir(['work1', 'foo']) test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n") +test.subdir(['work1', 'foo', 'sub']) +test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n") + test.run(chdir = 'work1', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +bk get -p %s/foo/sub/SConscript > foo/sub/SConscript +""" % (bkroot), + build_str = """\ bk get -p %s/foo/aaa.in > foo/aaa.in cat("aaa.out", "foo/aaa.in") cat("bbb.out", "foo/bbb.in") bk get -p %s/foo/ccc.in > foo/ccc.in cat("ccc.out", "foo/ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (bkroot, bkroot)), +bk get -p %s/foo/sub/ddd.in > foo/sub/ddd.in +cat("foo/sub/ddd.out", "foo/sub/ddd.in") +cat("foo/sub/eee.out", "foo/sub/eee.in") +bk get -p %s/foo/sub/fff.in > foo/sub/fff.in +cat("foo/sub/fff.out", "foo/sub/fff.in") +cat("foo/sub/all", ["foo/sub/ddd.out", "foo/sub/eee.out", "foo/sub/fff.out"]) +""" % (bkroot, bkroot, bkroot, bkroot)), stderr = """\ +%s/foo/sub/SConscript 1.1: 5 lines %s/foo/aaa.in 1.1: 1 lines %s/foo/ccc.in 1.1: 1 lines -""" % (bkroot, bkroot)) +%s/foo/sub/ddd.in 1.1: 1 lines +%s/foo/sub/fff.in 1.1: 1 lines +""" % (bkroot, bkroot, bkroot, bkroot, bkroot)) test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work1', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") + # Test BitKeeper checkouts when the module name is specified. test.write(['work2', 'SConstruct'], """ def cat(env, source, target): @@ -137,21 +167,36 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.BitKeeper(r'%s', 'foo')) +SConscript('sub/SConscript', "env") """ % bkroot) test.write(['work2', 'bbb.in'], "work2/bbb.in\n") +test.subdir(['work2', 'sub']) +test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") + test.run(chdir = 'work2', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +bk get -q -p %s/foo/sub/SConscript > sub/SConscript +""" % (bkroot), + build_str = """\ bk get -q -p %s/foo/aaa.in > aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") bk get -q -p %s/foo/ccc.in > ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (bkroot, bkroot))) +bk get -q -p %s/foo/sub/ddd.in > sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +bk get -q -p %s/foo/sub/fff.in > sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) +""" % (bkroot, bkroot, bkroot, bkroot))) test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work2', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") + test.pass_test() diff --git a/test/CVS.py b/test/CVS.py index c94ae8b..bf1e830 100644 --- a/test/CVS.py +++ b/test/CVS.py @@ -37,9 +37,9 @@ test = TestSCons.TestSCons() cvs = test.where_is('cvs') if not cvs: print "Could not find CVS, skipping test(s)." - test.no_result(1) + test.pass_test(1) -test.subdir('CVS', 'import', 'work1', 'work2', 'work3') +test.subdir('CVS', 'import', ['import', 'sub'], 'work1', 'work2') # Set up the CVS repository. cvsroot = test.workpath('CVS') @@ -51,6 +51,18 @@ test.write(['import', 'aaa.in'], "import/aaa.in\n") test.write(['import', 'bbb.in'], "import/bbb.in\n") test.write(['import', 'ccc.in'], "import/ccc.in\n") +test.write(['import', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") +test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") +test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") + test.run(chdir = 'import', program = cvs, arguments = '-q import -m "import" foo v v-r') @@ -71,24 +83,39 @@ env.Cat('bbb.out', 'foo/bbb.in') env.Cat('ccc.out', 'foo/ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.CVS(r'%s')) +SConscript('foo/sub/SConscript', "env") """ % cvsroot) test.subdir(['work1', 'foo']) test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n") +test.subdir(['work1', 'foo', 'sub',]) +test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n") + test.run(chdir = 'work1', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +cvs -Q -d %s co -p foo/sub/SConscript > foo/sub/SConscript +""" % (cvsroot), + build_str = """\ cvs -Q -d %s co -p foo/aaa.in > foo/aaa.in cat("aaa.out", "foo/aaa.in") cat("bbb.out", "foo/bbb.in") cvs -Q -d %s co -p foo/ccc.in > foo/ccc.in cat("ccc.out", "foo/ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (cvsroot, cvsroot))) +cvs -Q -d %s co -p foo/sub/ddd.in > foo/sub/ddd.in +cat("foo/sub/ddd.out", "foo/sub/ddd.in") +cat("foo/sub/eee.out", "foo/sub/eee.in") +cvs -Q -d %s co -p foo/sub/fff.in > foo/sub/fff.in +cat("foo/sub/fff.out", "foo/sub/fff.in") +cat("foo/sub/all", ["foo/sub/ddd.out", "foo/sub/eee.out", "foo/sub/fff.out"]) +""" % (cvsroot, cvsroot, cvsroot, cvsroot))) test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work1', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") + # Test CVS checkouts when the module name is specified. test.write(['work2', 'SConstruct'], """ def cat(env, source, target): @@ -105,21 +132,36 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.CVS(r'%s', 'foo')) +SConscript('sub/SConscript', "env") """ % cvsroot) test.write(['work2', 'bbb.in'], "work2/bbb.in\n") +test.subdir(['work2', 'sub']) +test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") + test.run(chdir = 'work2', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +cvs -q -d %s co -p foo/sub/SConscript > sub/SConscript +""" % (cvsroot), + build_str = """\ cvs -q -d %s co -p foo/aaa.in > aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") cvs -q -d %s co -p foo/ccc.in > ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (cvsroot, cvsroot))) +cvs -q -d %s co -p foo/sub/ddd.in > sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +cvs -q -d %s co -p foo/sub/fff.in > sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) +""" % (cvsroot, cvsroot, cvsroot, cvsroot))) test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work2', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") + test.pass_test() diff --git a/test/RCS.py b/test/RCS.py index 6c0e597..55e16f8 100644 --- a/test/RCS.py +++ b/test/RCS.py @@ -37,25 +37,46 @@ test = TestSCons.TestSCons() rcs = test.where_is('rcs') if not rcs: print "Could not find RCS, skipping test(s)." - test.no_result(1) + test.pass_test(1) ci = test.where_is('ci') if not ci: print "Could not find `ci' command, skipping test(s)." - test.no_result(1) + test.pass_test(1) # Test checkouts from local RCS files -test.subdir('work1') +test.subdir('work1', ['work1', 'sub']) for file in ['aaa.in', 'bbb.in', 'ccc.in']: test.write(['work1', file], "work1/%s\n" % file) args = "-f -t%s %s" % (file, file) test.run(chdir = 'work1', program = ci, arguments = args, stderr = None) +test.write(['work1', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") +args = "-f -tsub/SConscript sub/SConscript" +test.run(chdir = 'work1', program = ci, arguments = args, stderr = None) + +for file in ['ddd.in', 'eee.in', 'fff.in']: + test.write(['work1', 'sub', file], "work1/sub/%s\n" % file) + args = "-f -tsub/%s sub/%s" % (file, file) + test.run(chdir = 'work1', program = ci, arguments = args, stderr = None) + test.no_result(os.path.exists(test.workpath('work1', 'aaa.in'))) test.no_result(os.path.exists(test.workpath('work1', 'bbb.in'))) test.no_result(os.path.exists(test.workpath('work1', 'ccc.in'))) +test.no_result(os.path.exists(test.workpath('work1', 'sub', 'SConscript'))) + +test.no_result(os.path.exists(test.workpath('work1', 'sub', 'ddd.in'))) +test.no_result(os.path.exists(test.workpath('work1', 'sub', 'eee.in'))) +test.no_result(os.path.exists(test.workpath('work1', 'sub', 'fff.in'))) + test.write(['work1', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) @@ -70,41 +91,88 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.RCS()) +SConscript('sub/SConscript', "env") """) test.write(['work1', 'bbb.in'], "checked-out work1/bbb.in\n") +test.write(['work1', 'sub', 'eee.in'], "checked-out work1/sub/eee.in\n") + test.run(chdir = 'work1', arguments = '.', - stdout = test.wrap_stdout("""\ -co -p aaa.in,v > aaa.in + stdout = test.wrap_stdout(read_str = """\ +co sub/SConscript +""", + build_str = """\ +co aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") -co -p ccc.in,v > ccc.in +co ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) +co sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +co sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """), stderr = """\ -aaa.in,v --> standard output +sub/SConscript,v --> sub/SConscript +revision 1.1 +done +aaa.in,v --> aaa.in +revision 1.1 +done +ccc.in,v --> ccc.in +revision 1.1 +done +sub/ddd.in,v --> sub/ddd.in revision 1.1 -ccc.in,v --> standard output +done +sub/fff.in,v --> sub/fff.in revision 1.1 +done """) test.fail_test(test.read(['work1', 'all']) != "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n") +test.fail_test(test.read(['work1', 'sub', 'all']) != "work1/sub/ddd.in\nchecked-out work1/sub/eee.in\nwork1/sub/fff.in\n") + # Test RCS checkouts from an RCS subdirectory. -test.subdir('work2', ['work2', 'RCS']) +test.subdir('work2', ['work2', 'RCS'], + ['work2', 'sub'], ['work2', 'sub', 'RCS']) for file in ['aaa.in', 'bbb.in', 'ccc.in']: test.write(['work2', file], "work2/%s\n" % file) args = "-f -t%s %s" % (file, file) test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) +for file in ['ddd.in', 'eee.in', 'fff.in']: + test.write(['work2', 'sub', file], "work2/sub/%s\n" % file) + args = "-f -tsub/%s sub/%s" % (file, file) + test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) + +test.write(['work2', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") +args = "-f -tsub/SConscript sub/SConscript" +test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) + test.no_result(os.path.exists(test.workpath('work2', 'aaa.in'))) test.no_result(os.path.exists(test.workpath('work2', 'bbb.in'))) test.no_result(os.path.exists(test.workpath('work2', 'ccc.in'))) +test.no_result(os.path.exists(test.workpath('work2', 'sub', 'SConscript'))) + +test.no_result(os.path.exists(test.workpath('work2', 'sub', 'aaa.in'))) +test.no_result(os.path.exists(test.workpath('work2', 'sub', 'bbb.in'))) +test.no_result(os.path.exists(test.workpath('work2', 'sub', 'ccc.in'))) + test.write(['work2', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) @@ -120,21 +188,35 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.RCS()) +SConscript('sub/SConscript', "env") """) test.write(['work2', 'bbb.in'], "checked-out work2/bbb.in\n") +test.write(['work2', 'sub', 'eee.in'], "checked-out work2/sub/eee.in\n") + test.run(chdir = 'work2', arguments = '.', - stdout = test.wrap_stdout("""\ -co -q -p aaa.in,v > aaa.in + stdout = test.wrap_stdout(read_str = """\ +co -q sub/SConscript +""", + build_str = """\ +co -q aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") -co -q -p ccc.in,v > ccc.in +co -q ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) +co -q sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +co -q sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """)) test.fail_test(test.read(['work2', 'all']) != "work2/aaa.in\nchecked-out work2/bbb.in\nwork2/ccc.in\n") +test.fail_test(test.read(['work2', 'sub', 'all']) != "work2/sub/ddd.in\nchecked-out work2/sub/eee.in\nwork2/sub/fff.in\n") + test.pass_test() diff --git a/test/SCCS.py b/test/SCCS.py index a25f222..00e3337 100644 --- a/test/SCCS.py +++ b/test/SCCS.py @@ -35,10 +35,10 @@ test = TestSCons.TestSCons() sccs = test.where_is('sccs') if not sccs: print "Could not find SCCS, skipping test(s)." - test.no_result(1) + test.pass_test(1) # Test checkouts from local SCCS files. -test.subdir('work1') +test.subdir('work1', ['work1', 'sub']) test.preserve() @@ -49,6 +49,25 @@ for file in ['aaa.in', 'bbb.in', 'ccc.in']: test.unlink(['work1', file]) test.unlink(['work1', ','+file]) +test.write(['work1', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") +args = "create SConscript" +test.run(chdir = 'work1/sub', program = sccs, arguments = args, stderr = None) +test.unlink(['work1', 'sub', 'SConscript']) +test.unlink(['work1', 'sub', ',SConscript']) + +for file in ['ddd.in', 'eee.in', 'fff.in']: + test.write(['work1', 'sub', file], "work1/sub/%s\n" % file) + args = "create %s" % file + test.run(chdir = 'work1/sub', program = sccs, arguments = args, stderr = None) + test.unlink(['work1', 'sub', file]) + test.unlink(['work1', 'sub', ','+file]) + test.write(['work1', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) @@ -63,22 +82,37 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.SCCS()) +SConscript('sub/SConscript', "env") """) test.write(['work1', 'bbb.in'], "checked-out work1/bbb.in\n") +test.write(['work1', 'sub', 'eee.in'], "checked-out work1/sub/eee.in\n") + test.run(chdir = 'work1', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +sccs get sub/SConscript +""", + build_str = """\ sccs get aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") sccs get ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) +sccs get sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +sccs get sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) """), stderr = """\ +sub/SConscript 1.1: 5 lines aaa.in 1.1: 1 lines ccc.in 1.1: 1 lines +sub/ddd.in 1.1: 1 lines +sub/fff.in 1.1: 1 lines """) test.fail_test(test.read(['work1', 'all']) != "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n") diff --git a/test/Subversion.py b/test/Subversion.py index 648a131..6dc7d53 100644 --- a/test/Subversion.py +++ b/test/Subversion.py @@ -35,14 +35,14 @@ test = TestSCons.TestSCons() svn = test.where_is('svn') if not svn: print "Could not find Subversion, skipping test(s)." - test.no_result(1) + test.pass_test(1) svnadmin = test.where_is('svnadmin') if not svn: print "Could not find Subversion, skipping test(s)." - test.no_result(1) + test.pass_test(1) -test.subdir('Subversion', 'import', 'work1', 'work2', 'work3') +test.subdir('Subversion', 'import', ['import', 'sub'], 'work1', 'work2') # Set up the Subversion repository. svnrootpath = test.workpath('Subversion') @@ -54,6 +54,18 @@ test.write(['import', 'aaa.in'], "import/aaa.in\n") test.write(['import', 'bbb.in'], "import/bbb.in\n") test.write(['import', 'ccc.in'], "import/ccc.in\n") +test.write(['import', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") +test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") +test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") + test.run(chdir = 'import', program = svn, arguments = 'import %s . foo -m"import foo"' % svnrooturl) @@ -73,24 +85,39 @@ env.Cat('bbb.out', 'foo/bbb.in') env.Cat('ccc.out', 'foo/ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.Subversion(r'%s')) +SConscript('foo/sub/SConscript', "env") """ % svnrooturl) test.subdir(['work1', 'foo']) test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n") +test.subdir(['work1', 'foo', 'sub']) +test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n") + test.run(chdir = 'work1', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +svn cat %s/foo/sub/SConscript > foo/sub/SConscript +""" % (svnrooturl), + build_str = """\ svn cat %s/foo/aaa.in > foo/aaa.in cat("aaa.out", "foo/aaa.in") cat("bbb.out", "foo/bbb.in") svn cat %s/foo/ccc.in > foo/ccc.in cat("ccc.out", "foo/ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (svnrooturl, svnrooturl))) +svn cat %s/foo/sub/ddd.in > foo/sub/ddd.in +cat("foo/sub/ddd.out", "foo/sub/ddd.in") +cat("foo/sub/eee.out", "foo/sub/eee.in") +svn cat %s/foo/sub/fff.in > foo/sub/fff.in +cat("foo/sub/fff.out", "foo/sub/fff.in") +cat("foo/sub/all", ["foo/sub/ddd.out", "foo/sub/eee.out", "foo/sub/fff.out"]) +""" % (svnrooturl, svnrooturl, svnrooturl, svnrooturl))) test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work1', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") + # Test Subversion checkouts when the module name is specified. test.write(['work2', 'SConstruct'], """ def cat(env, source, target): @@ -106,21 +133,36 @@ env.Cat('bbb.out', 'bbb.in') env.Cat('ccc.out', 'ccc.in') env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) env.SourceCode('.', env.Subversion(r'%s', 'foo')) +SConscript('sub/SConscript', "env") """ % svnrooturl) test.write(['work2', 'bbb.in'], "work2/bbb.in\n") +test.subdir(['work2', 'sub']) +test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") + test.run(chdir = 'work2', arguments = '.', - stdout = test.wrap_stdout("""\ + stdout = test.wrap_stdout(read_str = """\ +svn cat %s/foo/sub/SConscript > sub/SConscript +""" % (svnrooturl), + build_str = """\ svn cat %s/foo/aaa.in > aaa.in cat("aaa.out", "aaa.in") cat("bbb.out", "bbb.in") svn cat %s/foo/ccc.in > ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -""" % (svnrooturl, svnrooturl))) +svn cat %s/foo/sub/ddd.in > sub/ddd.in +cat("sub/ddd.out", "sub/ddd.in") +cat("sub/eee.out", "sub/eee.in") +svn cat %s/foo/sub/fff.in > sub/fff.in +cat("sub/fff.out", "sub/fff.in") +cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) +""" % (svnrooturl, svnrooturl, svnrooturl, svnrooturl))) test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work2', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") + test.pass_test() -- cgit v0.12