summaryrefslogtreecommitdiffstats
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
parent1c2ac0f2ca0c14d1181add9cc66d9650fece1481 (diff)
downloadSCons-3ab7670a45179b7a09eabc219842f6c224ad35da.zip
SCons-3ab7670a45179b7a09eabc219842f6c224ad35da.tar.gz
SCons-3ab7670a45179b7a09eabc219842f6c224ad35da.tar.bz2
Make more Environment methods from global functions.
-rw-r--r--doc/man/scons.120
-rw-r--r--src/CHANGES.txt7
-rw-r--r--src/engine/SCons/Environment.py34
-rw-r--r--src/engine/SCons/EnvironmentTests.py136
-rw-r--r--src/engine/SCons/Script/SConscript.py79
-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
12 files changed, 370 insertions, 45 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 696f38b..be966a2 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -1886,6 +1886,8 @@ env.SourceCode('.', env.BitKeeper())
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI BuildDir( build_dir ", " src_dir ", [" duplicate ])
+.TP
+.RI env.BuildDir( build_dir ", " src_dir ", [" duplicate ])
This specifies a build directory
.I build_dir
in which to build all derived files
@@ -1979,6 +1981,8 @@ SConscript file.)
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI CacheDir( cache_dir )
+.TP
+.RI env.CacheDir( cache_dir )
Specifies that
.B scons
will maintain a cache of derived files in
@@ -2266,6 +2270,8 @@ cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI Dir( name ", [" directory ])
+.TP
+.RI env.Dir( name ", [" directory ])
This returns an object that represents a given directory
.IR name .
.I name
@@ -2360,6 +2366,8 @@ function, below.
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI File( name ", [" directory ])
+.TP
+.RI env.File( name ", [" directory ])
This returns an object that represents a given file
.IR name .
.I name
@@ -2386,9 +2394,11 @@ foo = env.FindFile('foo', ['dir1', 'dir2'])
.EE
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\".TP
-.\".RI GetBuildPath( XXX )
-.\"XXX
+.TP
+.RI GetBuildPath( XXX )
+.TP
+.RI env.GetBuildPath( XXX )
+XXX
.\"
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.\".TP
@@ -2702,6 +2712,8 @@ env.Replace(CCFLAGS = '-g', FOO = 'foo.xxx')
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI Repository( directory )
+.TP
+.RI env.Repository( directory )
Specifies that
.I directory
is a repository to be searched for files.
@@ -2951,6 +2963,8 @@ SConscript('bar/SConscript') # will chdir to bar
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI SConsignFile([ file ])
+.TP
+.RI env.SConsignFile([ file ])
This tells
.B scons
to store all file signatures
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 7e6b70f..9961c47 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -43,9 +43,10 @@ RELEASE X.XX - XXX
- Support arbitrary expansion of construction variables within
file and directory arguments to Builder calls and Environment methods.
- - Add Environment-method versions of the following global function:
- AddPreAction(), AddPostAction(), Clean(), Default(), FindFile(),
- Local(), SourceSignatures(), TargetSignatures().
+ - Add Environment-method versions of the following global functions:
+ AddPreAction(), AddPostAction(), BuildDir(), CacheDir(), Clean(),
+ Default(), FindFile(), GetBuildPath(), Local(), Repository(),
+ SConsignFile(), SourceSignatures(), TargetSignatures().
- Add the following global functions that correspond to the same-named
Environment methods: AlwaysBuild(), Command(), Depends(), Ignore(),
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 3d00837..2e95d81 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -636,6 +636,14 @@ class Environment:
tlist = tlist[0]
return tlist
+ def BuildDir(self, build_dir, src_dir, duplicate=1):
+ build_dir = self.arg2nodes(build_dir, self.fs.Dir)[0]
+ src_dir = self.arg2nodes(src_dir, self.fs.Dir)[0]
+ self.fs.BuildDir(build_dir, src_dir, duplicate)
+
+ def CacheDir(self, path):
+ self.fs.CacheDir(self.subst(path))
+
def Clean(self, target, files):
global CleanTargets
@@ -690,11 +698,27 @@ class Environment:
tlist = tlist[0]
return tlist
+ def Dir(self, name, *args, **kw):
+ """
+ """
+ return apply(self.fs.Dir, (self.subst(name),) + args, kw)
+
+ def File(self, name, *args, **kw):
+ """
+ """
+ return apply(self.fs.File, (self.subst(name),) + args, kw)
+
def FindFile(self, file, dirs):
file = self.subst(file)
nodes = self.arg2nodes(dirs, self.fs.Dir)
return SCons.Node.FS.find_file(file, nodes, self.fs.File)
+ def GetBuildPath(self, files):
+ ret = map(str, self.arg2nodes(files, self.fs.Entry))
+ if len(ret) == 1:
+ return ret[0]
+ return ret
+
def Ignore(self, target, dependency):
"""Ignore a dependency."""
tlist = self.arg2nodes(target, self.fs.File)
@@ -763,6 +787,16 @@ class Environment:
tlist = tlist[0]
return tlist
+ def Repository(self, *dirs, **kw):
+ dirs = self.arg2nodes(list(dirs), self.fs.Dir)
+ apply(self.fs.Repository, dirs, kw)
+
+ def SConsignFile(self, name=".sconsign.dbm"):
+ name = self.subst(name)
+ if not os.path.isabs(name):
+ name = os.path.join(str(self.fs.SConstruct_dir), name)
+ SCons.Sig.SConsignFile(name)
+
def SideEffect(self, side_effect, target):
"""Tell scons that side_effects are built as side
effects of building targets."""
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index baf501e..aa5dbac 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1051,6 +1051,44 @@ class EnvironmentTestCase(unittest.TestCase):
assert t[4].path == 'bbb'
assert t[4].always_build
+ def test_BuildDir(self):
+ """Test the BuildDir() method"""
+ class MyFS:
+ def Dir(self, name):
+ return name
+ def BuildDir(self, build_dir, src_dir, duplicate):
+ self.build_dir = build_dir
+ self.src_dir = src_dir
+ self.duplicate = duplicate
+
+ env = Environment(FOO = 'fff', BAR = 'bbb')
+ env.fs = MyFS()
+
+ env.BuildDir('build', 'src')
+ assert env.fs.build_dir == 'build', env.fs.build_dir
+ assert env.fs.src_dir == 'src', env.fs.src_dir
+ assert env.fs.duplicate == 1, env.fs.duplicate
+
+ env.BuildDir('build${FOO}', '${BAR}src', 0)
+ assert env.fs.build_dir == 'buildfff', env.fs.build_dir
+ assert env.fs.src_dir == 'bbbsrc', env.fs.src_dir
+ assert env.fs.duplicate == 0, env.fs.duplicate
+
+ def test_CacheDir(self):
+ """Test the CacheDir() method"""
+ class MyFS:
+ def CacheDir(self, path):
+ self.CD = path
+
+ env = Environment(CD = 'CacheDir')
+ env.fs = MyFS()
+
+ env.CacheDir('foo')
+ assert env.fs.CD == 'foo', env.fs.CD
+
+ env.CacheDir('$CD')
+ assert env.fs.CD == 'CacheDir', env.fs.CD
+
def test_Clean(self):
"""Test the Clean() method"""
env = Environment(FOO = 'fff', BAR = 'bbb')
@@ -1143,6 +1181,42 @@ class EnvironmentTestCase(unittest.TestCase):
assert d.__class__.__name__ == 'File'
assert d.path == 'yyy.py'
+ def test_Dir(self):
+ """Test the Dir() method"""
+ class MyFS:
+ def Dir(self, name):
+ return 'Dir(%s)' % name
+
+ env = Environment(FOO = 'foodir', BAR = 'bardir')
+ env.fs = MyFS()
+
+ d = env.Dir('d')
+ assert d == 'Dir(d)', d
+
+ d = env.Dir('$FOO')
+ assert d == 'Dir(foodir)', d
+
+ d = env.Dir('${BAR}_$BAR')
+ assert d == 'Dir(bardir_bardir)', d
+
+ def test_File(self):
+ """Test the File() method"""
+ class MyFS:
+ def File(self, name):
+ return 'File(%s)' % name
+
+ env = Environment(FOO = 'foofile', BAR = 'barfile')
+ env.fs = MyFS()
+
+ f = env.File('f')
+ assert f == 'File(f)', f
+
+ f = env.File('$FOO')
+ assert f == 'File(foofile)', f
+
+ f = env.File('${BAR}_$BAR')
+ assert f == 'File(barfile_barfile)', f
+
def test_FindFile(self):
"""Test the FindFile() method"""
env = Environment(FOO = 'fff', BAR = 'bbb')
@@ -1152,6 +1226,16 @@ class EnvironmentTestCase(unittest.TestCase):
# XXX
+ def test_GetBuildPath(self):
+ """Test the GetBuildPath() method."""
+ env = Environment(MAGIC = 'xyzzy')
+
+ p = env.GetBuildPath('foo')
+ assert p == 'foo', p
+
+ p = env.GetBuildPath('$MAGIC')
+ assert p == 'xyzzy', p
+
def test_Ignore(self):
"""Test the explicit Ignore method."""
env = Environment(FOO='yyy', BAR='zzz')
@@ -1267,6 +1351,58 @@ class EnvironmentTestCase(unittest.TestCase):
assert t[4].path == 'ggg'
assert t[4].precious
+ def test_Repository(self):
+ """Test the Repository() method."""
+ class MyFS:
+ def __init__(self):
+ self.list = []
+ def Repository(self, *dirs):
+ self.list.extend(dirs)
+ def Dir(self, name):
+ return name
+ env = Environment(FOO='rrr', BAR='sss')
+ env.fs = MyFS()
+ env.Repository('/tmp/foo')
+ env.Repository('/tmp/$FOO', '/tmp/$BAR/foo')
+ expect = ['/tmp/foo', '/tmp/rrr', '/tmp/sss/foo']
+ assert env.fs.list == expect, env.fs.list
+
+ def test_SConsignFile(self):
+ """Test the SConsignFile() method"""
+ import SCons.Sig
+
+ class MyFS:
+ SConstruct_dir = '/dir'
+
+ env = Environment(FOO = 'SConsign',
+ BAR = os.path.join(os.sep, 'File'))
+ env.fs = MyFS()
+
+ try:
+ save = []
+ def capture(name, save=save):
+ save.append(name)
+
+ save_Sig_SConsignFile = SCons.Sig.SConsignFile
+ SCons.Sig.SConsignFile = capture
+
+ env.SConsignFile('foo')
+ assert save[0] == os.path.join(os.sep, 'dir', 'foo'), save
+
+ env.SConsignFile('$FOO')
+ assert save[1] == os.path.join(os.sep, 'dir', 'SConsign'), save
+
+ env.SConsignFile('/$FOO')
+ assert save[2] == '/SConsign', save
+
+ env.SConsignFile('$BAR')
+ assert save[3] == os.path.join(os.sep, 'File'), save
+
+ env.SConsignFile('__$BAR')
+ assert save[4] == os.path.join(os.sep, 'dir', '__', 'File'), save
+ finally:
+ SCons.Sig.SConsignFile = save_Sig_SConsignFile
+
def test_SideEffect(self):
"""Test the SideEffect() method"""
env = Environment(LIB='lll', FOO='fff', BAR='bbb')
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 4f29f26..8614235 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -30,12 +30,14 @@ files.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import SCons
import SCons.Action
import SCons.Builder
import SCons.Defaults
import SCons.Environment
import SCons.Errors
import SCons.Node
+import SCons.Node.Alias
import SCons.Node.FS
import SCons.Node.Python
import SCons.Platform
@@ -43,8 +45,6 @@ import SCons.SConf
import SCons.Script
import SCons.Util
import SCons.Options
-import SCons
-import SCons.Node.Alias
import os
import os.path
@@ -52,6 +52,7 @@ import re
import string
import sys
import traceback
+import types
def do_nothing(text): pass
HelpFunction = do_nothing
@@ -206,7 +207,7 @@ def GetSConscriptFilenames(ls, kw):
else:
# Fast way to only get the terminal path component of a Node.
fname = fn.get_path(fn.dir)
- BuildDir(build_dir, src_dir, duplicate)
+ SCons.Node.FS.default_fs.BuildDir(build_dir, src_dir, duplicate)
files = [os.path.join(str(build_dir), fname)]
return (files, exports)
@@ -357,16 +358,6 @@ def annotate(node):
def Help(text):
HelpFunction(text)
-def BuildDir(build_dir, src_dir, duplicate=1):
- SCons.Node.FS.default_fs.BuildDir(build_dir, src_dir, duplicate)
-
-def GetBuildPath(files):
- nodes = SCons.Node.arg2nodes(files, SCons.Node.FS.default_fs.Entry)
- ret = map(str, nodes)
- if len(ret) == 1:
- return ret[0]
- return ret
-
def Export(*vars):
for var in vars:
global_exports.update(compute_exports(var))
@@ -462,12 +453,33 @@ def SetOption(name, value):
def GetOption(name):
return SCons.Script.ssoptions.get(name)
-def SConsignFile(name=".sconsign.dbm"):
- import SCons.Sig
- if not os.path.isabs(name):
- sd = str(SCons.Node.FS.default_fs.SConstruct_dir)
- name = os.path.join(sd, name)
- SCons.Sig.SConsignFile(name)
+#
+_DefaultEnvironmentProxy = None
+
+def get_DefaultEnvironmentProxy():
+ global _DefaultEnvironmentProxy
+ if not _DefaultEnvironmentProxy:
+ class EnvironmentProxy(SCons.Environment.Environment):
+ """A proxy subclass for an environment instance that overrides
+ the subst() and subst_list() methods so they don't actually
+ actually perform construction variable substitution. This is
+ specifically intended to be the shim layer in between global
+ function calls (which don't want want construction variable
+ substitution) and the DefaultEnvironment() (which would
+ substitute variables if left to its own devices)."""
+ def __init__(self, subject):
+ self.__dict__['__subject'] = subject
+ def __getattr__(self, name):
+ return getattr(self.__dict__['__subject'], name)
+ def __setattr__(self, name, value):
+ return setattr(self.__dict__['__subject'], name, value)
+ def subst(self, string, raw=0, target=None, source=None):
+ return string
+ def subst_list(self, string, raw=0, target=None, source=None):
+ return string
+ default_env = SCons.Defaults.DefaultEnvironment()
+ _DefaultEnvironmentProxy = EnvironmentProxy(default_env)
+ return _DefaultEnvironmentProxy
def BuildDefaultGlobals():
"""
@@ -479,20 +491,15 @@ def BuildDefaultGlobals():
globals['Action'] = SCons.Action.Action
globals['Alias'] = Alias
globals['ARGUMENTS'] = arguments
- globals['BuildDir'] = BuildDir
globals['Builder'] = SCons.Builder.Builder
- globals['CacheDir'] = SCons.Node.FS.default_fs.CacheDir
globals['Configure'] = SCons.SConf.SConf
globals['CScan'] = SCons.Defaults.CScan
globals['DefaultEnvironment'] = SCons.Defaults.DefaultEnvironment
- globals['Dir'] = SCons.Node.FS.default_fs.Dir
globals['EnsurePythonVersion'] = EnsurePythonVersion
globals['EnsureSConsVersion'] = EnsureSConsVersion
globals['Environment'] = SCons.Environment.Environment
globals['Exit'] = Exit
globals['Export'] = Export
- globals['File'] = SCons.Node.FS.default_fs.File
- globals['GetBuildPath'] = GetBuildPath
globals['GetCommandHandler'] = SCons.Action.GetCommandHandler
globals['GetJobs'] = GetJobs
globals['GetLaunchDir'] = GetLaunchDir
@@ -503,11 +510,9 @@ def BuildDefaultGlobals():
globals['Options'] = Options
globals['ParseConfig'] = SCons.Util.ParseConfig
globals['Platform'] = SCons.Platform.Platform
- globals['Repository'] = SCons.Node.FS.default_fs.Repository
globals['Return'] = Return
globals['SConscript'] = SConscript
globals['SConscriptChdir'] = SConscriptChdir
- globals['SConsignFile'] = SConsignFile
globals['Scanner'] = SCons.Scanner.Base
globals['SetBuildSignatureType'] = SetBuildSignatureType
globals['SetCommandHandler'] = SCons.Action.SetCommandHandler
@@ -520,28 +525,42 @@ def BuildDefaultGlobals():
globals['WhereIs'] = SCons.Util.WhereIs
class DefaultEnvironmentCall:
- """ """
+ """A class that implements "global function" calls of
+ Environment methods by fetching the specified method from the
+ DefaultEnvironment's class. Note that this uses an intermediate
+ proxy class instead of calling the DefaultEnvironment method
+ directly so that the proxy can override the subst() method and
+ thereby prevent expansion of construction variables (since from
+ the user's point of view this was called as a global function,
+ with no associated construction environment)."""
def __init__(self, method_name):
self.method_name = method_name
def __call__(self, *args, **kw):
- method = getattr(SCons.Defaults.DefaultEnvironment(),
- self.method_name)
- return apply(method, args, kw)
+ proxy = get_DefaultEnvironmentProxy()
+ method = getattr(proxy.__class__, self.method_name)
+ return apply(method, (proxy,) + args, kw)
EnvironmentMethods = [
'AddPostAction',
'AddPreAction',
'AlwaysBuild',
+ 'BuildDir',
+ 'CacheDir',
'Clean',
'Command',
'Default',
'Depends',
+ 'Dir',
+ 'File',
'FindFile',
+ 'GetBuildPath',
'Ignore',
'Install',
'InstallAs',
'Local',
'Precious',
+ 'Repository',
+ 'SConsignFile',
'SideEffect',
'SourceCode',
'SourceSignatures',
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()
-