From cefdf5c917b3a0be627aecb7166adf28c55a8022 Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Thu, 27 Jan 2022 21:02:14 -0800 Subject: [PATCH 1/4] Override language to English The two tests hardcode the error message, so they are language- dependent. --- test/unit/chruby_reset_test.sh | 3 +++ test/unit/chruby_use_test.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/unit/chruby_reset_test.sh b/test/unit/chruby_reset_test.sh index 5e19ed60..d83655c4 100755 --- a/test/unit/chruby_reset_test.sh +++ b/test/unit/chruby_reset_test.sh @@ -15,10 +15,13 @@ function test_chruby_reset_hash_table() assertEquals "did not clear the path table" \ "" "$(hash)" elif [[ -n "$BASH_VERSION" ]]; then + export LANG=en_US.UTF-8 chruby_reset assertEquals "did not clear the path table" \ "hash: hash table empty" "$(hash)" + + unset LANG fi } diff --git a/test/unit/chruby_use_test.sh b/test/unit/chruby_use_test.sh index 7cd8e049..568d7450 100755 --- a/test/unit/chruby_use_test.sh +++ b/test/unit/chruby_use_test.sh @@ -8,10 +8,13 @@ function test_chruby_clears_hash_table() assertEquals "did not clear the path table" \ "" "$(hash)" elif [[ -n "$BASH_VERSION" ]]; then + export LANG=en_US.UTF-8 chruby_use "$test_ruby_root" >/dev/null assertEquals "did not clear the path table" \ "hash: hash table empty" "$(hash)" + + unset LANG fi } From 49c9b49c26da6dbad71c4fac6073984101e3a84f Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Thu, 27 Jan 2022 22:24:25 -0800 Subject: [PATCH 2/4] Explicitly set the return value for hooks Otherwise it returns with the last status, and shows misleading error messages like shunit2:WARN oneTimeTearDown() returned non-zero return code. --- test/integration/helper.sh | 6 +++--- test/unit/helper.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integration/helper.sh b/test/integration/helper.sh index 74185bf1..7f053791 100644 --- a/test/integration/helper.sh +++ b/test/integration/helper.sh @@ -13,6 +13,6 @@ original_pwd="$PWD" original_ruby="$(command -v ruby 2>/dev/null)" original_gem="$(command -v gem 2>/dev/null)" -setUp() { return; } -tearDown() { return; } -oneTimeTearDown() { return; } +setUp() { return 0; } +tearDown() { return 0; } +oneTimeTearDown() { return 0; } diff --git a/test/unit/helper.sh b/test/unit/helper.sh index 218c89ec..31b6bce1 100644 --- a/test/unit/helper.sh +++ b/test/unit/helper.sh @@ -20,6 +20,6 @@ chruby_reset original_path="$PATH" original_pwd="$PWD" -setUp() { return; } -tearDown() { return; } -oneTimeTearDown() { return; } +setUp() { return 0; } +tearDown() { return 0; } +oneTimeTearDown() { return 0; } From 4f584f9cd6d548cfb64b90d07b08d8464ad8dec4 Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Thu, 27 Jan 2022 22:38:16 -0800 Subject: [PATCH 3/4] Prevent loading rc-files from environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, the developer’s shell configuration might break tests when running locally. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c8502798..b53c7a18 100644 --- a/Makefile +++ b/Makefile @@ -48,8 +48,8 @@ configure_tests: ./test/unit/configure test: configure_tests - SHELL=`command -v bash` ./test/unit/runner - SHELL=`command -v zsh` ./test/unit/runner + SHELL=`command -v bash` ./test/unit/runner --norc + SHELL=`command -v zsh` ./test/unit/runner --no-rcs integration_tests: SHELL=`command -v bash` ./test/integration/runner From 0c4d0fb52d8fd886c4655bca812008b7bf58fe32 Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Fri, 28 Jan 2022 02:15:03 -0800 Subject: [PATCH 4/4] Back up the "$LANG" and restore after test --- test/unit/chruby_reset_test.sh | 3 ++- test/unit/chruby_use_test.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unit/chruby_reset_test.sh b/test/unit/chruby_reset_test.sh index d83655c4..e849efd9 100755 --- a/test/unit/chruby_reset_test.sh +++ b/test/unit/chruby_reset_test.sh @@ -15,13 +15,14 @@ function test_chruby_reset_hash_table() assertEquals "did not clear the path table" \ "" "$(hash)" elif [[ -n "$BASH_VERSION" ]]; then + local old_lang="$LANG" export LANG=en_US.UTF-8 chruby_reset assertEquals "did not clear the path table" \ "hash: hash table empty" "$(hash)" - unset LANG + LANG="$old_lang" fi } diff --git a/test/unit/chruby_use_test.sh b/test/unit/chruby_use_test.sh index 568d7450..6d7eb493 100755 --- a/test/unit/chruby_use_test.sh +++ b/test/unit/chruby_use_test.sh @@ -8,13 +8,14 @@ function test_chruby_clears_hash_table() assertEquals "did not clear the path table" \ "" "$(hash)" elif [[ -n "$BASH_VERSION" ]]; then + local old_lang="$LANG" export LANG=en_US.UTF-8 chruby_use "$test_ruby_root" >/dev/null assertEquals "did not clear the path table" \ "hash: hash table empty" "$(hash)" - unset LANG + LANG="$old_lang" fi }