diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-23 16:54:06 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-23 16:54:06 +0200 | 
| commit | efdf3fdbcd2f7654cb8d1209a8b040914437bacd (patch) | |
| tree | 19f68a3e29675ad73f57f7c639a044290660782f /src/engine/SCons/EnvironmentTests.py | |
| parent | 697e33ed224b539a42ff68121f7497f5bbf941b2 (diff) | |
New upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
| -rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 83 | 
1 files changed, 51 insertions, 32 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index b97ac5c..1ce1007 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -23,7 +23,7 @@  from __future__ import print_function -__revision__ = "src/engine/SCons/EnvironmentTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog" +__revision__ = "src/engine/SCons/EnvironmentTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"  import SCons.compat @@ -74,7 +74,7 @@ def diff_dict(d1, d2):                     s2 = s2 + "    " + repr(k) + " : " + repr(d2[k]) + "\n"             else:                 s1 = s1 + "    " + repr(k) + " : " + repr(d1[k]) + "\n" -        elif k in env2: +        elif k in d2:             s2 = s2 + "    " + repr(k) + " : " + repr(d2[k]) + "\n"      s1 = s1 + "}\n"      s2 = s2 + "}\n" @@ -263,39 +263,39 @@ class SubstitutionTestCase(unittest.TestCase):          nodes = env.arg2nodes("Util.py UtilTests.py", Factory)          assert len(nodes) == 1, nodes          assert isinstance(nodes[0], X) -        assert nodes[0].name == "Util.py UtilTests.py" +        assert nodes[0].name == "Util.py UtilTests.py", nodes[0].name          nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory)          assert len(nodes) == 1, nodes          assert isinstance(nodes[0], X) -        assert nodes[0].name == u"Util.py UtilTests.py" +        assert nodes[0].name == u"Util.py UtilTests.py", nodes[0].name          nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory)          assert len(nodes) == 2, nodes          assert isinstance(nodes[0], X)          assert isinstance(nodes[1], X) -        assert nodes[0].name == "Util.py" -        assert nodes[1].name == "UtilTests.py" +        assert nodes[0].name == "Util.py", nodes[0].name +        assert nodes[1].name == "UtilTests.py", nodes[1].name          n1 = Factory("Util.py")          nodes = env.arg2nodes([n1, "UtilTests.py"], Factory)          assert len(nodes) == 2, nodes          assert isinstance(nodes[0], X)          assert isinstance(nodes[1], X) -        assert nodes[0].name == "Util.py" -        assert nodes[1].name == "UtilTests.py" +        assert nodes[0].name == "Util.py", nodes[0].name +        assert nodes[1].name == "UtilTests.py", nodes[1].name          class SConsNode(SCons.Node.Node):              pass          nodes = env.arg2nodes(SConsNode())          assert len(nodes) == 1, nodes -        assert isinstance(nodes[0], SConsNode), node +        assert isinstance(nodes[0], SConsNode), nodes[0]          class OtherNode(object):              pass          nodes = env.arg2nodes(OtherNode())          assert len(nodes) == 1, nodes -        assert isinstance(nodes[0], OtherNode), node +        assert isinstance(nodes[0], OtherNode), nodes[0]          def lookup_a(str, F=Factory):              if str[0] == 'a': @@ -484,7 +484,7 @@ class SubstitutionTestCase(unittest.TestCase):          env = SubstitutionEnvironment(AAA = '$BBB', BBB = '$CCC', CCC = 'c')          l = env.subst_list("$AAA ${AAA}A ${AAA}B $BBB") -        assert l == [["c", "cA", "cB", "c"]], mystr +        assert l == [["c", "cA", "cB", "c"]], l          env = SubstitutionEnvironment(AAA = '$BBB', BBB = '$CCC', CCC = [ 'a', 'b\nc' ])          lst = env.subst_list([ "$AAA", "B $CCC" ]) @@ -800,7 +800,9 @@ sys.exit(0)              "-fopenmp " + \              "-mno-cygwin -mwindows " + \              "-arch i386 -isysroot /tmp " + \ -            "-isystem /usr/include/foo " + \ +            "-iquote /usr/include/foo1 " + \ +            "-isystem /usr/include/foo2 " + \ +            "-idirafter /usr/include/foo3 " + \              "+DD64 " + \              "-DFOO -DBAR=value -D BAZ " @@ -809,10 +811,12 @@ sys.exit(0)          assert d['ASFLAGS'] == ['-as'], d['ASFLAGS']          assert d['CFLAGS']  == ['-std=c99']          assert d['CCFLAGS'] == ['-X', '-Wa,-as', -                                  '-pthread', '-fopenmp', '-mno-cygwin', -                                  ('-arch', 'i386'), ('-isysroot', '/tmp'), -                                  ('-isystem', '/usr/include/foo'), -                                  '+DD64'], repr(d['CCFLAGS']) +                                '-pthread', '-fopenmp', '-mno-cygwin', +                                ('-arch', 'i386'), ('-isysroot', '/tmp'), +                                ('-iquote', '/usr/include/foo1'), +                                ('-isystem', '/usr/include/foo2'), +                                ('-idirafter', '/usr/include/foo3'), +                                '+DD64'], repr(d['CCFLAGS'])          assert d['CXXFLAGS'] == ['-std=c++0x'], repr(d['CXXFLAGS'])          assert d['CPPDEFINES'] == ['FOO', ['BAR', 'value'], 'BAZ'], d['CPPDEFINES']          assert d['CPPFLAGS'] == ['-Wp,-cpp'], d['CPPFLAGS'] @@ -1195,7 +1199,7 @@ env4.builder1.env, env3)          test_it('foo.bar')          test_it('foo-bar') -    def test_autogenerate(dict): +    def test_autogenerate(self):          """Test autogenerating variables in a dictionary."""          drive, p = os.path.splitdrive(os.getcwd()) @@ -1206,9 +1210,9 @@ env4.builder1.env, env3)              drive, path = os.path.splitdrive(path)              return drive.lower() + path -        env = dict.TestEnvironment(LIBS = [ 'foo', 'bar', 'baz' ], -                          LIBLINKPREFIX = 'foo', -                          LIBLINKSUFFIX = 'bar') +        env = self.TestEnvironment(LIBS = [ 'foo', 'bar', 'baz' ], +                                   LIBLINKPREFIX = 'foo', +                                   LIBLINKSUFFIX = 'bar')          def RDirs(pathlist, fs=env.fs):              return fs.Dir('xx').Rfindalldirs(pathlist) @@ -2022,7 +2026,9 @@ def generate(env):                                   "-pthread " + \                                   "-mno-cygwin -mwindows " + \                                   "-arch i386 -isysroot /tmp " + \ -                                 "-isystem /usr/include/foo " + \ +                                 "-iquote /usr/include/foo1 " + \ +                                 "-isystem /usr/include/foo2 " + \ +                                 "-idirafter /usr/include/foo3 " + \                                   "+DD64 " + \                                   "-DFOO -DBAR=value")              env.ParseConfig("fake $COMMAND") @@ -2031,7 +2037,9 @@ def generate(env):              assert env['CCFLAGS'] == ['', '-X', '-Wa,-as',                                        '-pthread', '-mno-cygwin',                                        ('-arch', 'i386'), ('-isysroot', '/tmp'), -                                      ('-isystem', '/usr/include/foo'), +                                      ('-iquote', '/usr/include/foo1'), +                                      ('-isystem', '/usr/include/foo2'), +                                      ('-idirafter', '/usr/include/foo3'),                                        '+DD64'], env['CCFLAGS']              assert env['CPPDEFINES'] == ['FOO', ['BAR', 'value']], env['CPPDEFINES']              assert env['CPPFLAGS'] == ['', '-Wp,-cpp'], env['CPPFLAGS'] @@ -2433,16 +2441,16 @@ f5: \          exc_caught = None          try:              env.Tool('does_not_exist') -        except SCons.Errors.EnvironmentError: +        except SCons.Errors.SConsEnvironmentError:              exc_caught = 1 -        assert exc_caught, "did not catch expected EnvironmentError" +        assert exc_caught, "did not catch expected SConsEnvironmentError"          exc_caught = None          try:              env.Tool('$NONE') -        except SCons.Errors.EnvironmentError: +        except SCons.Errors.SConsEnvironmentError:              exc_caught = 1 -        assert exc_caught, "did not catch expected EnvironmentError" +        assert exc_caught, "did not catch expected SConsEnvironmentError"          # Use a non-existent toolpath directory just to make sure we          # can call Tool() with the keyword argument. @@ -3272,11 +3280,11 @@ def generate(env):          s = e.src_builder()          assert s is None, s -    def test_SourceSignatures(type): +    def test_SourceSignatures(self):          """Test the SourceSignatures() method"""          import SCons.Errors -        env = type.TestEnvironment(M = 'MD5', T = 'timestamp') +        env = self.TestEnvironment(M = 'MD5', T = 'timestamp')          exc_caught = None          try: @@ -3312,7 +3320,7 @@ def generate(env):      def test_Split(self):          """Test the Split() method""" -        env = self.TestEnvironment(FOO='fff', BAR='bbb') +        env = self.TestEnvironment(FOO = 'fff', BAR = 'bbb')          s = env.Split("foo bar")          assert s == ["foo", "bar"], s          s = env.Split("$FOO bar") @@ -3326,11 +3334,11 @@ def generate(env):          s = env.Split("$FOO$BAR")          assert s == ["fffbbb"], s -    def test_TargetSignatures(type): +    def test_TargetSignatures(self):          """Test the TargetSignatures() method"""          import SCons.Errors -        env = type.TestEnvironment(B = 'build', C = 'content') +        env = self.TestEnvironment(B='build', C='content')          exc_caught = None          try: @@ -3397,7 +3405,7 @@ def generate(env): -    def test_Environment_global_variable(type): +    def test_Environment_global_variable(self):          """Test setting Environment variable to an Environment.Base subclass"""          class MyEnv(SCons.Environment.Base):              def xxx(self, string): @@ -3579,6 +3587,10 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):      def setUp(self):          env = Environment()          env._dict = {'XXX' : 'x', 'YYY' : 'y'} +        def verify_value(env, key, value, *args, **kwargs): +            """Verifies that key is value on the env this is called with.""" +            assert env[key] == value +        env.AddMethod(verify_value)          env2 = OverrideEnvironment(env, {'XXX' : 'x2'})          env3 = OverrideEnvironment(env2, {'XXX' : 'x3', 'YYY' : 'y3', 'ZZZ' : 'z3'})          self.envs = [ env, env2, env3 ] @@ -3769,6 +3781,13 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):      #    """Test the OverrideEnvironment WhereIs() method"""      #    pass +    def test_PseudoBuilderInherits(self): +        """Test that pseudo-builders inherit the overrided values.""" +        env, env2, env3 = self.envs +        env.verify_value('XXX', 'x') +        env2.verify_value('XXX', 'x2') +        env3.verify_value('XXX', 'x3') +      def test_Dir(self):          """Test the OverrideEnvironment Dir() method"""          env, env2, env3 = self.envs  | 
