diff options
author | Tom Plunket <tom@mightysprite.com> | 2016-03-23 20:09:38 (GMT) |
---|---|---|
committer | Tom Plunket <tom@mightysprite.com> | 2016-03-23 20:09:38 (GMT) |
commit | b0511d03a4939ca9dfd42e14fc39dfced6c5527c (patch) | |
tree | 14f82a06db2d6d73781289a2a3d87ed961983d4f /test | |
parent | 3791dc82915d61f0b9eee4738fc090c8a23b162c (diff) | |
download | SCons-b0511d03a4939ca9dfd42e14fc39dfced6c5527c.zip SCons-b0511d03a4939ca9dfd42e14fc39dfced6c5527c.tar.gz SCons-b0511d03a4939ca9dfd42e14fc39dfced6c5527c.tar.bz2 |
Rewrite file-names.py test so that it runs successfully.
Diffstat (limited to 'test')
-rw-r--r-- | test/file-names.py | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/test/file-names.py b/test/file-names.py index 95b4e4e..2311f38 100644 --- a/test/file-names.py +++ b/test/file-names.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys import TestSCons test = TestSCons.TestSCons() @@ -38,55 +39,76 @@ test = TestSCons.TestSCons() # parsing and interpretation of redirection and piping. But that # means we have to find ways to work with *all* of their quoting # conventions. -# -# Until we sort that all out, short-circuit this test so we can -# check it in and avoid having to re-invent this wheel later. -test.pass_test() def contents(c): return "|" + c + "|\n" +invalid_chars = '/\0' + if sys.platform == 'win32': - def bad_char(c): - return c in '/\\:' -else: - def bad_char(c): - return c in '/' + invalid_chars = set(invalid_chars) -# Only worry about ASCII characters right now. -# Someone with more Unicode knowledge should enhance this later. -for i in range(1, 255): - c = chr(i) - if not bad_char(c): - test.write("in" + c + "in", contents(c)) + # See the 'naming conventions' section of + # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx + invalid_chars.update([ chr(c) for c in range(32) ]) + invalid_chars.update(r'\/:*?"<>|') + invalid_chars.update(chr(127)) -test.write('SConstruct', r""" -import sys -if sys.platform == 'win32': + # Win32 filesystems are case insensitive so don't do half the alphabet. + import string + invalid_chars.update(string.lowercase) + + # See the 'naming conventions' section of + # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx def bad_char(c): - return (c == '/' or c == '\\' or c == ':') + return c in invalid_chars + def invalid_leading_char(c): + # the hash character as a leading character is interpreted to mean the project root + return c in ' #' + def invalid_trailing_char(c): + return c in ' .' + commandString = "copy $SOURCE $TARGET" else: def bad_char(c): - return (c == '/') -env = Environment() -for i in range(1, 255): - c = chr(i) - if not bad_char(c): - if c in '$': - c = '\\' + c - infile = "in" + c + "in" - env.Command(c + "out", infile, "cp $SOURCE $TARGET") - env.Command("out" + c + "out", infile, "cp $SOURCE $TARGET") - env.Command("out" + c, infile, "cp $SOURCE $TARGET") -""") + return c in invalid_chars + def invalid_leading_char(c): + # the hash character as a leading character is interpreted to mean the project root + return c in '#' + def invalid_trailing_char(c): + return False + commandString = "cp $SOURCE $TARGET" + +goodChars = [ chr(c) for c in range(1, 128) if not bad_char(chr(c)) ] + +for c in goodChars: + test.write("in" + c + "in", contents(c)) + +def create_command(a, b, c): + a = ('', 'out')[a] + b = ('', 'out')[b] + return 'env.Command("' + a + c + b + '", "in' + c + 'in", "' + commandString + '")' + +sconstruct = [ 'import sys', 'env = Environment()' ] +for c in goodChars: + if c == '$': + c = '$$' + if c == '"': + c = r'\"' + infile = "in" + c + "in" + if not invalid_leading_char(c): + sconstruct.append(create_command(False, True, c)) + sconstruct.append(create_command(True, True, c)) + if not invalid_trailing_char(c): + sconstruct.append(create_command(True, False, c)) +test.write('SConstruct', '\n'.join(sconstruct)) test.run(arguments = '.') -for i in range(1, 255): - c = chr(i) - if not bad_char(c): +for c in goodChars: + if not invalid_leading_char(c): test.fail_test(test.read(c + "out") != contents(c)) - test.fail_test(test.read("out" + c + "out") != contents(c)) + test.fail_test(test.read("out" + c + "out") != contents(c)) + if not invalid_trailing_char(c): test.fail_test(test.read("out" + c) != contents(c)) test.pass_test() |