diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-10-06 03:19:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 03:19:14 (GMT) |
commit | d6e9551dd3d9606d606a8e90d2a40d9e255dc540 (patch) | |
tree | 2449a76682912c49d40661ae218a141f0dfc4022 /test | |
parent | 00f6b1a868af4543f14b385d63ec274d6feca3e8 (diff) | |
parent | ed00f8fafdc7305eff8116a1ae2d3b4c2c5e30d5 (diff) | |
download | SCons-d6e9551dd3d9606d606a8e90d2a40d9e255dc540.zip SCons-d6e9551dd3d9606d606a8e90d2a40d9e255dc540.tar.gz SCons-d6e9551dd3d9606d606a8e90d2a40d9e255dc540.tar.bz2 |
Merge branch 'master' into ninja_fix_mkdir
Diffstat (limited to 'test')
-rw-r--r-- | test/CC/gcc-non-utf8-fixture/.exclude_tests | 2 | ||||
-rw-r--r-- | test/CC/gcc-non-utf8-fixture/data | 10 | ||||
-rw-r--r-- | test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py | 8 | ||||
-rw-r--r-- | test/CC/gcc-version.py | 65 | ||||
-rw-r--r-- | test/CacheDir/scanner-target.py | 6 | ||||
-rw-r--r-- | test/CacheDir/source-scanner.py | 6 | ||||
-rw-r--r-- | test/ninja/force_scons_callback.py | 88 | ||||
-rw-r--r-- | test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback | 8 |
8 files changed, 185 insertions, 8 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/ninja/force_scons_callback.py b/test/ninja/force_scons_callback.py new file mode 100644 index 0000000..55c12ca --- /dev/null +++ b/test/ninja/force_scons_callback.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# +# 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. +# + +import os + +import TestSCons +from TestCmd import IS_WINDOWS + +test = TestSCons.TestSCons() + +try: + import ninja +except ImportError: + test.skip_test("Could not find module in python") + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +ninja_bin = os.path.abspath(os.path.join( + ninja.__file__, + os.pardir, + 'data', + 'bin', + 'ninja' + _exe)) + +test.dir_fixture('ninja-fixture') + +test.file_fixture('ninja_test_sconscripts/sconstruct_force_scons_callback', 'SConstruct') + +# generate simple build +test.run(stdout=None) +test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) +test.must_contain_all(test.stdout(), 'Executing:') +test.must_contain_all(test.stdout(), 'ninja%(_exe)s -f' % locals()) +if test.stdout().count('scons: Building targets') != 2: + test.fail_test() +test.must_match('out.txt', 'foo.c' + os.linesep) +test.must_match('out2.txt', "test2.cpp" + os.linesep) + +# clean build and ninja files +test.run(arguments='-c', stdout=None) +test.must_contain_all_lines(test.stdout(), [ + 'Removed out.txt', + 'Removed out2.txt', + 'Removed build.ninja']) + +# only generate the ninja file +test.run(arguments='--disable-execute-ninja', stdout=None) +test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) +test.must_not_exist(test.workpath('out.txt')) +test.must_not_exist(test.workpath('out2.txt')) + +# run ninja independently +program = test.workpath('run_ninja_env.bat') if IS_WINDOWS else ninja_bin +test.run(program=program, stdout=None) +if test.stdout().count('scons: Building targets') != 1: + test.fail_test() +test.must_match('out.txt', 'foo.c' + os.linesep) +test.must_match('out2.txt', "test2.cpp" + os.linesep) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback b/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback new file mode 100644 index 0000000..55729a6 --- /dev/null +++ b/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback @@ -0,0 +1,8 @@ +SetOption('experimental','ninja') +DefaultEnvironment(tools=[]) + +env = Environment(tools=[]) +env.Tool('ninja') + +env.Command('out.txt', 'foo.c', 'echo $SOURCE> $TARGET', NINJA_FORCE_SCONS_BUILD=True) +env.Command('out2.txt', 'test2.cpp', 'echo $SOURCE> $TARGET')
\ No newline at end of file |