summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-09-14 19:29:01 (GMT)
committerSteven Knight <knight@baldmt.com>2003-09-14 19:29:01 (GMT)
commit3ab7670a45179b7a09eabc219842f6c224ad35da (patch)
treeaca25fd119f68b44fa181a90bd535bfdfb01fed5 /test
parent1c2ac0f2ca0c14d1181add9cc66d9650fece1481 (diff)
downloadSCons-3ab7670a45179b7a09eabc219842f6c224ad35da.zip
SCons-3ab7670a45179b7a09eabc219842f6c224ad35da.tar.gz
SCons-3ab7670a45179b7a09eabc219842f6c224ad35da.tar.bz2
Make more Environment methods from global functions.
Diffstat (limited to 'test')
-rw-r--r--test/BuildDir.py3
-rw-r--r--test/CacheDir.py5
-rw-r--r--test/Dir.py58
-rw-r--r--test/File.py58
-rw-r--r--test/Repository/SConscript.py3
-rw-r--r--test/SConsignFile.py3
-rw-r--r--test/option--C.py9
7 files changed, 130 insertions, 9 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py
index bca4104..6d5289f 100644
--- a/test/BuildDir.py
+++ b/test/BuildDir.py
@@ -69,11 +69,12 @@ var4 = Dir('build/var4')
var5 = Dir('../build/var5')
var6 = Dir('../build/var6')
+env = Environment(BUILD = 'build', SRC = 'src')
BuildDir('build/var1', src)
BuildDir(var2, src)
BuildDir(var3, src, duplicate=0)
-BuildDir(var4, src, duplicate=0)
+env.BuildDir("$BUILD/var4", "$SRC", duplicate=0)
BuildDir(var5, src, duplicate=0)
BuildDir(var6, src)
diff --git a/test/CacheDir.py b/test/CacheDir.py
index de78e7a..a906b6a 100644
--- a/test/CacheDir.py
+++ b/test/CacheDir.py
@@ -150,10 +150,11 @@ test.write(['src', 'ccc.in'], "ccc.in\n")
#
test.write('SConstruct', """\
-CacheDir(r'%s')
+env = Environment(TWO = '2')
+env.CacheDir(r'%s')
BuildDir('build', 'src', duplicate=0)
SConscript('build/SConscript')
-""" % test.workpath('cache2'))
+""" % test.workpath('cache${TWO}'))
# Verify that a normal build works correctly, and clean up.
# This should populate the cache with our derived files.
diff --git a/test/Dir.py b/test/Dir.py
new file mode 100644
index 0000000..5c4eaa3
--- /dev/null
+++ b/test/Dir.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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__"
+
+"""
+Verify that the Dir() global function and environment method work
+correctly, and that the former does not try to expand construction
+variables.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(FOO = 'fff', BAR = 'bbb')
+print Dir('ddd')
+print Dir('$FOO')
+print Dir('${BAR}_$BAR')
+print env.Dir('eee')
+print env.Dir('$FOO')
+print env.Dir('${BAR}_$BAR')
+""")
+
+test.run(stdout = test.wrap_stdout(read_str = """\
+ddd
+$FOO
+${BAR}_$BAR
+eee
+fff
+bbb_bbb
+""", build_str = """\
+scons: `.' is up to date.
+"""))
+
+test.pass_test()
diff --git a/test/File.py b/test/File.py
new file mode 100644
index 0000000..6f634cf
--- /dev/null
+++ b/test/File.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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__"
+
+"""
+Verify that the File() global function and environment method work
+correctly, and that the former does not try to expand construction
+variables.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(FOO = 'fff', BAR = 'bbb')
+print File('ddd')
+print File('$FOO')
+print File('${BAR}_$BAR')
+print env.File('eee')
+print env.File('$FOO')
+print env.File('${BAR}_$BAR')
+""")
+
+test.run(stdout = test.wrap_stdout(read_str = """\
+ddd
+$FOO
+${BAR}_$BAR
+eee
+fff
+bbb_bbb
+""", build_str = """\
+scons: `.' is up to date.
+"""))
+
+test.pass_test()
diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py
index 14a7c54..5f2e6b8 100644
--- a/test/Repository/SConscript.py
+++ b/test/Repository/SConscript.py
@@ -90,7 +90,8 @@ test.up_to_date(chdir = 'work', arguments = ".")
#
test.write(['rep2', 'build', 'SConstruct'], """
-Repository(r'%s')
+env = Environment(REPOSITORY = r'%s')
+env.Repository('$REPOSITORY')
SConscript('src/SConscript')
""" % workpath_rep2)
diff --git a/test/SConsignFile.py b/test/SConsignFile.py
index 29f2af2..606f20b 100644
--- a/test/SConsignFile.py
+++ b/test/SConsignFile.py
@@ -77,7 +77,8 @@ test.fail_test(os.path.exists(test.workpath('work1', 'subdir', '.sconsign')))
#
test.write(['work2', 'SConstruct'], """
-SConsignFile('my_sconsign')
+e = Environment(XXX = 'scons')
+e.SConsignFile('my_${XXX}ign')
B = Builder(action = "%s ../build.py $TARGETS $SOURCES")
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'f5.out', source = 'f5.in')
diff --git a/test/option--C.py b/test/option--C.py
index c889602..0a11688 100644
--- a/test/option--C.py
+++ b/test/option--C.py
@@ -47,6 +47,7 @@ test = TestSCons.TestSCons(match=match_normcase)
wpath = test.workpath()
wpath_sub = test.workpath('sub')
wpath_sub_dir = test.workpath('sub', 'dir')
+wpath_sub_foo_bar = test.workpath('sub', 'foo', 'bar')
test.subdir('sub', ['sub', 'dir'])
@@ -62,7 +63,8 @@ print GetBuildPath('..')
test.write(['sub', 'dir', 'SConstruct'], """
import os
-print GetBuildPath('..')
+env = Environment(FOO='foo', BAR='bar')
+print env.GetBuildPath('../$FOO/$BAR')
""")
test.run(arguments = '-C sub .',
@@ -70,7 +72,7 @@ test.run(arguments = '-C sub .',
build_str = "scons: `.' is up to date.\n"))
test.run(arguments = '-C sub -C dir .',
- stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub,
+ stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
build_str = "scons: `.' is up to date.\n"))
test.run(arguments = ".",
@@ -78,7 +80,7 @@ test.run(arguments = ".",
build_str = "scons: `.' is up to date.\n"))
test.run(arguments = '--directory=sub/dir .',
- stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub,
+ stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
build_str = "scons: `.' is up to date.\n"))
test.run(arguments = '-C %s -C %s .' % (wpath_sub_dir, wpath_sub),
@@ -86,4 +88,3 @@ test.run(arguments = '-C %s -C %s .' % (wpath_sub_dir, wpath_sub),
build_str = "scons: `.' is up to date.\n"))
test.pass_test()
-