summaryrefslogtreecommitdiffstats
path: root/test/Actions
diff options
context:
space:
mode:
authorDaniel Moody <dmoody256@gmail.com>2022-05-10 16:46:55 (GMT)
committerDaniel Moody <dmoody256@gmail.com>2022-05-10 16:46:55 (GMT)
commit50fd3e098ec2271acab5a9622cb3b0191bce4455 (patch)
treee83fac8abf4bf0a41a76f97341a36a9da26681e7 /test/Actions
parentcc811439cbb2a8b57d8626b1dec360ea37eb0ace (diff)
downloadSCons-50fd3e098ec2271acab5a9622cb3b0191bce4455.zip
SCons-50fd3e098ec2271acab5a9622cb3b0191bce4455.tar.gz
SCons-50fd3e098ec2271acab5a9622cb3b0191bce4455.tar.bz2
added test for EXPANDED_SHELL_VAR
Diffstat (limited to 'test/Actions')
-rw-r--r--test/Actions/subst_shell_env-fixture/SConstruct24
-rw-r--r--test/Actions/subst_shell_env.py50
2 files changed, 74 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..1d6d2ef
--- /dev/null
+++ b/test/Actions/subst_shell_env-fixture/SConstruct
@@ -0,0 +1,24 @@
+import sys
+
+def custom_environment_expansion(env, target, source):
+ ENV = env['ENV']
+ 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_EXPANDER'] = 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', f'{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..fda3e00
--- /dev/null
+++ b/test/Actions/subst_shell_env.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that an Action list with a string command containing a Unicode file
+name, and a Python function action, works corectly. This verifies that
+the signatures of the two actions can be concatenated without encoding
+Unicode problems.
+"""
+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.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: