diff options
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/ActionTests.py | 23 | ||||
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/ProgTests.py | 21 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 10 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 26 |
6 files changed, 79 insertions, 19 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9783116..d3f6aa0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -63,6 +63,8 @@ RELEASE 0.05 - - Run HTML docs through tidy to clean up the HTML (for Konqueror). + - Add preliminary support for Unicode strings. + From Anthony Roach: - Make the scons script return an error code on failures. diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 3aedc25..f872a1d 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -30,9 +30,8 @@ __revision__ = "src/engine/SCons/ActionTests.py __REVISION__ __DATE__ __DEVELOPE def Func(): pass -import unittest - import sys +import types import unittest import SCons.Action @@ -46,19 +45,23 @@ class ActionTestCase(unittest.TestCase): def foo(): pass a1 = SCons.Action.Action(foo) - assert isinstance(a1, SCons.Action.FunctionAction) + assert isinstance(a1, SCons.Action.FunctionAction), a1 a2 = SCons.Action.Action("string") - assert isinstance(a2, SCons.Action.CommandAction) + assert isinstance(a2, SCons.Action.CommandAction), a2 + + if hasattr(types, 'UnicodeType'): + exec "a3 = SCons.Action.Action(u'string')" + exec "assert isinstance(a3, SCons.Action.CommandAction), a3" - a3 = SCons.Action.Action(["x", a2, "y"]) - assert isinstance(a3, SCons.Action.ListAction) + a4 = SCons.Action.Action(["x", a2, "y"]) + assert isinstance(a4, SCons.Action.ListAction), a4 - a4 = SCons.Action.Action(1) - assert a4 is None, a4 + a5 = SCons.Action.Action(1) + assert a5 is None, a5 - a5 = SCons.Action.Action(a1) - assert a5 is a1 + a6 = SCons.Action.Action(a1) + assert a6 is a1 class ActionBaseTestCase(unittest.TestCase): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 3b44672..a1223d7 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -32,6 +32,7 @@ def Func(): import os.path import sys +import types import unittest import TestCmd @@ -118,6 +119,21 @@ class BuilderTestCase(unittest.TestCase): assert target.sources[0].name == 'n10' assert target.sources[1].name == 'n11' + if hasattr(types, 'UnicodeType'): + code = """if 1: + targets = builder(env, target = u'n12 n13', source = [u'n14 n15']) + assert targets[0].name == u'n12' + assert targets[0].sources[0].name == u'n14 n15' + assert targets[1].name == u'n13' + assert targets[1].sources[0].name == u'n14 n15' + + target = builder(env, target = [u'n16 n17'], source = u'n18 n19') + assert target.name == u'n16 n17' + assert target.sources[0].name == u'n18' + assert target.sources[1].name == u'n19' + \n""" + exec code + def test_noname(self): """Test error reporting for missing name diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 31f3301..3f79838 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -23,11 +23,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path +import sys +import types +import unittest + import TestCmd import SCons.Scanner.Prog -import unittest -import sys -import os.path test = TestCmd.TestCmd(workdir = '') @@ -94,6 +96,19 @@ def suite(): suite.addTest(ProgScanTestCase1()) suite.addTest(ProgScanTestCase2()) suite.addTest(ProgScanTestCase3()) + if hasattr(types, 'UnicodeType'): + code = """if 1: + class ProgScanTestCase4(unittest.TestCase): + def runTest(self): + env = DummyEnvironment(LIBPATH=test.workpath("d1/d2") + ' ' +\ + test.workpath("d1"), + LIBS=u'l2 l3') + s = SCons.Scanner.Prog.ProgScan() + deps = s.scan('dummy', env) + assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) + suite.addTest(ProgScanTestCase4()) + \n""" + exec code return suite if __name__ == "__main__": diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index fd95438..038468f 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -444,8 +444,14 @@ def is_Dict(e): def is_List(e): return type(e) is types.ListType or isinstance(e, UserList.UserList) -def is_String(e): - return type(e) is types.StringType or isinstance(e, UserString) +if hasattr(types, 'UnicodeType'): + def is_String(e): + return type(e) is types.StringType \ + or type(e) is types.UnicodeType \ + or isinstance(e, UserString) +else: + def is_String(e): + return type(e) is types.StringType or isinstance(e, UserString) # attempt to load the windows registry module: can_read_reg = 0 diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 11238c9..0e9f7b5 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -28,6 +28,7 @@ import os.path import re import string import sys +import types import unittest import SCons.Node import SCons.Node.FS @@ -38,21 +39,32 @@ class UtilTestCase(unittest.TestCase): def test_str2nodes(self): """Test the str2nodes function.""" nodes = scons_str2nodes("Util.py UtilTests.py") - assert len(nodes) == 2 + assert len(nodes) == 2, nodes assert isinstance(nodes[0], SCons.Node.FS.File) assert isinstance(nodes[1], SCons.Node.FS.File) assert nodes[0].path == "Util.py" assert nodes[1].path == "UtilTests.py" + if hasattr(types, 'UnicodeType'): + code = """if 1: + nodes = scons_str2nodes(u"Util.py UtilTests.py") + assert len(nodes) == 2, nodes + assert isinstance(nodes[0], SCons.Node.FS.File) + assert isinstance(nodes[1], SCons.Node.FS.File) + assert nodes[0].path == u"Util.py" + assert nodes[1].path == u"UtilTests.py" + \n""" + exec code + nodes = scons_str2nodes("Util.py UtilTests.py", SCons.Node.FS.FS().File) - assert len(nodes) == 2 + assert len(nodes) == 2, nodes assert isinstance(nodes[0], SCons.Node.FS.File) assert isinstance(nodes[1], SCons.Node.FS.File) assert nodes[0].path == "Util.py" assert nodes[1].path == "UtilTests.py" nodes = scons_str2nodes(["Util.py", "UtilTests.py"]) - assert len(nodes) == 2 + assert len(nodes) == 2, nodes assert isinstance(nodes[0], SCons.Node.FS.File) assert isinstance(nodes[1], SCons.Node.FS.File) assert nodes[0].path == "Util.py" @@ -60,7 +72,7 @@ class UtilTestCase(unittest.TestCase): n1 = SCons.Node.FS.default_fs.File("Util.py") nodes = scons_str2nodes([n1, "UtilTests.py"]) - assert len(nodes) == 2 + assert len(nodes) == 2, nodes assert isinstance(nodes[0], SCons.Node.FS.File) assert isinstance(nodes[1], SCons.Node.FS.File) assert nodes[0].path == "Util.py" @@ -270,6 +282,8 @@ class UtilTestCase(unittest.TestCase): assert is_Dict(UserDict.UserDict()) assert not is_Dict([]) assert not is_Dict("") + if hasattr(types, 'UnicodeType'): + exec "assert not is_Dict(u'')" def test_is_List(self): assert is_List([]) @@ -277,9 +291,13 @@ class UtilTestCase(unittest.TestCase): assert is_List(UserList.UserList()) assert not is_List({}) assert not is_List("") + if hasattr(types, 'UnicodeType'): + exec "assert not is_List(u'')" def test_is_String(self): assert is_String("") + if hasattr(types, 'UnicodeType'): + exec "assert is_String(u'')" try: import UserString except: |