[ci skip] add test framework reformat to .git-blame-ignore-revs
[scons.git] / test / MSVS / vs-variant_dir.py
blob880a36edac4b1183bf055324d05901449ca5164f
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 Test that we can generate Visual Studio 8.0 project (.vcproj) and
29 solution (.sln) files that look correct when using a variant_dir.
30 """
32 import TestSConsMSVS
34 test = None
36 for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions():
37 test = TestSConsMSVS.TestSConsMSVS()
38 host_arch = test.get_vs_host_arch()
40 # Make the test infrastructure think we have this version of MSVS installed.
41 test._msvs_versions = [vc_version]
43 dirs = ['inc1', 'inc2']
44 major, minor = test.parse_vc_version(vc_version)
45 project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj'
46 expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file)
47 expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file)
49 test.subdir('src')
51 test.write('SConstruct', """\
52 SConscript('src/SConscript', variant_dir='build')
53 """)
55 test.write('SConstruct', """\
56 SConscript('src/SConscript', variant_dir='build')
57 """)
59 test.write(['src', 'SConscript'], test.get_expected_sconscript_file_contents(vc_version, project_file))
61 test.run(arguments=".")
63 vcproj = test.read(['src', project_file], 'r')
64 expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct')
65 # don't compare the pickled data
66 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
68 test.must_exist(test.workpath('src', 'Test.sln'))
69 sln = test.read(['src', 'Test.sln'], 'r')
70 expect = test.msvs_substitute(expected_slnfile, '8.0', 'src')
71 # don't compare the pickled data
72 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
74 test.must_match(['build', project_file], """\
75 This is just a placeholder file.
76 The real project file is here:
78 """ % test.workpath('src', project_file), mode='r')
80 test.must_match(['build', 'Test.sln'], """\
81 This is just a placeholder file.
82 The real workspace file is here:
84 """ % test.workpath('src', 'Test.sln'), mode='r')
86 if test:
87 test.pass_test()
89 # Local Variables:
90 # tab-width:4
91 # indent-tabs-mode:nil
92 # End:
93 # vim: set expandtab tabstop=4 shiftwidth=4: