feat(pm): isolate developer test environment from runtime extras
This commit is contained in:
28
activate
28
activate
@@ -18,15 +18,41 @@
|
||||
# install` and `hermes update` keep that check.
|
||||
# ============================================================================
|
||||
_HERMES_REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# Options: `--test-extras a,b` selects the test environment's runtime extras
|
||||
# (default: [all]); `--` ends options.
|
||||
# A bare `source ./activate` inherits the caller's positional parameters.
|
||||
# Ignore unrelated words so scripts with their own arguments can source it.
|
||||
_hermes_test_env="--test-environment"
|
||||
_hermes_expect_extras=""
|
||||
for _hermes_arg in "$@"; do
|
||||
if [ -n "$_hermes_expect_extras" ]; then
|
||||
_hermes_test_env="--test-environment=$_hermes_arg"
|
||||
_hermes_expect_extras=""
|
||||
continue
|
||||
fi
|
||||
case "$_hermes_arg" in
|
||||
--) break ;;
|
||||
--test-extras) _hermes_expect_extras=1 ;;
|
||||
--test-extras=*) _hermes_test_env="--test-environment=${_hermes_arg#--test-extras=}" ;;
|
||||
*) : ;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$_hermes_expect_extras" ]; then
|
||||
printf '%s\n' 'activate: --test-extras needs a comma-separated list' >&2
|
||||
unset _hermes_arg _hermes_test_env _hermes_expect_extras
|
||||
return 2 2>/dev/null || exit 2
|
||||
fi
|
||||
# Setup runs in a child: failures must not exit or partially activate the
|
||||
# caller's shell, and activation must not republish launchers or shell config.
|
||||
if ! (
|
||||
unset PYTHONHOME PYTHONPATH VIRTUAL_ENV
|
||||
bash "$_HERMES_REPO/setup-hermes.sh" --runtime-only
|
||||
bash "$_HERMES_REPO/setup-hermes.sh" --runtime-only "$_hermes_test_env"
|
||||
) >&2; then
|
||||
printf '%s\n' 'activate: setup failed; shell environment unchanged' >&2
|
||||
unset _hermes_arg _hermes_test_env _hermes_expect_extras
|
||||
return 1 2>/dev/null || exit 1
|
||||
fi
|
||||
unset _hermes_arg _hermes_test_env _hermes_expect_extras
|
||||
|
||||
# Guard against double-sourcing: venv activate precedent (re-activating is a
|
||||
# no-op re-save; we keep it idempotent by deactivating first). Key on the
|
||||
|
||||
Reference in New Issue
Block a user