summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/TestCmd.py4
-rw-r--r--etc/TestCommon.py12
-rw-r--r--test/AS.py2
-rw-r--r--test/CVS.py119
-rw-r--r--test/RCS.py90
5 files changed, 129 insertions, 98 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py
index cc73dd1..b90e653 100644
--- a/etc/TestCmd.py
+++ b/etc/TestCmd.py
@@ -175,8 +175,8 @@ version.
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.11.D001 2004/09/13 13:22:19 knight"
-__version__ = "0.11"
+__revision__ = "TestCmd.py 0.12.D001 2004/10/21 14:00:53 knight"
+__version__ = "0.12"
import os
import os.path
diff --git a/etc/TestCommon.py b/etc/TestCommon.py
index 924f8f8..8ef9b3d 100644
--- a/etc/TestCommon.py
+++ b/etc/TestCommon.py
@@ -76,8 +76,8 @@ The TestCommon module also provides the following variables
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.11.D001 2004/09/13 13:22:19 knight"
-__version__ = "0.11"
+__revision__ = "TestCommon.py 0.12.D001 2004/10/21 14:00:53 knight"
+__version__ = "0.12"
import os
import os.path
@@ -193,10 +193,10 @@ class TestCommon(TestCmd):
apply(TestCmd.__init__, [self], kw)
os.chdir(self.workdir)
- def must_contain(self, file, required):
+ def must_contain(self, file, required, mode = 'rb'):
"""Ensures that the specified file contains the required text.
"""
- file_contents = self.read(file)
+ file_contents = self.read(file, mode)
contains = (string.find(file_contents, required) != -1)
if not contains:
print "File `%s' does not contain required string." % file
@@ -218,13 +218,13 @@ class TestCommon(TestCmd):
print "Missing files: `%s'" % string.join(missing, "', `")
self.fail_test(missing)
- def must_match(self, file, expect):
+ def must_match(self, file, expect, mode = 'rb'):
"""Matches the contents of the specified file (first argument)
against the expected contents (second argument). The expected
contents are a list of lines or a string which will be split
on newlines.
"""
- file_contents = self.read(file)
+ file_contents = self.read(file, mode)
try:
self.fail_test(not self.match(file_contents, expect))
except:
diff --git a/test/AS.py b/test/AS.py
index b841154..adace1e 100644
--- a/test/AS.py
+++ b/test/AS.py
@@ -308,7 +308,7 @@ os.system(string.join(sys.argv[1:], " "))
import os
ccc = Environment(tools = ['msvc', 'mslink', 'masm'],
ASFLAGS = '/nologo /coff')
-ccc['ENV']['PATH'] = os.environ['PATH']
+ccc['ENV']['PATH'] = ccc['ENV']['PATH'] + os.pathsep + os.environ['PATH']
ddd = ccc.Copy(AS = r'%s wrapper.py ' + ccc['AS'])
ccc.Program(target = 'ccc', source = ['ccc.asm', 'ccc_main.c'])
ddd.Program(target = 'ddd', source = ['ddd.asm', 'ddd_main.c'])
diff --git a/test/CVS.py b/test/CVS.py
index 0e9decc..59384c9 100644
--- a/test/CVS.py
+++ b/test/CVS.py
@@ -110,9 +110,9 @@ env.Cat('aaa.out', 'foo/aaa.in')
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'))
+env.SourceCode('.', env.CVS(r'%(cvsroot)s'))
SConscript('foo/sub/SConscript', "env")
-""" % cvsroot)
+""" % locals())
test.subdir(['work1', 'foo'])
test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n")
@@ -123,39 +123,33 @@ test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n")
test.run(chdir = 'work1',
arguments = '.',
stdout = test.wrap_stdout(read_str = """\
-cvs -Q -d %s co foo/sub/SConscript
-""" % (cvsroot),
+cvs -Q -d %(cvsroot)s co foo/sub/SConscript
+""" % locals(),
build_str = """\
-cvs -Q -d %s co foo/aaa.in
-cat(["aaa.out"], ["%s"])
-cat(["bbb.out"], ["%s"])
-cvs -Q -d %s co foo/ccc.in
-cat(["ccc.out"], ["%s"])
+cvs -Q -d %(cvsroot)s co foo/aaa.in
+cat(["aaa.out"], ["%(foo_aaa_in)s"])
+cat(["bbb.out"], ["%(foo_bbb_in)s"])
+cvs -Q -d %(cvsroot)s co foo/ccc.in
+cat(["ccc.out"], ["%(foo_ccc_in)s"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
-cvs -Q -d %s co foo/sub/ddd.in
-cat(["%s"], ["%s"])
-cat(["%s"], ["%s"])
-cvs -Q -d %s co foo/sub/fff.in
-cat(["%s"], ["%s"])
-cat(["%s"], ["%s", "%s", "%s"])
-""" % (cvsroot,
- foo_aaa_in,
- foo_bbb_in,
- cvsroot,
- foo_ccc_in,
- cvsroot,
- foo_sub_ddd_out, foo_sub_ddd_in,
- foo_sub_eee_out, foo_sub_eee_in,
- cvsroot,
- foo_sub_fff_out, foo_sub_fff_in,
- foo_sub_all, foo_sub_ddd_out, foo_sub_eee_out, foo_sub_fff_out)))
+cvs -Q -d %(cvsroot)s co foo/sub/ddd.in
+cat(["%(foo_sub_ddd_out)s"], ["%(foo_sub_ddd_in)s"])
+cat(["%(foo_sub_eee_out)s"], ["%(foo_sub_eee_in)s"])
+cvs -Q -d %(cvsroot)s co foo/sub/fff.in
+cat(["%(foo_sub_fff_out)s"], ["%(foo_sub_fff_in)s"])
+cat(["%(foo_sub_all)s"], ["%(foo_sub_ddd_out)s", "%(foo_sub_eee_out)s", "%(foo_sub_fff_out)s"])
+""" % locals()))
# Checking things back out of CVS apparently messes with the line
# endings, so read the result files in non-binary mode.
-test.fail_test(test.read(['work1', 'all'], 'r') != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n")
+test.must_match(['work1', 'all'],
+ "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n",
+ mode='r')
-test.fail_test(test.read(['work1', 'foo', 'sub', 'all'], 'r') != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n")
+test.must_match(['work1', 'foo', 'sub', 'all'],
+ "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n",
+ mode='r')
test.fail_test(not is_writable(test.workpath('work1', 'foo', 'sub', 'SConscript')))
test.fail_test(not is_writable(test.workpath('work1', 'foo', 'aaa.in')))
@@ -180,9 +174,9 @@ env.Cat('aaa.out', 'aaa.in')
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'))
+env.SourceCode('.', env.CVS(r'%(cvsroot)s', 'foo'))
SConscript('sub/SConscript', "env")
-""" % cvsroot)
+""" % locals())
test.write(['work2', 'bbb.in'], "work2/bbb.in\n")
@@ -192,41 +186,38 @@ test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n")
test.run(chdir = 'work2',
arguments = '.',
stdout = test.wrap_stdout(read_str = """\
-cvs -q -d %s co -d sub foo/sub/SConscript
+cvs -q -d %(cvsroot)s co -d sub foo/sub/SConscript
U sub/SConscript
-""" % (cvsroot),
+""" % locals(),
build_str = """\
-cvs -q -d %s co -d . foo/aaa.in
+cvs -q -d %(cvsroot)s co -d . foo/aaa.in
U ./aaa.in
cat(["aaa.out"], ["aaa.in"])
cat(["bbb.out"], ["bbb.in"])
-cvs -q -d %s co -d . foo/ccc.in
+cvs -q -d %(cvsroot)s co -d . foo/ccc.in
U ./ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
-cvs -q -d %s co -d sub foo/sub/ddd.in
+cvs -q -d %(cvsroot)s co -d sub foo/sub/ddd.in
U sub/ddd.in
-cat(["%s"], ["%s"])
-cat(["%s"], ["%s"])
-cvs -q -d %s co -d sub foo/sub/fff.in
+cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
+cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
+cvs -q -d %(cvsroot)s co -d sub foo/sub/fff.in
U sub/fff.in
-cat(["%s"], ["%s"])
-cat(["%s"], ["%s", "%s", "%s"])
-""" % (cvsroot,
- cvsroot,
- cvsroot,
- sub_ddd_out, sub_ddd_in,
- sub_eee_out, sub_eee_in,
- cvsroot,
- sub_fff_out, sub_fff_in,
- sub_all, sub_ddd_out, sub_eee_out, sub_fff_out)))
+cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
+cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
+""" % locals()))
# Checking things back out of CVS apparently messes with the line
# endings, so read the result files in non-binary mode.
-test.fail_test(test.read(['work2', 'all'], 'r') != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n")
+test.must_match(['work2', 'all'],
+ "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n",
+ mode='r')
-test.fail_test(test.read(['work2', 'sub', 'all'], 'r') != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n")
+test.must_match(['work2', 'sub', 'all'],
+ "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n",
+ mode='r')
test.fail_test(not is_writable(test.workpath('work2', 'sub', 'SConscript')))
test.fail_test(not is_writable(test.workpath('work2', 'aaa.in')))
@@ -265,24 +256,30 @@ env.SourceCode('ccc.in', cvs)
test.run(chdir = 'work3',
arguments = '.',
stdout = test.wrap_stdout(build_str = """\
-cvs -q -d %s co -d . foo/aaa.in
+cvs -q -d %(cvsroot)s co -d . foo/aaa.in
U ./aaa.in
cat(["aaa.out"], ["aaa.in"])
-cvs -q -d %s co -d . foo/bbb.in
+cvs -q -d %(cvsroot)s co -d . foo/bbb.in
U ./bbb.in
cat(["bbb.out"], ["bbb.in"])
-cvs -q -d %s co -d . foo/ccc.in
+cvs -q -d %(cvsroot)s co -d . foo/ccc.in
U ./ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
-""" % (cvsroot,
- cvsroot,
- cvsroot)))
-
-test.must_match(['work3', 'aaa.out'], "import/aaa.in\n")
-test.must_match(['work3', 'bbb.out'], "import/bbb.in\n")
-test.must_match(['work3', 'ccc.out'], "import/ccc.in\n")
-test.must_match(['work3', 'all'], "import/aaa.in\nimport/bbb.in\nimport/ccc.in\n")
+""" % locals()))
+
+test.must_match(['work3', 'aaa.out'],
+ "import/aaa.in\n",
+ mode='r')
+test.must_match(['work3', 'bbb.out'],
+ "import/bbb.in\n",
+ mode='r')
+test.must_match(['work3', 'ccc.out'],
+ "import/ccc.in\n",
+ mode='r')
+test.must_match(['work3', 'all'],
+ "import/aaa.in\nimport/bbb.in\nimport/ccc.in\n",
+ mode='r')
# Test CVS checkouts from a remote server (Tigris.org).
test.subdir(['work4'])
diff --git a/test/RCS.py b/test/RCS.py
index 15ad0f5..50d353f 100644
--- a/test/RCS.py
+++ b/test/RCS.py
@@ -54,6 +54,16 @@ def is_writable(file):
# Test explicit checkouts from local RCS files.
test.subdir('work1', ['work1', 'sub'])
+sub_RCS = os.path.join('sub', 'RCS')
+sub_SConscript = os.path.join('sub', 'SConscript')
+sub_all = os.path.join('sub', 'all')
+sub_ddd_in = os.path.join('sub', 'ddd.in')
+sub_ddd_out = os.path.join('sub', 'ddd.out')
+sub_eee_in = os.path.join('sub', 'eee.in')
+sub_eee_out = os.path.join('sub', 'eee.out')
+sub_fff_in = os.path.join('sub', 'fff.in')
+sub_fff_out = os.path.join('sub', 'fff.out')
+
for file in ['aaa.in', 'bbb.in', 'ccc.in']:
test.write(['work1', file], "work1/%s\n" % file)
args = "-f -t%s %s" % (file, file)
@@ -86,7 +96,11 @@ test.no_result(os.path.exists(test.workpath('work1', 'sub', 'fff.in')))
test.write(['work1', 'SConstruct'], """
import os
-ENV = {'PATH' : os.environ['PATH']}
+for key in ['LOGNAME', 'USERNAME', 'USER']:
+ logname = os.environ.get(key)
+ if logname: break
+ENV = {'PATH' : os.environ['PATH'],
+ 'LOGNAME' : logname}
def cat(env, source, target):
target = str(target[0])
source = map(str, source)
@@ -97,6 +111,7 @@ def cat(env, source, target):
env = Environment(ENV=ENV,
BUILDERS={'Cat':Builder(action=cat)},
RCS_COFLAGS='-q')
+DefaultEnvironment()['ENV'] = ENV
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')
env.Cat('ccc.out', 'ccc.in')
@@ -112,8 +127,8 @@ test.write(['work1', 'sub', 'eee.in'], "checked-out work1/sub/eee.in\n")
test.run(chdir = 'work1',
arguments = '.',
stdout = test.wrap_stdout(read_str = """\
-co -q sub/SConscript
-""",
+co -q %(sub_SConscript)s
+""" % locals(),
build_str = """\
co -q aaa.in
cat(["aaa.out"], ["aaa.in"])
@@ -121,17 +136,24 @@ cat(["bbb.out"], ["bbb.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"])
-"""))
+co -q %(sub_ddd_in)s
+cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
+cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
+co -q %(sub_fff_in)s
+cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
+cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
+""" % locals()))
+
+# Checking things back out of RCS apparently messes with the line
+# endings, so read the result files in non-binary mode.
-test.must_match(['work1', 'all'], "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n")
+test.must_match(['work1', 'all'],
+ "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n",
+ mode='r')
-test.must_match(['work1', 'sub', 'all'], "work1/sub/ddd.in\nchecked-out work1/sub/eee.in\nwork1/sub/fff.in\n")
+test.must_match(['work1', 'sub', 'all'],
+ "work1/sub/ddd.in\nchecked-out work1/sub/eee.in\nwork1/sub/fff.in\n",
+ mode='r')
test.fail_test(is_writable(test.workpath('work1', 'sub', 'SConscript')))
test.fail_test(is_writable(test.workpath('work1', 'aaa.in')))
@@ -177,7 +199,11 @@ test.no_result(os.path.exists(test.workpath('work2', 'sub', 'ccc.in')))
test.write(['work2', 'SConstruct'], """
import os
-ENV = { 'PATH' : os.environ['PATH'] }
+for key in ['LOGNAME', 'USERNAME', 'USER']:
+ logname = os.environ.get(key)
+ if logname: break
+ENV = {'PATH' : os.environ['PATH'],
+ 'LOGNAME' : logname}
def cat(env, source, target):
target = str(target[0])
source = map(str, source)
@@ -185,6 +211,7 @@ def cat(env, source, target):
for src in source:
f.write(open(src, "rb").read())
f.close()
+DefaultEnvironment()['ENV'] = ENV
DefaultEnvironment()['RCS_COFLAGS'] = '-l'
env = Environment(ENV=ENV, BUILDERS={'Cat':Builder(action=cat)})
env.Cat('aaa.out', 'aaa.in')
@@ -201,8 +228,8 @@ test.write(['work2', 'sub', 'eee.in'], "checked-out work2/sub/eee.in\n")
test.run(chdir = 'work2',
arguments = '.',
stdout = test.wrap_stdout(read_str = """\
-co -l sub/SConscript
-""",
+co -l %(sub_SConscript)s
+""" % locals(),
build_str = """\
co -l aaa.in
cat(["aaa.out"], ["aaa.in"])
@@ -210,15 +237,15 @@ cat(["bbb.out"], ["bbb.in"])
co -l ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
-co -l sub/ddd.in
-cat(["sub/ddd.out"], ["sub/ddd.in"])
-cat(["sub/eee.out"], ["sub/eee.in"])
-co -l sub/fff.in
-cat(["sub/fff.out"], ["sub/fff.in"])
-cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"])
-"""),
+co -l %(sub_ddd_in)s
+cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
+cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
+co -l %(sub_fff_in)s
+cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
+cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
+""" % locals()),
stderr = """\
-sub/RCS/SConscript,v --> sub/SConscript
+%(sub_RCS)s/SConscript,v --> %(sub_SConscript)s
revision 1.1 (locked)
done
RCS/aaa.in,v --> aaa.in
@@ -227,17 +254,24 @@ done
RCS/ccc.in,v --> ccc.in
revision 1.1 (locked)
done
-sub/RCS/ddd.in,v --> sub/ddd.in
+%(sub_RCS)s/ddd.in,v --> %(sub_ddd_in)s
revision 1.1 (locked)
done
-sub/RCS/fff.in,v --> sub/fff.in
+%(sub_RCS)s/fff.in,v --> %(sub_fff_in)s
revision 1.1 (locked)
done
-""")
+""" % locals())
+
+# Checking things back out of RCS apparently messes with the line
+# endings, so read the result files in non-binary mode.
-test.must_match(['work2', 'all'], "work2/aaa.in\nchecked-out work2/bbb.in\nwork2/ccc.in\n")
+test.must_match(['work2', 'all'],
+ "work2/aaa.in\nchecked-out work2/bbb.in\nwork2/ccc.in\n",
+ mode='r')
-test.must_match(['work2', 'sub', 'all'], "work2/sub/ddd.in\nchecked-out work2/sub/eee.in\nwork2/sub/fff.in\n")
+test.must_match(['work2', 'sub', 'all'],
+ "work2/sub/ddd.in\nchecked-out work2/sub/eee.in\nwork2/sub/fff.in\n",
+ mode='r')
test.fail_test(not is_writable(test.workpath('work2', 'sub', 'SConscript')))
test.fail_test(not is_writable(test.workpath('work2', 'aaa.in')))