diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-08-30 17:39:14 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2021-09-18 23:45:08 (GMT) |
commit | 76f770a7b4bbaaea25ef2670958b9136eea7049a (patch) | |
tree | d449250b3a69f76b81fc460df0eeeba19ba7fd2a /test | |
parent | aaeae85edd462782267da4bd07b27af1d4e785b7 (diff) | |
download | SCons-76f770a7b4bbaaea25ef2670958b9136eea7049a.zip SCons-76f770a7b4bbaaea25ef2670958b9136eea7049a.tar.gz SCons-76f770a7b4bbaaea25ef2670958b9136eea7049a.tar.bz2 |
add logic to ensure PCH is subst() evaluated when it should be
Diffstat (limited to 'test')
-rw-r--r-- | test/MSVC/msvc.py | 69 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/SConstruct | 15 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/StdAfx.cpp | 4 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/StdAfx.h | 3 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/foo.cpp | 1 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/resource.h | 1 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/sconstest.skip | 0 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/test.cpp | 10 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/test.rc | 6 | ||||
-rw-r--r-- | test/MSVC/pch_gen/fixture/SConstruct | 19 | ||||
-rw-r--r-- | test/MSVC/pch_gen/fixture/sconstest.skip | 0 | ||||
-rw-r--r-- | test/MSVC/pch_gen/pch_gen.py | 50 |
12 files changed, 114 insertions, 64 deletions
diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index 3b32046..b870b77 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,7 +28,6 @@ Verify basic invocation of Microsoft Visual C/C++, including use of a precompiled header with the $CCFLAGS variable. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import time @@ -36,71 +37,11 @@ test = TestSCons.TestSCons(match = TestSCons.match_re) test.skip_if_not_msvc() +test.dir_fixture('msvc_fixture') + ##### # Test the basics -test.write('SConstruct',""" -import os -DefaultEnvironment(tools=[]) -# TODO: this is order-dependent (putting 'mssdk' second or third breaks), -# and ideally we shouldn't need to specify the tools= list anyway. -env = Environment(tools=['mssdk', 'msvc', 'mslink']) -env.Append(CPPPATH=os.environ.get('INCLUDE', ''), - LIBPATH=os.environ.get('LIB', ''), - CCFLAGS='/DPCHDEF') -env['PDB'] = File('test.pdb') -env['PCHSTOP'] = 'StdAfx.h' -env['PCH'] = env.PCH('StdAfx.cpp')[0] -env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) - -env.Object('fast', 'foo.cpp') -env.Object('slow', 'foo.cpp', PCH=0) -""") - -test.write('test.cpp', ''' -#include "StdAfx.h" -#include "resource.h" - -int main(void) -{ - char test[1024]; - LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); - printf("%d %s\\n", IDS_TEST, test); - return 0; -} -''') - -test.write('test.rc', ''' -#include "resource.h" - -STRINGTABLE DISCARDABLE -BEGIN - IDS_TEST "test 1" -END -''') - -test.write('resource.h', ''' -#define IDS_TEST 2001 -''') - - -test.write('foo.cpp', ''' -#include "StdAfx.h" -''') - -test.write('StdAfx.h', ''' -#include <windows.h> -#include <stdio.h> -#include "resource.h" -''') - -test.write('StdAfx.cpp', ''' -#include "StdAfx.h" -#ifndef PCHDEF -this line generates an error if PCHDEF is not defined! -#endif -''') - # Visual Studio 8 has deprecated the /Yd option and prints warnings # about it, so ignore stderr when running SCons. diff --git a/test/MSVC/msvc_fixture/SConstruct b/test/MSVC/msvc_fixture/SConstruct new file mode 100644 index 0000000..2a63180 --- /dev/null +++ b/test/MSVC/msvc_fixture/SConstruct @@ -0,0 +1,15 @@ +import os +DefaultEnvironment(tools=[]) +# TODO: this is order-dependent (putting 'mssdk' second or third breaks), +# and ideally we shouldn't need to specify the tools= list anyway. +env = Environment(tools=['mssdk', 'msvc', 'mslink']) +env.Append(CPPPATH=os.environ.get('INCLUDE', ''), + LIBPATH=os.environ.get('LIB', ''), + CCFLAGS='/DPCHDEF') +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = 'StdAfx.h' +env['PCH'] = env.PCH('StdAfx.cpp')[0] +env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) + +env.Object('fast', 'foo.cpp') +env.Object('slow', 'foo.cpp', PCH=0) diff --git a/test/MSVC/msvc_fixture/StdAfx.cpp b/test/MSVC/msvc_fixture/StdAfx.cpp new file mode 100644 index 0000000..a6a290b --- /dev/null +++ b/test/MSVC/msvc_fixture/StdAfx.cpp @@ -0,0 +1,4 @@ +#include "StdAfx.h" +#ifndef PCHDEF +this line generates an error if PCHDEF is not defined! +#endif
\ No newline at end of file diff --git a/test/MSVC/msvc_fixture/StdAfx.h b/test/MSVC/msvc_fixture/StdAfx.h new file mode 100644 index 0000000..a92d7df --- /dev/null +++ b/test/MSVC/msvc_fixture/StdAfx.h @@ -0,0 +1,3 @@ +#include <windows.h> +#include <stdio.h> +#include "resource.h"
\ No newline at end of file diff --git a/test/MSVC/msvc_fixture/foo.cpp b/test/MSVC/msvc_fixture/foo.cpp new file mode 100644 index 0000000..09f15b6 --- /dev/null +++ b/test/MSVC/msvc_fixture/foo.cpp @@ -0,0 +1 @@ +#include "StdAfx.h"
\ No newline at end of file diff --git a/test/MSVC/msvc_fixture/resource.h b/test/MSVC/msvc_fixture/resource.h new file mode 100644 index 0000000..089e932 --- /dev/null +++ b/test/MSVC/msvc_fixture/resource.h @@ -0,0 +1 @@ +#define IDS_TEST 2001 diff --git a/test/MSVC/msvc_fixture/sconstest.skip b/test/MSVC/msvc_fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/MSVC/msvc_fixture/sconstest.skip diff --git a/test/MSVC/msvc_fixture/test.cpp b/test/MSVC/msvc_fixture/test.cpp new file mode 100644 index 0000000..354b5f1 --- /dev/null +++ b/test/MSVC/msvc_fixture/test.cpp @@ -0,0 +1,10 @@ +#include "StdAfx.h" +#include "resource.h" + +int main(void) +{ + char test[1024]; + LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); + printf("%d %s\n", IDS_TEST, test); + return 0; +}
\ No newline at end of file diff --git a/test/MSVC/msvc_fixture/test.rc b/test/MSVC/msvc_fixture/test.rc new file mode 100644 index 0000000..aec22a2 --- /dev/null +++ b/test/MSVC/msvc_fixture/test.rc @@ -0,0 +1,6 @@ +#include "resource.h" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TEST "test 1" +END diff --git a/test/MSVC/pch_gen/fixture/SConstruct b/test/MSVC/pch_gen/fixture/SConstruct new file mode 100644 index 0000000..5fea0a8 --- /dev/null +++ b/test/MSVC/pch_gen/fixture/SConstruct @@ -0,0 +1,19 @@ +import os +DefaultEnvironment(tools=[]) +# TODO: this is order-dependent (putting 'mssdk' second or third breaks), +# and ideally we shouldn't need to specify the tools= list anyway. +env = Environment(tools=['mssdk', 'msvc', 'mslink']) +env.Append(CPPPATH=os.environ.get('INCLUDE', ''), + LIBPATH=os.environ.get('LIB', ''), + CCFLAGS='/DPCHDEF') +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = 'StdAfx.h' + +def pch_gen(env, target, source, for_signature): + return 'StdAfx.pch' +env['PCH'] = pch_gen +env.PCH('StdAfx.cpp')[0] +env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) + +env.Object('fast', 'foo.cpp') +env.Object('slow', 'foo.cpp', PCH=0)
\ No newline at end of file diff --git a/test/MSVC/pch_gen/fixture/sconstest.skip b/test/MSVC/pch_gen/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/MSVC/pch_gen/fixture/sconstest.skip diff --git a/test/MSVC/pch_gen/pch_gen.py b/test/MSVC/pch_gen/pch_gen.py new file mode 100644 index 0000000..9fea9e2 --- /dev/null +++ b/test/MSVC/pch_gen/pch_gen.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Template for end-to-end test file. +Replace this with a description of the test. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_if_not_msvc() + +test.dir_fixture('../msvc_fixture') + +test.file_fixture('fixture/SConstruct', + 'SConstruct') + +test.run(arguments='.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |