diff options
author | William Deegan <bill@baddogconsulting.com> | 2022-05-12 18:46:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-12 18:46:28 (GMT) |
commit | 63c39b37c641f71bde1939bd4e4d22b7eecdb403 (patch) | |
tree | 0438489eccf9c675ffca9c54ddfc98a71e9b6086 /test | |
parent | 50df0c523b69b1ec832e1b39f6fd16fcd139f36e (diff) | |
parent | fdae889759be56c6299bcedc577aecf2225f0190 (diff) | |
download | SCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.zip SCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.tar.gz SCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.tar.bz2 |
Merge branch 'master' into ninja_always_execute
Diffstat (limited to 'test')
-rw-r--r-- | test/Actions/subst_shell_env-fixture/SConstruct | 26 | ||||
-rw-r--r-- | test/Actions/subst_shell_env.py | 48 | ||||
-rw-r--r-- | test/Dir/source.py | 2 |
3 files changed, 76 insertions, 0 deletions
diff --git a/test/Actions/subst_shell_env-fixture/SConstruct b/test/Actions/subst_shell_env-fixture/SConstruct new file mode 100644 index 0000000..6e48add --- /dev/null +++ b/test/Actions/subst_shell_env-fixture/SConstruct @@ -0,0 +1,26 @@ +import sys + +def custom_environment_expansion(env, target, source): + ENV = env['ENV'].copy() + ENV['EXPANDED_SHELL_VAR'] = env.subst(env['ENV']['EXPANDED_SHELL_VAR'], target=target, source=source) + return ENV + +def expand_this_generator(env, target, source, for_signature): + return "I_got_expanded_to_" + str(target[0]) + +env = Environment(tools=['textfile']) + +env['SHELL_ENV_GENERATOR'] = custom_environment_expansion + +env['EXPAND_THIS'] = expand_this_generator +env['ENV']['EXPANDED_SHELL_VAR'] = "$EXPAND_THIS" +env['ENV']['NON_EXPANDED_SHELL_VAR'] = "$EXPAND_THIS" + +env.Textfile('expand_script.py', [ + 'import os', + 'print(os.environ["EXPANDED_SHELL_VAR"])', + 'print(os.environ["NON_EXPANDED_SHELL_VAR"])', +]) +env.Command('out.txt', 'expand_script.py', fr'{sys.executable} $SOURCE > $TARGET') + +env.Depends('out.txt', env.Command('out2.txt', 'expand_script.py', fr'{sys.executable} $SOURCE > $TARGET')) diff --git a/test/Actions/subst_shell_env.py b/test/Actions/subst_shell_env.py new file mode 100644 index 0000000..9f5c5db --- /dev/null +++ b/test/Actions/subst_shell_env.py @@ -0,0 +1,48 @@ +#!/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. +# + + +""" +Verify that shell environment variables can be expanded per target/source +when exectuting actions on the command line. +""" +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.dir_fixture('subst_shell_env-fixture') + +test.run(arguments = ['-Q']) +test.must_match('out.txt', f"I_got_expanded_to_out.txt{os.linesep}$EXPAND_THIS{os.linesep}") +test.must_match('out2.txt', f"I_got_expanded_to_out2.txt{os.linesep}$EXPAND_THIS{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/Dir/source.py b/test/Dir/source.py index f38b07d..c35d169 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -106,6 +106,8 @@ test.up_to_date(arguments='cmd-content.out') test.up_to_date(arguments='cmd-tstamp-noscan.out') test.up_to_date(arguments='cmd-content-noscan.out') +test.sleep() + test.write([ 'tstamp', 'foo.txt' ], 'foo.txt 2\n') test.not_up_to_date(arguments='tstamp.out') |