From 0d080212d255764a910db96da76a61c88008320f Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Tue, 30 Jul 2019 22:19:32 +0200 Subject: [PATCH] Verify (re-)initialization of SDKMAN env vars works. - Add new test that covers the two cases considered so far. Housekeeping: - Add `.gitignore` - Add `.editorconfig` --- .editorconfig | 5 +++++ .gitignore | 2 ++ .travis.yml | 1 + test/reinitialize.fish | 25 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100755 test/reinitialize.fish diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0009889 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98c52b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +test/*_fish +test/*_bash diff --git a/.travis.yml b/.travis.yml index 33a29f7..c227e31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,6 @@ install: script: - ruby test/completion.rb - fish test/wrapper.fish + - fish test/reinitialize.fish - bash -c "sdk install crash 1.3.0; sdk uninstall crash 1.3.0"; fish test/10_zombies_new.fish diff --git a/test/reinitialize.fish b/test/reinitialize.fish new file mode 100755 index 0000000..23cb921 --- /dev/null +++ b/test/reinitialize.fish @@ -0,0 +1,25 @@ +# If either of +# - $SDKMAN_DIR is unset +# - $SDKMAN_DIR points to a directory not owned by the current user +# is true, sdkman-for-fish should run sdkman's init script. + +# Assumes sdkman-for-fish is installed +set proper_value "$SDKMAN_DIR" + +begin + set -e SDKMAN_DIR + set in_new_shell (fish -lc 'echo $SDKMAN_DIR') + if [ "$in_new_shell" != "$proper_value" ] + echo "SDKMAN_DIR initialized to $in_new_shell instead of $proper_value" + exit 1 + end +end + +begin + set SDKMAN_DIR "/" # belongs to root, who hopefully doesn't run this + set in_new_shell (fish -lc 'echo $SDKMAN_DIR') + if [ "$in_new_shell" != "$proper_value" ] + echo "SDKMAN_DIR reinitialized to $in_new_shell instead of $proper_value" + exit 1 + end +end