diff options
author | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2021-10-05 11:55:50 (GMT) |
---|---|---|
committer | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2021-10-05 11:55:50 (GMT) |
commit | 704be25ce5f435c9fb469eb840b9b443685bf992 (patch) | |
tree | e2242de8905ac2f54a2de9ca5901effd4254a7ae /test | |
parent | 271293587215f0a3c255a37202158c0fa5795cbb (diff) | |
parent | 43f775a78f1d78515654e72c1280b074fd4c1899 (diff) | |
download | SCons-704be25ce5f435c9fb469eb840b9b443685bf992.zip SCons-704be25ce5f435c9fb469eb840b9b443685bf992.tar.gz SCons-704be25ce5f435c9fb469eb840b9b443685bf992.tar.bz2 |
Merge branch 'master' into jbrill-msvs-2022
Manually resolve conflict in CHANGES.txt
Diffstat (limited to 'test')
25 files changed, 267 insertions, 85 deletions
diff --git a/test/CC/gcc-non-utf8-fixture/.exclude_tests b/test/CC/gcc-non-utf8-fixture/.exclude_tests new file mode 100644 index 0000000..f0608bf --- /dev/null +++ b/test/CC/gcc-non-utf8-fixture/.exclude_tests @@ -0,0 +1,2 @@ +data +gcc-non-utf8.py diff --git a/test/CC/gcc-non-utf8-fixture/data b/test/CC/gcc-non-utf8-fixture/data new file mode 100644 index 0000000..740064b --- /dev/null +++ b/test/CC/gcc-non-utf8-fixture/data @@ -0,0 +1,10 @@ +gcc (tdm-1) 9.2.0 +Copyright (C) 2019 Free Software Foundation, Inc. +Ýòî ñâîáîäíî ðàñïðîñòðàíÿåìîå ïðîãðàììíîå îáåñïå÷åíèå. Óñëîâèÿ êîïèðîâàíèÿ +ïðèâåäåíû â èñõîäíûõ òåêñòàõ. + + Áåç ãàðàíòèè êàêèõ-ëèáî êà÷åñòâ, âêëþ÷àÿ +êîììåð÷åñêóþ öåííîñòü è ïðèìåíèìîñòü äëÿ êàêèõ-ëèáî öåëåé. + + + diff --git a/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py b/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py new file mode 100644 index 0000000..daa5fe2 --- /dev/null +++ b/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py @@ -0,0 +1,8 @@ +import sys + +print(f"In {sys.argv[0]}") + +if __name__ == '__main__': + if '--version' in sys.argv: + with open("data", "rb") as f: + sys.stdout.buffer.write(f.read()) diff --git a/test/CC/gcc-version.py b/test/CC/gcc-version.py new file mode 100644 index 0000000..13defec --- /dev/null +++ b/test/CC/gcc-version.py @@ -0,0 +1,65 @@ +#!/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. + +""" +Test that if gcc returns non-UTF8 text, the version check doesn't fall over. +""" + +import sys + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.dir_fixture('gcc-non-utf8-fixture') + +test.write( + 'SConstruct', + """ +import sys + +DefaultEnvironment(tools=[]) +env = Environment(tools=[], CC="%(_python_)s gcc-non-utf8.py") +try: + env.Tool('gcc') +except UnicodeDecodeError: + print("Failed decoding gcc version message.", file=sys.stderr) + Exit(1) +""" + % locals(), +) + +test.run(arguments='.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/scanner-target.py b/test/CacheDir/scanner-target.py index 202910b..44ba199 100644 --- a/test/CacheDir/scanner-target.py +++ b/test/CacheDir/scanner-target.py @@ -53,11 +53,9 @@ def sillyScanner(node, env, dirs): print('This is never called (unless we build file.out)') return [] -SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) +SillyScanner = SCons.Scanner.ScannerBase(function=sillyScanner, skeys=['.res']) -env = Environment(tools=[], - SCANNERS = [SillyScanner], - BUILDERS = {}) +env = Environment(tools=[], SCANNERS=[SillyScanner], BUILDERS={}) r = env.Command('file.res', 'file.ma', docopy) diff --git a/test/CacheDir/source-scanner.py b/test/CacheDir/source-scanner.py index 1c56499..1f6fef0 100644 --- a/test/CacheDir/source-scanner.py +++ b/test/CacheDir/source-scanner.py @@ -57,11 +57,9 @@ def sillyScanner(node, env, dirs): print('This is never called (unless we build file.out)') return [] -SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) +SillyScanner = SCons.Scanner.ScannerBase(function=sillyScanner, skeys=['.res']) -env = Environment(tools=[], - SCANNERS = [SillyScanner], - BUILDERS = {}) +env = Environment(tools=[], SCANNERS=[SillyScanner], BUILDERS={}) r = env.Command('file.res', 'file.ma', docopy) 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() |