875d959882ec2383d20767cfd32571dc68adb8f8
[scons.git] / test / Win32 / win32pathmadness.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 """
26 This test verifies that the build command signatures do not depend on
27 the case of the drive letter on Windows. This is important because Windows is 
28 inconsistent about which case is used for the drive letter.
29 """
30
31 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
32
33 import TestSCons
34 import sys
35 import TestCmd
36 import string
37 import os.path
38
39 test = TestSCons.TestSCons(match=TestCmd.match_re)
40
41 if sys.platform != 'win32':
42     msg = "Skipping Windows path tests on non-Windows platform '%s'\n" % sys.platform
43     test.skip_test(msg)
44
45 test.subdir('src', 'build', 'include', 'src2')
46
47 test.write('src/SConstruct', """
48 env=Environment(LIBS=['../build/foo'], CPPPATH=['../include'], CCCOM='$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS /c ${SOURCES.abspath} /Fo$TARGET')
49 foo=env.Object('../build/foo', 'foo.c')
50 Default(env.Library('../build/foo', foo))
51 Default(env.SharedLibrary('../build/bar', 'bar.c'))
52 Default(env.Program('../build/bar', ['main.c', '../src2/blat.c', '../build/bar.lib']))
53 """)
54
55 test.write('src/foo.c', """
56 int foo(void) 
57
58     return 1;
59 }
60 """)
61
62 test.write('src/bar.c', """
63 __declspec(dllexport) int bar(void) 
64
65     return 1;
66 }
67 """)
68
69 test.write('src/main.c', """
70 #include <bar.h>
71 int main(void) 
72
73     return 1;
74 }
75 """)
76
77 test.write('src2/blat.c', """
78 int blat(void) 
79
80     return 1;
81 }
82 """)
83
84 test.write('include/bar.h', """
85 int foo(void);
86 int blat(void);
87 int bar(void);
88 """)
89
90 drive, rest = os.path.splitdrive(test.workpath('src'))
91
92 drive_upper = string.upper(drive)
93 drive_lower = string.lower(drive)
94 rest_upper = rest[0] + string.upper(rest[1]) + rest[2:]
95 rest_lower = rest[0] + string.lower(rest[1]) + rest[2:]
96
97 combinations = [
98     os.path.join(drive_upper, rest_upper),
99     os.path.join(drive_upper, rest_lower),
100     os.path.join(drive_lower, rest_upper),
101     os.path.join(drive_lower, rest_lower),
102 ]
103
104 test.run(chdir=combinations[0])
105
106 for dir in combinations[1:]:
107     test.run(chdir=dir, stdout=test.wrap_stdout("""\
108 scons: .* is up to date.
109 scons: .* is up to date.
110 scons: .* is up to date.
111 """))
112
113
114
115 test.write('SConstruct', """
116 env=Environment()
117 env.StaticLibrary('a', 'a.c')
118 env.StaticLibrary('b', 'b.c')
119 """)
120
121 test.write('a.c', '''
122 #include "a.h"
123 #include "b.h"
124 ''')
125
126 test.write('b.c', '''
127 #include "a.h"
128 #include "B.h"
129 ''')
130
131 test.write('a.h', """
132 #define A_H
133 """)
134
135 test.write('b.h', """
136 #define B_H
137 """)
138
139 test.run(arguments='a.lib b.lib')
140 test.run(arguments='b.lib a.lib', stdout=test.wrap_stdout("""\
141 scons: .* is up to date.
142 scons: .* is up to date.
143 """))
144
145
146
147 test.pass_test()
148
149 # Local Variables:
150 # tab-width:4
151 # indent-tabs-mode:nil
152 # End:
153 # vim: set expandtab tabstop=4 shiftwidth=4: