diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-09-26 20:05:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 20:05:08 (GMT) |
commit | 00f6b1a868af4543f14b385d63ec274d6feca3e8 (patch) | |
tree | 46e1f2f740212c5cf4893bf3c3133c0d1f4c8259 /test | |
parent | 3e172324f2e47581c173e1bd0ae8d8d1237067ae (diff) | |
parent | 46a57536bc53d71840bdfd29cb2fb16e6737035f (diff) | |
download | SCons-00f6b1a868af4543f14b385d63ec274d6feca3e8.zip SCons-00f6b1a868af4543f14b385d63ec274d6feca3e8.tar.gz SCons-00f6b1a868af4543f14b385d63ec274d6feca3e8.tar.bz2 |
Merge branch 'master' into ninja_fix_mkdir
Diffstat (limited to 'test')
-rw-r--r-- | test/Libs/LIBS.py | 6 | ||||
-rw-r--r-- | test/MSVC/hierarchical.py | 13 | ||||
-rw-r--r-- | test/MSVC/msvc.py | 69 | ||||
-rw-r--r-- | test/MSVC/msvc_fixture/SConstruct | 14 | ||||
-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-spaces-subdir.py | 1 | ||||
-rw-r--r-- | test/MSVC/pch_gen/fixture/SConstruct | 53 | ||||
-rw-r--r-- | test/MSVC/pch_gen/fixture/sconstest.skip | 0 | ||||
-rw-r--r-- | test/MSVC/pch_gen/pch_gen.py | 66 | ||||
-rw-r--r-- | test/Repository/CPPPATH.py | 2 | ||||
-rw-r--r-- | test/Repository/SConscript.py | 2 | ||||
-rw-r--r-- | test/Repository/multi-dir.py | 2 | ||||
-rw-r--r-- | test/ninja/build_libraries.py | 2 | ||||
-rw-r--r-- | test/textfile/fixture/SConstruct | 5 | ||||
-rw-r--r-- | test/textfile/textfile.py | 11 |
21 files changed, 188 insertions, 83 deletions
diff --git a/test/Libs/LIBS.py b/test/Libs/LIBS.py index 33978da..3d9eb29 100644 --- a/test/Libs/LIBS.py +++ b/test/Libs/LIBS.py @@ -26,7 +26,11 @@ import sys import TestSCons -from TestSCons import _exe, lib_, _lib + +# Leave below to resolve sider complaints +_exe = TestSCons._exe +lib_ = TestSCons.lib_ +_lib = TestSCons._lib if sys.platform == 'win32': import SCons.Tool.MSCommon as msc diff --git a/test/MSVC/hierarchical.py b/test/MSVC/hierarchical.py index 0b19483..49ebe78 100644 --- a/test/MSVC/hierarchical.py +++ b/test/MSVC/hierarchical.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 @@ -20,9 +22,6 @@ # 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Verify use of Visual Studio with a hierarchical build. @@ -37,18 +36,16 @@ test.skip_if_not_msvc() test.subdir('src', 'build', 'out') test.write('SConstruct', """ +DefaultEnvironment(tools=[]) VariantDir('build', 'src', duplicate=0) SConscript('build/SConscript') """) test.write('src/SConscript',""" -import os # 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', '')) -env['PCH'] = 'StdAfx.pch' +env['PCH'] = File('StdAfx.pch') env['PDB'] = '#out/test.pdb' env['PCHSTOP'] = 'StdAfx.h' env.PCH('StdAfx.cpp') 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..af916dc --- /dev/null +++ b/test/MSVC/msvc_fixture/SConstruct @@ -0,0 +1,14 @@ +# msvc_fixture's SConstruct + +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(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-spaces-subdir.py b/test/MSVC/pch-spaces-subdir.py index f00fac1..a55d8b7 100644 --- a/test/MSVC/pch-spaces-subdir.py +++ b/test/MSVC/pch-spaces-subdir.py @@ -62,6 +62,7 @@ SConscript('SConscript', variant_dir='Release Output', duplicate=0) """) test.write('SConscript', """\ +DefaultEnvironment(tools=[]) env = Environment() env['PCHSTOP'] = 'Precompiled.h' diff --git a/test/MSVC/pch_gen/fixture/SConstruct b/test/MSVC/pch_gen/fixture/SConstruct new file mode 100644 index 0000000..ab63cd6 --- /dev/null +++ b/test/MSVC/pch_gen/fixture/SConstruct @@ -0,0 +1,53 @@ +# pch_gen fixture's SConstruct + +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. + + +VariantDir('output1','src') +VariantDir('output2','src') + + +# Add flag to cause pch_gen to return empty string +# This will enable testing that PCH if subst'd yields empty string will stop +# PCH from being enabled. +vars = Variables(None, ARGUMENTS) +vars.AddVariables(BoolVariable("DISABLE_PCH", help="Disable PCH functionality", default=False)) + + +env = Environment(variables=vars, tools=["mssdk", "msvc", "mslink"]) +env.Append(CCFLAGS="/DPCHDEF") +env["PDB"] = File("output1/test.pdb") +env["PCHSTOP"] = "StdAfx.h" + + +def pch_gen(env, target, source, for_signature): + if env['DISABLE_PCH']: + return "" + else: + return "StdAfx-1.pch" + + +env["PCH"] = pch_gen +env.PCH("output1/StdAfx-1.pch", "output1/StdAfx.cpp") +env.Program("output1/test", ["output1/test.cpp", env.RES("output1/test.rc")], LIBS=["user32"]) + +env.Object("output1/fast", "output1/foo.cpp") +env.Object("output1/slow", "output1/foo.cpp", PCH=0) + + + +env2 = env.Clone() + +def pch_gen2(env, target, source, for_signature): + if env['DISABLE_PCH']: + return "" + else: + return env.get('PCH_NODE') +env2["PDB"] = File("output2/test.pdb") +env2["PCHSTOP"] = "StdAfx.h" +env2["PCH"] = pch_gen2 +env2['PCH_NODE'] = env2.PCH("output2/StdAfx-1.pch", "output2/StdAfx.cpp")[0] +env2.Program("output2/test", ["output2/test.cpp", env.RES("output2/test.rc")], LIBS=["user32"]) + 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..9490d69 --- /dev/null +++ b/test/MSVC/pch_gen/pch_gen.py @@ -0,0 +1,66 @@ +#!/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() + +# include all of msvc_fixture's files +test.dir_fixture('../msvc_fixture','src') + +# Then we'll replace the SConstruct with one specific to this test. +test.file_fixture('fixture/SConstruct', + 'SConstruct') + +test.run(arguments='.') + +test.must_exist(test.workpath('output1/test.exe')) +test.must_exist(test.workpath('output1/test.res')) +test.must_exist(test.workpath('output1/test.pdb')) +test.must_exist(test.workpath('output1/StdAfx-1.pch')) +test.must_exist(test.workpath('output1/StdAfx-1.obj')) + +test.run(arguments="-c .") +test.run(arguments="DISABLE_PCH=1 .") + +test.must_exist(test.workpath('output1/test.exe')) +test.must_exist(test.workpath('output1/test.res')) +test.must_exist(test.workpath('output1/test.pdb')) +test.fail_test(condition = ('/Yuoutput1/StdAfx.h' in test.stdout()), message="Shouldn't have output1/YuStdAfx.h in compile line when PCH is disabled") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Repository/CPPPATH.py b/test/Repository/CPPPATH.py index 93c6ffe..e523fe8 100644 --- a/test/Repository/CPPPATH.py +++ b/test/Repository/CPPPATH.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import sys -from TestSCons import TestSCons, _exe +from TestSCons import TestSCons test = TestSCons() diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py index 709f1ca..72e2d27 100644 --- a/test/Repository/SConscript.py +++ b/test/Repository/SConscript.py @@ -28,7 +28,7 @@ Test how we handle SConscript calls when using a Repository. """ import sys -from TestSCons import TestSCons, _exe +from TestSCons import TestSCons test = TestSCons() diff --git a/test/Repository/multi-dir.py b/test/Repository/multi-dir.py index 6500581..757ed0c 100644 --- a/test/Repository/multi-dir.py +++ b/test/Repository/multi-dir.py @@ -25,7 +25,7 @@ import sys -from TestSCons import TestSCons, _exe +from TestSCons import TestSCons test = TestSCons() diff --git a/test/ninja/build_libraries.py b/test/ninja/build_libraries.py index 385a493..325031b 100644 --- a/test/ninja/build_libraries.py +++ b/test/ninja/build_libraries.py @@ -25,7 +25,7 @@ import os import TestSCons from TestCmd import IS_WINDOWS, IS_MACOS -from TestSCons import _python_, _exe, _lib, lib_, _dll, dll_ +from TestSCons import _exe, _lib, lib_, _dll, dll_ test = TestSCons.TestSCons() diff --git a/test/textfile/fixture/SConstruct b/test/textfile/fixture/SConstruct index 8cfe909..60e7225 100644 --- a/test/textfile/fixture/SConstruct +++ b/test/textfile/fixture/SConstruct @@ -1,6 +1,5 @@ DefaultEnvironment(tools=[]) - env = Environment(tools=['textfile']) data0 = ['Goethe', 'Schiller'] data = ['lalala', 42, data0, 'tanteratei'] @@ -10,6 +9,10 @@ env.Textfile('foo2', data, LINESEPARATOR='|*') env.Textfile('foo1a.txt', data + ['']) env.Textfile('foo2a.txt', data + [''], LINESEPARATOR='|*') +issue_4021_textfile = r'<HintPath>..\..\..\@HINT_PATH@\Datalogics.PDFL.dll</HintPath>' +env.Textfile('issue-4021.txt', issue_4021_textfile, + SUBST_DICT={'@HINT_PATH@': r'NETCore\bin\$$(Platform)\$$(Configuration)'}) + # recreate the list with the data wrapped in Value() data0 = list(map(Value, data0)) data = list(map(Value, data)) diff --git a/test/textfile/textfile.py b/test/textfile/textfile.py index 0f2e18e..936eaf5 100644 --- a/test/textfile/textfile.py +++ b/test/textfile/textfile.py @@ -1,6 +1,7 @@ #!/usr/bin/env python +# MIT License # -# __COPYRIGHT__ +# 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 @@ -20,9 +21,6 @@ # 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons @@ -30,7 +28,7 @@ import os test = TestSCons.TestSCons() -foo1 = test.workpath('foo1.txt') +# foo1 = test.workpath('foo1.txt') # foo2 = test.workpath('foo2.txt') # foo1a = test.workpath('foo1a.txt') # foo2a = test.workpath('foo2a.txt') @@ -51,6 +49,8 @@ foo2Text = '|*'.join(textparts) foo1aText = foo1Text + linesep foo2aText = foo2Text + '|*' +issue_4021_text = r'<HintPath>..\..\..\NETCore\bin\$(Platform)\$(Configuration)\Datalogics.PDFL.dll</HintPath>' + test.up_to_date(arguments='.') files = list(map(test.workpath, ( @@ -81,6 +81,7 @@ test.must_match('foo1a.txt', foo1aText, mode=match_mode) test.must_match('bar1a.txt', foo1aText, mode=match_mode) test.must_match('foo2a.txt', foo2aText, mode=match_mode) test.must_match('bar2a.txt', foo2aText, mode=match_mode) +test.must_match('issue-4021.txt', issue_4021_text, mode=match_mode) check_times() # write the contents and make sure the files |