Issue 2505: fix use of pre-compiled headers when the source .cpp
[scons.git] / test / MSVS / vs-7.0-clean.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 """
28 Verify the -c option's ability to clean generated Visual Studio 7.0
29 project (.vcproj) and solution (.sln) files.
30 """
31
32 import TestSConsMSVS
33
34 test = TestSConsMSVS.TestSConsMSVS()
35
36 # Make the test infrastructure think we have this version of MSVS installed.
37 test._msvs_versions = ['7.0']
38
39
40
41 expected_slnfile = TestSConsMSVS.expected_slnfile_7_0
42 expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_7_0
43
44
45
46 test.write('SConstruct', """\
47 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='7.0')
48
49 testsrc = ['test1.cpp', 'test2.cpp']
50 testincs = ['sdk.h']
51 testlocalincs = ['test.h']
52 testresources = ['test.rc']
53 testmisc = ['readme.txt']
54
55 p = env.MSVSProject(target = 'Test.vcproj',
56                     srcs = testsrc,
57                     incs = testincs,
58                     localincs = testlocalincs,
59                     resources = testresources,
60                     misc = testmisc,
61                     buildtarget = 'Test.exe',
62                     variant = 'Release',
63                     auto_build_solution = 0)
64
65 env.MSVSSolution(target = 'Test.sln',
66                  slnguid = '{SLNGUID}',
67                  projects = [p],
68                  variant = 'Release')
69 """)
70
71 test.run(arguments=".")
72
73 test.must_exist(test.workpath('Test.vcproj'))
74 vcproj = test.read('Test.vcproj', 'r')
75 expect = test.msvs_substitute(expected_vcprojfile, '7.0', None, 'SConstruct')
76 # don't compare the pickled data
77 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
78
79 test.must_exist(test.workpath('Test.sln'))
80 sln = test.read('Test.sln', 'r')
81 expect = test.msvs_substitute(expected_slnfile, '7.0', None, 'SConstruct')
82 # don't compare the pickled data
83 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
84
85 test.run(arguments='-c .')
86
87 test.must_not_exist(test.workpath('Test.vcproj'))
88 test.must_not_exist(test.workpath('Test.sln'))
89
90 test.run(arguments='.')
91
92 test.must_exist(test.workpath('Test.vcproj'))
93 test.must_exist(test.workpath('Test.sln'))
94
95 test.run(arguments='-c Test.sln')
96
97 test.must_exist(test.workpath('Test.vcproj'))
98 test.must_not_exist(test.workpath('Test.sln'))
99
100 test.run(arguments='-c Test.vcproj')
101
102 test.must_not_exist(test.workpath('Test.vcproj'))
103
104
105
106 test.pass_test()
107
108 # Local Variables:
109 # tab-width:4
110 # indent-tabs-mode:nil
111 # End:
112 # vim: set expandtab tabstop=4 shiftwidth=4: