From cbda1ddea022045b34fb6f37f15a9a82eca506cd Mon Sep 17 00:00:00 2001 From: Mike Hendricks Date: Fri, 12 Jan 2024 12:04:19 -0800 Subject: [PATCH] "Hab launch returns the error code returned by the called alias" testing --- tests/reference_scripts/ps1_activate_launch/hab_config.ps1 | 2 ++ tests/reference_scripts/ps1_env/hab_launch.ps1 | 3 ++- tests/reference_scripts/ps1_env_launch/hab_config.ps1 | 2 ++ tests/reference_scripts/ps1_env_launch/hab_launch.ps1 | 3 ++- tests/reference_scripts/ps1_launch/hab_config.ps1 | 2 ++ tests/reference_scripts/ps1_launch/hab_launch.ps1 | 3 ++- tests/reference_scripts/ps1_launch_args/hab_config.ps1 | 2 ++ tests/reference_scripts/ps1_launch_args/hab_launch.ps1 | 3 ++- tests/reference_scripts/sh_linux_activate/hab_config.sh | 5 +++++ .../reference_scripts/sh_linux_activate_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_linux_env/hab_config.sh | 5 +++++ tests/reference_scripts/sh_linux_env/hab_launch.sh | 1 + tests/reference_scripts/sh_linux_env_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_linux_env_launch/hab_launch.sh | 1 + tests/reference_scripts/sh_linux_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_linux_launch/hab_launch.sh | 1 + tests/reference_scripts/sh_linux_launch_args/hab_config.sh | 5 +++++ tests/reference_scripts/sh_linux_launch_args/hab_launch.sh | 1 + tests/reference_scripts/sh_win_activate/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_activate_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_env/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_env/hab_launch.sh | 1 + tests/reference_scripts/sh_win_env_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_env_launch/hab_launch.sh | 1 + tests/reference_scripts/sh_win_launch/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_launch/hab_launch.sh | 1 + tests/reference_scripts/sh_win_launch_args/hab_config.sh | 5 +++++ tests/reference_scripts/sh_win_launch_args/hab_launch.sh | 1 + 28 files changed, 84 insertions(+), 4 deletions(-) diff --git a/tests/reference_scripts/ps1_activate_launch/hab_config.ps1 b/tests/reference_scripts/ps1_activate_launch/hab_config.ps1 index 385d071..c70cc56 100644 --- a/tests/reference_scripts/ps1_activate_launch/hab_config.ps1 +++ b/tests/reference_scripts/ps1_activate_launch/hab_config.ps1 @@ -95,3 +95,5 @@ function pip() { # Run the requested command pip +# Ensure the exit-code is reported to the calling process. +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_env/hab_launch.ps1 b/tests/reference_scripts/ps1_env/hab_launch.ps1 index 95b0e6f..a353e85 100644 --- a/tests/reference_scripts/ps1_env/hab_launch.ps1 +++ b/tests/reference_scripts/ps1_env/hab_launch.ps1 @@ -1 +1,2 @@ -powershell.exe -NoExit -ExecutionPolicy Unrestricted . "{{ tmpdir / "hab_config.ps1" }}" +powershell.exe -NoExit -ExecutionPolicy Unrestricted -File "{{ tmpdir / "hab_config.ps1" }}" +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_env_launch/hab_config.ps1 b/tests/reference_scripts/ps1_env_launch/hab_config.ps1 index 385d071..c70cc56 100644 --- a/tests/reference_scripts/ps1_env_launch/hab_config.ps1 +++ b/tests/reference_scripts/ps1_env_launch/hab_config.ps1 @@ -95,3 +95,5 @@ function pip() { # Run the requested command pip +# Ensure the exit-code is reported to the calling process. +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_env_launch/hab_launch.ps1 b/tests/reference_scripts/ps1_env_launch/hab_launch.ps1 index 95b0e6f..a353e85 100644 --- a/tests/reference_scripts/ps1_env_launch/hab_launch.ps1 +++ b/tests/reference_scripts/ps1_env_launch/hab_launch.ps1 @@ -1 +1,2 @@ -powershell.exe -NoExit -ExecutionPolicy Unrestricted . "{{ tmpdir / "hab_config.ps1" }}" +powershell.exe -NoExit -ExecutionPolicy Unrestricted -File "{{ tmpdir / "hab_config.ps1" }}" +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_launch/hab_config.ps1 b/tests/reference_scripts/ps1_launch/hab_config.ps1 index 385d071..c70cc56 100644 --- a/tests/reference_scripts/ps1_launch/hab_config.ps1 +++ b/tests/reference_scripts/ps1_launch/hab_config.ps1 @@ -95,3 +95,5 @@ function pip() { # Run the requested command pip +# Ensure the exit-code is reported to the calling process. +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_launch/hab_launch.ps1 b/tests/reference_scripts/ps1_launch/hab_launch.ps1 index 9afa142..cf86f17 100644 --- a/tests/reference_scripts/ps1_launch/hab_launch.ps1 +++ b/tests/reference_scripts/ps1_launch/hab_launch.ps1 @@ -1 +1,2 @@ -powershell.exe -ExecutionPolicy Unrestricted . "{{ tmpdir / "hab_config.ps1" }}" +powershell.exe -ExecutionPolicy Unrestricted -File "{{ tmpdir / "hab_config.ps1" }}" +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_launch_args/hab_config.ps1 b/tests/reference_scripts/ps1_launch_args/hab_config.ps1 index ef5ab95..5f6ef37 100644 --- a/tests/reference_scripts/ps1_launch_args/hab_config.ps1 +++ b/tests/reference_scripts/ps1_launch_args/hab_config.ps1 @@ -95,3 +95,5 @@ function pip() { # Run the requested command as_str -c "print('Running...');import sys;print('sys', sys)" +# Ensure the exit-code is reported to the calling process. +exit $LASTEXITCODE diff --git a/tests/reference_scripts/ps1_launch_args/hab_launch.ps1 b/tests/reference_scripts/ps1_launch_args/hab_launch.ps1 index 9afa142..cf86f17 100644 --- a/tests/reference_scripts/ps1_launch_args/hab_launch.ps1 +++ b/tests/reference_scripts/ps1_launch_args/hab_launch.ps1 @@ -1 +1,2 @@ -powershell.exe -ExecutionPolicy Unrestricted . "{{ tmpdir / "hab_config.ps1" }}" +powershell.exe -ExecutionPolicy Unrestricted -File "{{ tmpdir / "hab_config.ps1" }}" +exit $LASTEXITCODE diff --git a/tests/reference_scripts/sh_linux_activate/hab_config.sh b/tests/reference_scripts/sh_linux_activate/hab_config.sh index 5cce1b9..8fc3824 100644 --- a/tests/reference_scripts/sh_linux_activate/hab_config.sh +++ b/tests/reference_scripts/sh_linux_activate/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_activate_launch/hab_config.sh b/tests/reference_scripts/sh_linux_activate_launch/hab_config.sh index cd93017..6a33ac4 100644 --- a/tests/reference_scripts/sh_linux_activate_launch/hab_config.sh +++ b/tests/reference_scripts/sh_linux_activate_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_env/hab_config.sh b/tests/reference_scripts/sh_linux_env/hab_config.sh index 5cce1b9..8fc3824 100644 --- a/tests/reference_scripts/sh_linux_env/hab_config.sh +++ b/tests/reference_scripts/sh_linux_env/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_env/hab_launch.sh b/tests/reference_scripts/sh_linux_env/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_linux_env/hab_launch.sh +++ b/tests/reference_scripts/sh_linux_env/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_linux_env_launch/hab_config.sh b/tests/reference_scripts/sh_linux_env_launch/hab_config.sh index cd93017..6a33ac4 100644 --- a/tests/reference_scripts/sh_linux_env_launch/hab_config.sh +++ b/tests/reference_scripts/sh_linux_env_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_env_launch/hab_launch.sh b/tests/reference_scripts/sh_linux_env_launch/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_linux_env_launch/hab_launch.sh +++ b/tests/reference_scripts/sh_linux_env_launch/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_linux_launch/hab_config.sh b/tests/reference_scripts/sh_linux_launch/hab_config.sh index aa80be5..119b35c 100644 --- a/tests/reference_scripts/sh_linux_launch/hab_config.sh +++ b/tests/reference_scripts/sh_linux_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_launch/hab_launch.sh b/tests/reference_scripts/sh_linux_launch/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_linux_launch/hab_launch.sh +++ b/tests/reference_scripts/sh_linux_launch/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_linux_launch_args/hab_config.sh b/tests/reference_scripts/sh_linux_launch_args/hab_config.sh index 8df56a4..83a8c03 100644 --- a/tests/reference_scripts/sh_linux_launch_args/hab_config.sh +++ b/tests/reference_scripts/sh_linux_launch_args/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_linux_launch_args/hab_launch.sh b/tests/reference_scripts/sh_linux_launch_args/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_linux_launch_args/hab_launch.sh +++ b/tests/reference_scripts/sh_linux_launch_args/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_win_activate/hab_config.sh b/tests/reference_scripts/sh_win_activate/hab_config.sh index 590b1a8..c04326c 100644 --- a/tests/reference_scripts/sh_win_activate/hab_config.sh +++ b/tests/reference_scripts/sh_win_activate/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_activate_launch/hab_config.sh b/tests/reference_scripts/sh_win_activate_launch/hab_config.sh index 9711586..b7b1b5b 100644 --- a/tests/reference_scripts/sh_win_activate_launch/hab_config.sh +++ b/tests/reference_scripts/sh_win_activate_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_env/hab_config.sh b/tests/reference_scripts/sh_win_env/hab_config.sh index 590b1a8..c04326c 100644 --- a/tests/reference_scripts/sh_win_env/hab_config.sh +++ b/tests/reference_scripts/sh_win_env/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_env/hab_launch.sh b/tests/reference_scripts/sh_win_env/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_win_env/hab_launch.sh +++ b/tests/reference_scripts/sh_win_env/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_win_env_launch/hab_config.sh b/tests/reference_scripts/sh_win_env_launch/hab_config.sh index 9711586..b7b1b5b 100644 --- a/tests/reference_scripts/sh_win_env_launch/hab_config.sh +++ b/tests/reference_scripts/sh_win_env_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_env_launch/hab_launch.sh b/tests/reference_scripts/sh_win_env_launch/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_win_env_launch/hab_launch.sh +++ b/tests/reference_scripts/sh_win_env_launch/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_win_launch/hab_config.sh b/tests/reference_scripts/sh_win_launch/hab_config.sh index 36e611f..259b7bf 100644 --- a/tests/reference_scripts/sh_win_launch/hab_config.sh +++ b/tests/reference_scripts/sh_win_launch/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_launch/hab_launch.sh b/tests/reference_scripts/sh_win_launch/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_win_launch/hab_launch.sh +++ b/tests/reference_scripts/sh_win_launch/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}" diff --git a/tests/reference_scripts/sh_win_launch_args/hab_config.sh b/tests/reference_scripts/sh_win_launch_args/hab_config.sh index cb87de5..0e108f5 100644 --- a/tests/reference_scripts/sh_win_launch_args/hab_config.sh +++ b/tests/reference_scripts/sh_win_launch_args/hab_config.sh @@ -1,6 +1,11 @@ # Customize the prompt export PS1="[not_set/child] $PS1" +# Exit immediately if a command exits with a non-zero status. +# This ensures that if any exit codes are encountered it gets propagated to +# whatever originally called hab. +set -e + # Setting global environment variables: unset UNSET_VARIABLE export TEST="case" diff --git a/tests/reference_scripts/sh_win_launch_args/hab_launch.sh b/tests/reference_scripts/sh_win_launch_args/hab_launch.sh index 3c3fcd8..5722dd0 100644 --- a/tests/reference_scripts/sh_win_launch_args/hab_launch.sh +++ b/tests/reference_scripts/sh_win_launch_args/hab_launch.sh @@ -1 +1,2 @@ +set -e bash --init-file "{{ tmpdir / "hab_config.sh" }}"