diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-08-25 15:33:07 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-08-25 15:33:07 +0200 |
commit | 16bc58049adac72cb1f398d9f89e42757bb4a22f (patch) | |
tree | 4bd9643dd0bcf91fc8c6420a4a33337a0bda6e46 /src/engine/SCons/Platform/PlatformTests.py | |
parent | 78989ebb445af2c6462ae2bf05ffd588d76610e4 (diff) |
Imported Upstream version 2.3.3upstream/2.3.3
Diffstat (limited to 'src/engine/SCons/Platform/PlatformTests.py')
-rw-r--r-- | src/engine/SCons/Platform/PlatformTests.py | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py index 94a697b..de8ad2c 100644 --- a/src/engine/SCons/Platform/PlatformTests.py +++ b/src/engine/SCons/Platform/PlatformTests.py @@ -21,22 +21,24 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/PlatformTests.py 2014/07/05 09:42:21 garyo" +__revision__ = "src/engine/SCons/Platform/PlatformTests.py 2014/08/24 12:12:31 garyo" import SCons.compat import collections -import sys import unittest import TestUnit import SCons.Errors import SCons.Platform +import SCons.Environment +import SCons.Action class Environment(collections.UserDict): def Detect(self, cmd): return cmd + def AppendENVPath(self, key, value): pass @@ -117,9 +119,52 @@ class PlatformTestCase(unittest.TestCase): SCons.Platform.Platform()(env) assert env != {}, env +class TempFileMungeTestCase(unittest.TestCase): + def test_MAXLINELENGTH(self): + """ Test different values for MAXLINELENGTH with the same + size command string to ensure that the temp file mechanism + kicks in only at MAXLINELENGTH+1, or higher + """ + # Init class with cmd, such that the fully expanded + # string reads "a test command line". + # Note, how we're using a command string here that is + # actually longer than the substituted one. This is to ensure + # that the TempFileMunge class internally really takes the + # length of the expanded string into account. + defined_cmd = "a $VERY $OVERSIMPLIFIED line" + t = SCons.Platform.TempFileMunge(defined_cmd) + env = SCons.Environment.SubstitutionEnvironment(tools=[]) + # Setting the line length high enough... + env['MAXLINELENGTH'] = 1024 + env['VERY'] = 'test' + env['OVERSIMPLIFIED'] = 'command' + expanded_cmd = env.subst(defined_cmd) + # Call the tempfile munger + cmd = t(None,None,env,0) + assert cmd == defined_cmd, cmd + # Let MAXLINELENGTH equal the string's length + env['MAXLINELENGTH'] = len(expanded_cmd) + cmd = t(None,None,env,0) + assert cmd == defined_cmd, cmd + # Finally, let the actual tempfile mechanism kick in + # Disable printing of actions... + old_actions = SCons.Action.print_actions + SCons.Action.print_actions = 0 + env['MAXLINELENGTH'] = len(expanded_cmd)-1 + cmd = t(None,None,env,0) + # ...and restoring its setting. + SCons.Action.print_actions = old_actions + assert cmd != defined_cmd, cmd if __name__ == "__main__": - suite = unittest.makeSuite(PlatformTestCase, 'test_') + suite = unittest.TestSuite() + + tclasses = [ PlatformTestCase, + TempFileMungeTestCase ] + for tclass in tclasses: + names = unittest.getTestCaseNames(tclass, 'test_') + suite.addTests(list(map(tclass, names))) + TestUnit.run(suite) # Local Variables: |