Issue 1568: fix a stack trace when --debug=include tries to handle
[scons.git] / test / long-lines.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 import os
28 import os.path
29 import string
30 import sys
31 import TestSCons
32
33 test = TestSCons.TestSCons()
34
35 if sys.platform == 'win32':
36     lib_static_lib = 'static.lib'
37     lib_shared_dll ='shared.dll'
38     arflag_init = '/LIBPATH:' + test.workpath()
39     arflag = ' /LIBPATH:' + test.workpath()
40     linkflag_init = '/LIBPATH:' + test.workpath()
41     linkflag = ' /LIBPATH:' + test.workpath()
42 elif sys.platform == 'cygwin':
43     lib_static_lib = 'libstatic.a'
44     lib_shared_dll ='shared.dll'
45     arflag_init = 'r'
46     arflag = 'o'
47     linkflag_init = '-L' + test.workpath()
48     linkflag = ' -L' + test.workpath()
49 elif sys.platform in ('darwin', 'irix6'):
50     lib_shared_dll = 'libshared' + TestSCons._dll
51     lib_static_lib = 'libstatic.a'
52     arflag_init = 'r'
53     arflag = 'v'
54     linkflag_init = '-L' + test.workpath()
55     linkflag = ' -L' + test.workpath()
56 else:
57     lib_shared_dll = 'libshared.so'
58     lib_static_lib = 'libstatic.a'
59     arflag_init = 'r'
60     arflag = 'o'
61     linkflag_init = '-L' + test.workpath()
62     linkflag = ' -L' + test.workpath()
63
64 test.write('SConstruct', """
65 arflags = r'%s'
66 while len(arflags) <= 8100:
67     arflags = arflags + r'%s'
68
69 linkflags = r'%s'
70 while len(linkflags) <= 8100:
71     linkflags = linkflags + r'%s'
72
73 env = Environment(ARFLAGS = '$ARXXX', ARXXX = arflags,
74                   LINKFLAGS = '$LINKXXX', LINKXXX = linkflags)
75 env.Program(target = 'foo', source = 'foo.c')
76
77 env.StaticLibrary(target = 'static', source = 'static.c')
78 # SharedLibrary() uses $LINKFLAGS by default.
79 env.SharedLibrary(target = 'shared', source = 'shared.c', no_import_lib=1)
80 """ % (arflag_init, arflag, linkflag_init, linkflag))
81
82 test.write('foo.c', r"""
83 #include <stdio.h>
84 #include <stdlib.h>
85 int
86 main(int argc, char *argv[])
87 {
88         argv[argc++] = "--";
89         printf("foo.c\n");
90         exit (0);
91 }
92 """)
93
94 test.write('static.c', r"""
95 #include <stdio.h>
96 #include <stdlib.h>
97 int
98 main(int argc, char *argv[])
99 {
100         argv[argc++] = "--";
101         printf("static.c\n");
102         exit (0);
103 }
104 """)
105
106 test.write('shared.c', r"""
107 #include <stdio.h>
108 #include <stdlib.h>
109 int
110 main(int argc, char *argv[])
111 {
112         argv[argc++] = "--";
113         printf("shared.c\n");
114         exit (0);
115 }
116 """)
117
118
119 test.run(arguments = '.',
120          stderr=TestSCons.noisy_ar,
121          match=TestSCons.match_re_dotall)
122
123 test.up_to_date(arguments = '.')
124
125 test.run(program = test.workpath('foo'), stdout = "foo.c\n")
126
127 test.fail_test(not os.path.exists(lib_static_lib))
128
129 test.fail_test(not os.path.exists(lib_shared_dll))
130
131 test.pass_test()