Merge pull request #4584 from siegria/fix_piped_spawn_encoding
[scons.git] / test / MSVS / vs-14.0-exec.py
blob82e2d0aabf99271de0535f61abbada03dd2e4d19
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Test that we can actually build a simple program using our generated
28 Visual Studio 14.0 project (.vcxproj) and solution (.sln) files
29 using Visual Studio 14.0 (Professional edition).
30 """
32 import os
33 import sys
35 import TestSConsMSVS
36 from TestSConsMSVS import _obj, _exe
38 test = TestSConsMSVS.TestSConsMSVS()
40 if sys.platform != 'win32':
41 msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
42 test.skip_test(msg)
44 msvs_version = '14.0'
46 if msvs_version not in test.msvs_versions():
47 msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
48 test.skip_test(msg)
50 # Let SCons figure out the Visual Studio environment variables for us and
51 # print out a statement that we can exec to suck them into our external
52 # environment so we can execute devenv and really try to build something.
54 test.run(arguments='-n -q -Q -f -', stdin="""\
55 env = Environment(tools=['msvc'], MSVS_VERSION='%(msvs_version)s')
56 if env.WhereIs('cl'):
57 print("os.environ.update(%%s)" %% repr(env['ENV']))
58 """ % locals())
60 if test.stdout() == "":
61 msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
62 test.skip_test(msg)
64 exec(test.stdout())
66 test.subdir('sub dir')
67 test.write(['sub dir', 'SConstruct'], """\
68 DefaultEnvironment(tools=[])
69 env = Environment(MSVS_VERSION='%(msvs_version)s')
71 env.MSVSProject(
72 target='foo.vcxproj',
73 srcs=['foo.c'],
74 buildtarget='foo.exe',
75 variant='Release',
76 DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
78 env.Program('foo.c')
79 """ % locals())
81 test.write(['sub dir', 'foo.c'], r"""
82 #include <stdio.h>
83 int
84 main(int argc, char *argv)
86 printf("foo.c\n");
87 exit (0);
89 """)
91 test.run(chdir='sub dir', arguments='.')
93 test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
94 test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
96 import SCons.Platform.win32
98 system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
99 os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path
101 test.run(
102 chdir='sub dir',
103 program=[test.get_msvs_executable(msvs_version)],
104 arguments=['foo.sln', '/build', 'Release'],
107 test.run(program=test.workpath('sub dir', 'foo' + _exe), stdout="foo.c\n")
108 test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user'))
110 test.pass_test()
112 # Local Variables:
113 # tab-width:4
114 # indent-tabs-mode:nil
115 # End:
116 # vim: set expandtab tabstop=4 shiftwidth=4: