summaryrefslogtreecommitdiff
path: root/test/long-lines
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-02-07 14:45:00 +0000
committerSteven Knight <knight@baldmt.com>2009-02-07 14:45:00 +0000
commit18d4190683f08b448e6c6e28d4e6dfb5487cadaf (patch)
tree34b6eee7fda1af369c9403a853514d960130fbcc /test/long-lines
parent4b4db1b1595ca441866621a422f911e4f129cbbb (diff)
downloadscons-18d4190683f08b448e6c6e28d4e6dfb5487cadaf.tar.gz
Capture a test case to verify correct behavior of $( $) on long lines
handled by TempFileMunge. Comment the behavior. Other minor cleanups.
Diffstat (limited to 'test/long-lines')
-rw-r--r--test/long-lines/live.py134
-rw-r--r--test/long-lines/signature.py90
2 files changed, 224 insertions, 0 deletions
diff --git a/test/long-lines/live.py b/test/long-lines/live.py
new file mode 100644
index 00000000..916740a5
--- /dev/null
+++ b/test/long-lines/live.py
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify correct execution of long command lines with the live utilities
+that use TempFileMunge().
+"""
+
+import sys
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if sys.platform == 'win32':
+ lib_static_lib = 'static.lib'
+ lib_shared_dll ='shared.dll'
+ arflag_init = '/LIBPATH:' + test.workpath()
+ arflag = ' /LIBPATH:' + test.workpath()
+ linkflag_init = '/LIBPATH:' + test.workpath()
+ linkflag = ' /LIBPATH:' + test.workpath()
+elif sys.platform == 'cygwin':
+ lib_static_lib = 'libstatic.a'
+ lib_shared_dll ='shared.dll'
+ arflag_init = 'r'
+ arflag = 'o'
+ linkflag_init = '-L' + test.workpath()
+ linkflag = ' -L' + test.workpath()
+elif sys.platform in ('darwin', 'irix6'):
+ lib_shared_dll = 'libshared' + TestSCons._dll
+ lib_static_lib = 'libstatic.a'
+ arflag_init = 'r'
+ arflag = 'v'
+ linkflag_init = '-L' + test.workpath()
+ linkflag = ' -L' + test.workpath()
+else:
+ lib_shared_dll = 'libshared.so'
+ lib_static_lib = 'libstatic.a'
+ arflag_init = 'r'
+ arflag = 'o'
+ linkflag_init = '-L' + test.workpath()
+ linkflag = ' -L' + test.workpath()
+
+test.write('SConstruct', """
+arflags = r'%(arflag_init)s'
+while len(arflags) <= 8100:
+ arflags = arflags + r'%(arflag)s'
+
+linkflags = r'%(linkflag_init)s'
+while len(linkflags) <= 8100:
+ linkflags = linkflags + r'%(linkflag)s'
+
+env = Environment(ARFLAGS = '$ARXXX', ARXXX = arflags,
+ LINKFLAGS = '$LINKXXX', LINKXXX = linkflags)
+env.Program(target = 'foo', source = 'foo.c')
+
+env.StaticLibrary(target = 'static', source = 'static.c')
+# SharedLibrary() uses $LINKFLAGS by default.
+env.SharedLibrary(target = 'shared', source = 'shared.c', no_import_lib=1)
+""" % locals())
+
+test.write('foo.c', r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("foo.c\n");
+ exit (0);
+}
+""")
+
+test.write('static.c', r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("static.c\n");
+ exit (0);
+}
+""")
+
+test.write('shared.c', r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("shared.c\n");
+ exit (0);
+}
+""")
+
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.up_to_date(arguments = '.')
+
+test.run(program = test.workpath('foo'), stdout = "foo.c\n")
+
+test.must_exist(lib_static_lib)
+
+test.must_exist(lib_shared_dll)
+
+test.pass_test()
diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py
new file mode 100644
index 00000000..cc8f3e28
--- /dev/null
+++ b/test/long-lines/signature.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that use of long command lines correctly excludes arguments
+surrounded by $( $) from the signature calculation.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+build_py = test.workpath('build.py')
+
+test.write(build_py, """\
+#!/usr/bin/env python
+import string
+import sys
+if sys.argv[1][0] == '@':
+ args = open(sys.argv[1][1:], 'rb').read()
+ args = string.split(args)
+else:
+ args = sys.argv[1:]
+fp = open(args[0], 'wb')
+fp.write(open(args[1], 'rb').read())
+fp.write('FILEFLAG=%s\\n' % args[2])
+fp.write('TIMESTAMP=%s\\n' % args[3])
+""")
+
+os.chmod(build_py, 0755)
+
+test.write('SConstruct', """\
+arg = 'a_long_ignored_argument'
+extra_arguments = arg
+while len(extra_arguments) <= 1024:
+ extra_arguments = extra_arguments + ' ' + arg
+env = Environment(FILECOM=[r'%(build_py)s',
+ '$TARGET', '$SOURCE',
+ '$FILEFLAG',
+ '$(', '$TIMESTAMP', '$)',
+ '$EXTRA_ARGUMENTS'],
+ FILEFLAG=ARGUMENTS.get('FILEFLAG'),
+ TIMESTAMP=ARGUMENTS.get('TIMESTAMP'),
+ EXTRA_ARGUMENTS=extra_arguments,
+ MAXLINELENGTH=1024)
+env.PrependENVPath('PATHEXT', '.PY')
+env.Command('file.out', 'file.in',
+ '${TEMPFILE(FILECOM)}')
+""" % locals())
+
+test.write('file.in', "file.in\n")
+
+test.run(arguments='FILEFLAG=first TIMESTAMP=20090207 .')
+
+test.must_match('file.out', "file.in\nFILEFLAG=first\nTIMESTAMP=20090207\n")
+
+test.up_to_date(options='FILEFLAG=first TIMESTAMP=20090208', arguments = '.')
+
+test.run(arguments='FILEFLAG=second TIMESTAMP=20090208 .')
+
+test.must_match('file.out', "file.in\nFILEFLAG=second\nTIMESTAMP=20090208\n")
+
+test.up_to_date(options='FILEFLAG=second TIMESTAMP=20090209', arguments = '.')
+
+test.pass_test()