Skip to content

Commit

Permalink
[PR SCons#3211] fix a couple of bugs
Browse files Browse the repository at this point in the history
Since the last time this was built, Travis and Appveyor run
more tests, and that turned up some missed locations that
needed updating.

Signed-off-by: Mats Wichmann <mats@linux.com>
  • Loading branch information
mwichmann committed Apr 13, 2019
1 parent d830eb0 commit bb3b2a4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
38 changes: 23 additions & 15 deletions src/engine/SCons/EnvironmentTests.py
Expand Up @@ -1751,7 +1751,7 @@ class TestA(object):
env2.Dictionary()['ZZZ'][5] = 6
assert env1.Dictionary()['XXX'] == env2.Dictionary()['XXX']
assert 4 in env2.Dictionary()['YYY']
assert not 4 in env1.Dictionary()['YYY']
assert 4 not in env1.Dictionary()['YYY']
assert 5 in env2.Dictionary()['ZZZ']
assert 5 not in env1.Dictionary()['ZZZ']

Expand Down Expand Up @@ -1942,20 +1942,21 @@ def test_Dictionary(self):
defaults that get inserted.
"""
env = self.TestEnvironment(XXX = 'x', YYY = 'y', ZZZ = 'z')
assert env.Dictionary()['XXX'] == 'x'
assert env.Dictionary()['YYY'] == 'y'
assert not {'x', 'z'}.difference(env.Dictionary('XXX', 'ZZZ').values())
assert env.Dictionary()['XXX'] == 'x', env.Dictionary()['XXX']
assert env.Dictionary()['YYY'] == 'y', env.Dictionary()['YYY']
assert set(env.Dictionary('XXX', 'ZZZ').values()) == {'x', 'z'}, \
set(env.Dictionary('XXX', 'ZZZ').values())
xxx = env.Dictionary('XXX', 'ZZZ')
assert xxx['XXX'] == 'x'
assert xxx['ZZZ'] == 'z'
assert xxx['XXX'] == 'x', xxx['XXX']
assert xxx['ZZZ'] == 'z', xxx['ZZZ']
assert 'BUILDERS' in env.Dictionary()
assert 'CC' in env.Dictionary()
assert 'CCFLAGS' in env.Dictionary()
assert 'ENV' in env.Dictionary()

assert env['XXX'] == 'x'
assert env['XXX'] == 'x', env['XXX']
env['XXX'] = 'foo'
assert env.Dictionary()['XXX'] == 'foo'
assert env.Dictionary()['XXX'] == 'foo', env.Dictionary()['XXX']
del env['XXX']
assert 'XXX' not in env.Dictionary()

Expand All @@ -1971,15 +1972,21 @@ def test_FindIxes(self):
paths = [os.path.join('dir', 'libfoo.a'),
os.path.join('dir', 'libfoo.so')]

assert paths[0] == env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
assert paths[1] == env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
assert None is env.FindIxes(paths, 'PREFIX', 'POST')
assert env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX') == paths[0], \
env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
assert env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX') == paths[1], \
env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
assert env.FindIxes(paths, 'PREFIX', 'POST') is None, \
env.FindIxes(paths, 'PREFIX', 'POST')

paths = ['libfoo.a', 'prefoopost']

assert paths[0] == env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
assert None is env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
assert paths[1] == env.FindIxes(paths, 'PREFIX', 'SUFFIX')
assert env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX') == paths[0], \
env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
assert env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX') is None, \
env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
assert env.FindIxes(paths, 'PREFIX', 'SUFFIX') == paths[1], \
env.FindIxes(paths, 'PREFIX', 'SUFFIX')

def test_ParseConfig(self):
"""Test the ParseConfig() method"""
Expand Down Expand Up @@ -2929,7 +2936,8 @@ def test_NoClean(self):
def test_Dump(self):
"""Test the Dump() method"""

# this is to format the expected string
# this is to format the expected string to match,
# since Dump() uses the same method to format
import pprint
pp = pprint.PrettyPrinter(indent=2)
expect = pp.pformat({'FOO': 'foo'})
Expand Down
4 changes: 2 additions & 2 deletions test/LEX/live_mingw.py
Expand Up @@ -52,8 +52,8 @@

test.write('SConstruct', """
foo = Environment(tools=['default', 'mingw', 'lex'], LEXUNISTD="")
lex = foo.Dictionary('LEX')
bar = Environment(LEX = r'%(_python_)s wrapper.py ' + lex,
lex = foo.Dictionary()['LEX']
bar = Environment(LEX=r'%(_python_)s wrapper.py ' + lex['LEX'],
LEXFLAGS = '-b',
LEXUNISTD="",
tools=['default', 'mingw', 'lex'])
Expand Down
2 changes: 1 addition & 1 deletion test/LEX/no_lex.py
Expand Up @@ -45,7 +45,7 @@ def Detect(self, progs):
SCons.Tool.find_program_path = no_lex
foo = TestEnvironment(tools=['default', 'lex'])
print(foo.Dictionary('LEX'))
print(foo.Dictionary()['LEX'])
""" % locals())

test.run(arguments = '-Q -s', stdout = 'None\n' )
Expand Down

0 comments on commit bb3b2a4

Please sign in to comment.