Skip to content

Commit f770eff

Browse files
committed
testsuite: test handling of PYTHONPATH
Problem: The testsuite does not ensure that PYTHONPATH is not exported by default by flux(1), but is for the `python` and `env` subcommands. Add tests to t1102-cmddriver.t that verify the expected handling of PYTHONPATH by flux commands.
1 parent 721844f commit f770eff

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

t/t1102-cmddriver.t

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ test_expect_success 'flux env passes cmddriver option to argument' "
5757
(FLUX_URI=foo://xyx \
5858
flux env sh -c 'echo \$FLUX_URI' | grep '^foo://xyx$')
5959
"
60+
test_expect_success 'flux env prepends to PYTHONPATH' '
61+
expected=$(flux config builtin python_path | sed "s/:.*//") &&
62+
result=$(PYTHONPATH= flux env sh -c "echo \$PYTHONPATH") &&
63+
test_debug "echo expecting PYTHONPATH=$expected got $result" &&
64+
echo "$result" | grep $expected
65+
'
66+
test_expect_success 'flux env outputs PYTHONPATH' '
67+
expected=$(flux config builtin python_path | sed "s/:.*//") &&
68+
result=$(PYTHONPATH= flux env | grep PYTHONPATH) &&
69+
test_debug "echo expecting PYTHONPATH=$expected got $result" &&
70+
echo "$result" | grep $expected
71+
'
72+
test_expect_success 'flux python prepends to PYTHONPATH' '
73+
expected=$(flux config builtin python_path | sed "s/:.*//") &&
74+
test_debug "echo expecting PYTHONPATH=$expected" &&
75+
PYTHONPATH= \
76+
flux python -c "import os; print(os.environ[\"PYTHONPATH\"])" \
77+
| grep $expected
78+
'
79+
test_expect_success 'flux does not prepend to PYTHONPATH' '
80+
printenv=$(which printenv) &&
81+
( unset PYTHONPATH &&
82+
test_must_fail flux $printenv PYTHONPATH)
83+
'
6084
# push /foo twice onto PYTHONPATH -- ensure it is leftmost position:
6185
#test_expect_success 'cmddriver pushes dup path elements onto front of PATH' "
6286
# flux -P /foo env flux -P /bar env flux -P /foo env \

0 commit comments

Comments
 (0)