Clean up and simplify logic. TODO: scons -c isn't removing the .di files. Mainly...
[scons.git] / test / MSVS / vs-7.1-clean.py
blob8c9cb87894c52e61c3068f08761187f597f1e7ae
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 """
28 Verify the -c option's ability to clean generated Visual Studio 7.1
29 project (.vcproj) and solution (.sln) files.
30 """
32 import TestSConsMSVS
34 test = TestSConsMSVS.TestSConsMSVS()
35 host_arch = test.get_vs_host_arch()
38 # Make the test infrastructure think we have this version of MSVS installed.
39 test._msvs_versions = ['7.1']
43 expected_slnfile = TestSConsMSVS.expected_slnfile_7_1
44 expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_7_1
48 test.write('SConstruct', """\
49 env=Environment(platform='win32', tools=['msvs'],
50 MSVS_VERSION='7.1',HOST_ARCH='%(HOST_ARCH)s')
52 testsrc = ['test1.cpp', 'test2.cpp']
53 testincs = ['sdk.h']
54 testlocalincs = ['test.h']
55 testresources = ['test.rc']
56 testmisc = ['readme.txt']
58 p = env.MSVSProject(target = 'Test.vcproj',
59 srcs = testsrc,
60 incs = testincs,
61 localincs = testlocalincs,
62 resources = testresources,
63 misc = testmisc,
64 buildtarget = 'Test.exe',
65 variant = 'Release',
66 auto_build_solution = 0)
68 env.MSVSSolution(target = 'Test.sln',
69 slnguid = '{SLNGUID}',
70 projects = [p],
71 variant = 'Release')
72 """%{'HOST_ARCH':host_arch})
74 test.run(arguments=".")
76 test.must_exist(test.workpath('Test.vcproj'))
77 vcproj = test.read('Test.vcproj', 'r')
78 expect = test.msvs_substitute(expected_vcprojfile, '7.1', None, 'SConstruct')
79 # don't compare the pickled data
80 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
82 test.must_exist(test.workpath('Test.sln'))
83 sln = test.read('Test.sln', 'r')
84 expect = test.msvs_substitute(expected_slnfile, '7.1', None, 'SConstruct')
85 # don't compare the pickled data
86 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
88 test.run(arguments='-c .')
90 test.must_not_exist(test.workpath('Test.vcproj'))
91 test.must_not_exist(test.workpath('Test.sln'))
93 test.run(arguments='.')
95 test.must_exist(test.workpath('Test.vcproj'))
96 test.must_exist(test.workpath('Test.sln'))
98 test.run(arguments='-c Test.sln')
100 test.must_exist(test.workpath('Test.vcproj'))
101 test.must_not_exist(test.workpath('Test.sln'))
103 test.run(arguments='-c Test.vcproj')
105 test.must_not_exist(test.workpath('Test.vcproj'))
109 test.pass_test()
111 # Local Variables:
112 # tab-width:4
113 # indent-tabs-mode:nil
114 # End:
115 # vim: set expandtab tabstop=4 shiftwidth=4: