projects/guix·blob java-team · refs

57 lines · 2.4 KiB

1Inherit essential environment variables in tests.
2
3Note: it could be better to generalize this in SCons/Platform/posix.py
4instead of just patching the tests.
5
6diff --git a/SCons/ActionTests.py b/SCons/ActionTests.py
7--- a/SCons/ActionTests.py
8+++ b/SCons/ActionTests.py
9@@ -98,6 +98,7 @@ outfile2 = test.workpath('outfile2')
10 pipe_file = test.workpath('pipe.out')
11
12 scons_env = SCons.Environment.Environment()
13+scons_env['ENV']['PATH'] += os.environ['PATH']
14
15 # Capture all the stuff the Actions will print,
16 # so it doesn't clutter the output.
17@@ -1090,6 +1091,8 @@ class CommandActionTestCase(unittest.TestCase):
18 except AttributeError:
19 env = Environment()
20
21+ env = Environment(ENV={'PATH': os.environ['PATH']})
22+
23 cmd1 = r'%s %s %s xyzzy' % (_python_, act_py, outfile)
24
25 act = SCons.Action.CommandAction(cmd1)
26@@ -1884,7 +1887,7 @@ class ListActionTestCase(unittest.TestCase):
27 f.write("class2b\n")
28
29 act = SCons.Action.ListAction([cmd2, function2, class2a(), class2b])
30- r = act([], [], Environment(out=outfile))
31+ r = act([], [], Environment(out=outfile, ENV={'PATH' : os.getenv('PATH')}))
32 assert isinstance(r.status, class2b), r.status
33 c = test.read(outfile, 'r')
34 assert c == "act.py: 'syzygy'\nfunction2\nclass2a\nclass2b\n", c
35@@ -1948,7 +1951,7 @@ class LazyActionTestCase(unittest.TestCase):
36 a([], [], env=Environment(BAR=f, s=self))
37 assert self.test == 1, self.test
38 cmd = r'%s %s %s lazy' % (_python_, act_py, outfile)
39- a([], [], env=Environment(BAR=cmd, s=self))
40+ a([], [], env=Environment(BAR=cmd, s=self, ENV={'PATH' : os.getenv('PATH')}))
41 c = test.read(outfile, 'r')
42 assert c == "act.py: 'lazy'\n", c
43
44diff --git a/SCons/SConfTests.py b/SCons/SConfTests.py
45--- a/SCons/SConfTests.py
46+++ b/SCons/SConfTests.py
47@@ -71,7 +71,9 @@ class SConfTestCase(unittest.TestCase):
48 # and we need a new environment, cause references may point to
49 # old modules (well, at least this is safe ...)
50 self.scons_env = self.Environment.Environment()
51- self.scons_env.AppendENVPath('PATH', os.environ['PATH'])
52+ # Inherit the OS environment to get essential variables.
53+ inherited_env = os.environ.copy()
54+ self.scons_env['ENV'] = inherited_env
55
56 # we want to do some autodetection here
57 # this stuff works with