diff options
| author | Steven Knight <knight@baldmt.com> | 2003-09-08 04:01:32 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2003-09-08 04:01:32 (GMT) |
| commit | 68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9 (patch) | |
| tree | 910dcf1998d6b72aa8eb4bdb5497177d331ea900 /src/engine/SCons/EnvironmentTests.py | |
| parent | 61d018dfceac6cb9717caeeea7125d7a55b4b0eb (diff) | |
| download | SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.zip SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.tar.gz SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.tar.bz2 | |
Give the global functions corresponding Environment methods.
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
| -rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index d3807f5..db05351 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -957,6 +957,18 @@ class EnvironmentTestCase(unittest.TestCase): assert(env1['ENV']['PATH'] == r'C:\dir\num\three;C:\dir\num\two;C:\dir\num\one') assert(env1['MYENV']['MYPATH'] == r'C:\mydir\num\one;C:\mydir\num\three;C:\mydir\num\two') + def test_PrependENVPath(self): + """Test prepending to an ENV path.""" + env1 = Environment(ENV = {'PATH': r'C:\dir\num\one;C:\dir\num\two'}, + MYENV = {'MYPATH': r'C:\mydir\num\one;C:\mydir\num\two'}) + # have to include the pathsep here so that the test will work on UNIX too. + env1.PrependENVPath('PATH',r'C:\dir\num\two',sep = ';') + env1.PrependENVPath('PATH',r'C:\dir\num\three',sep = ';') + env1.PrependENVPath('MYPATH',r'C:\mydir\num\three','MYENV',sep = ';') + env1.PrependENVPath('MYPATH',r'C:\mydir\num\one','MYENV',sep = ';') + assert(env1['ENV']['PATH'] == r'C:\dir\num\three;C:\dir\num\two;C:\dir\num\one') + assert(env1['MYENV']['MYPATH'] == r'C:\mydir\num\one;C:\mydir\num\three;C:\mydir\num\two') + def test_Replace(self): """Test replacing construction variables in an Environment @@ -997,6 +1009,28 @@ class EnvironmentTestCase(unittest.TestCase): + def test_AddPostAction(self): + """Test the AddPostAction() method""" + env = Environment(FOO='fff', BAR='bbb') + + n = env.AddPostAction('$FOO', lambda x: x) + assert str(n[0]) == 'fff', n[0] + + n = env.AddPostAction(['ggg', '$BAR'], lambda x: x) + assert str(n[0]) == 'ggg', n[0] + assert str(n[1]) == 'bbb', n[1] + + def test_AddPreAction(self): + """Test the AddPreAction() method""" + env = Environment(FOO='fff', BAR='bbb') + + n = env.AddPreAction('$FOO', lambda x: x) + assert str(n[0]) == 'fff', n[0] + + n = env.AddPreAction(['ggg', '$BAR'], lambda x: x) + assert str(n[0]) == 'ggg', n[0] + assert str(n[1]) == 'bbb', n[1] + def test_AlwaysBuild(self): """Test the AlwaysBuild() method""" env = Environment(FOO='fff', BAR='bbb') @@ -1045,6 +1079,25 @@ class EnvironmentTestCase(unittest.TestCase): assert 'foo1.in' in map(lambda x: x.path, t.sources) assert 'foo2.in' in map(lambda x: x.path, t.sources) + def test_Default(self): + """Test the Default() method""" + env = Environment(FOO = 'fff', BAR = 'bbb') + + t = env.Default(None) + assert SCons.Environment.DefaultTargets == [] + + t = env.Default('xyz') + d = map(str, SCons.Environment.DefaultTargets) + assert d == ['xyz'], d + + t = env.Default('$FOO') + d = map(str, SCons.Environment.DefaultTargets) + assert d == ['xyz', 'fff'], d + + t = env.Default(None, '$BAR', 'another_file') + d = map(str, SCons.Environment.DefaultTargets) + assert d == ['bbb', 'another_file'], d + def test_Depends(self): """Test the explicit Depends method.""" env = Environment(FOO = 'xxx', BAR='yyy') @@ -1064,6 +1117,15 @@ class EnvironmentTestCase(unittest.TestCase): assert d.__class__.__name__ == 'File' assert d.path == 'yyy.py' + def test_FindFile(self): + """Test the FindFile() method""" + env = Environment(FOO = 'fff', BAR = 'bbb') + + r = env.FindFile('foo', ['no_such_directory']) + assert r is None, r + + # XXX + def test_Ignore(self): """Test the explicit Ignore method.""" env = Environment(FOO='yyy', BAR='zzz') @@ -1083,7 +1145,7 @@ class EnvironmentTestCase(unittest.TestCase): assert i.path == 'zzzyyy' def test_Install(self): - """Test Install and InstallAs methods""" + """Test the Install method""" env = Environment(FOO='iii', BAR='jjj') tgt = env.Install('export', [ 'build/foo1', 'build/foo2' ]) @@ -1129,6 +1191,10 @@ class EnvironmentTestCase(unittest.TestCase): match = str(e) == "Target `export/foo1' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" assert match, e + def test_InstallAs(self): + """Test the InstallAs method""" + env = Environment(FOO='iii', BAR='jjj') + tgt = env.InstallAs(target=string.split('foo1 foo2'), source=string.split('bar1 bar2')) assert len(tgt) == 2, len(tgt) @@ -1144,6 +1210,17 @@ class EnvironmentTestCase(unittest.TestCase): assert tgt.sources[0].path == 'jjj.s' assert tgt.builder == InstallBuilder + def test_Local(self): + """Test the Local() method.""" + env = Environment(FOO='lll') + + l = env.Local(env.fs.File('fff')) + assert str(l[0]) == 'fff', l[0] + + l = env.Local('ggg', '$FOO') + assert str(l[0]) == 'ggg', l[0] + assert str(l[1]) == 'lll', l[1] + def test_Precious(self): """Test the Precious() method.""" env = Environment(FOO='ggg', BAR='hhh') @@ -1207,7 +1284,7 @@ class EnvironmentTestCase(unittest.TestCase): s = e.src_builder() assert s is None, s - + if __name__ == "__main__": suite = unittest.makeSuite(EnvironmentTestCase, 'test_') if not unittest.TextTestRunner().run(suite).wasSuccessful(): |
