Skip to content

Commit

Permalink
Better compartmentalize test fixture files and rm -rf them.
Browse files Browse the repository at this point in the history
* tearDown actually runs an additional time after all test_* functions
  have been called.
  kward/shunit2#112
  • Loading branch information
postmodern committed Jun 5, 2021
1 parent bd41b2e commit 84b7598
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/cli-tests/no_reinstall_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. ./test/helper.sh

test_install_dir="$test_fixtures_dir/install_dir"
test_install_dir="$test_fixtures_dir/no_reinstall_test"

function setUp()
{
Expand All @@ -22,7 +22,7 @@ function test_no_reinstall_when_ruby_executable_exists()

function tearDown()
{
rm -r "$test_install_dir"
rm -rf "$test_install_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2
4 changes: 2 additions & 2 deletions test/functions-tests/apply_patches_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. ./test/helper.sh
. ./share/ruby-install/functions.sh

src_dir="$test_fixtures_dir/src"
src_dir="$test_fixtures_dir/apply_patches_test"
ruby_dir_name="ruby-1.9.3-p448"
patches=("$src_dir/$ruby_dir_name/falcon-gc.diff")

Expand All @@ -30,7 +30,7 @@ function test_apply_patches()

function tearDown()
{
rm -r "$src_dir/$ruby_dir_name"
rm -rf "$src_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2
7 changes: 6 additions & 1 deletion test/functions-tests/download_patches_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
. ./test/helper.sh
. ./share/ruby-install/functions.sh

src_dir="$test_fixtures_dir/download_patches_test"

patches=("https://gist.github.com/funny-falcon/2981959/raw/ary-queue.diff" "local.patch")
ruby_dir_name="ruby-1.9.3-p448"

Expand All @@ -17,13 +19,16 @@ function test_download_patches()

assertTrue "did not download patches to \$src_dir/\$ruby_dir_name" \
'[[ -f "$src_dir/$ruby_dir_name/ary-queue.diff" ]]'

assertEquals "did not update \$patches" \
"${patches[0]}" "$src_dir/$ruby_dir_name/ary-queue.diff"

ls "$src_dir/$ruby_dir_name"
}

function tearDown()
{
rm -r "$src_dir/$ruby_dir_name"
rm -rf "$src_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2
5 changes: 4 additions & 1 deletion test/ruby-versions-tests/download_ruby_versions_file_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
. ./test/helper.sh
. ./share/ruby-install/ruby-versions.sh

ruby_install_cache_dir="$test_fixtures_dir/download_ruby_versions_file_test"

ruby="ruby"
file="stable.txt"

expected_path="$ruby_install_cache_dir/$ruby/$file"

function test_download_ruby_versions_file_with_no_parent_dir()
Expand Down Expand Up @@ -42,7 +45,7 @@ function test_download_ruby_versions_file_with_existing_file()

function tearDown()
{
rm -rf "$ruby_install_cache_dir/$ruby"
rm -rf "$ruby_install_cache_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2
4 changes: 2 additions & 2 deletions test/util-tests/fetch_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. ./test/helper.sh

ruby_install_dir="$test_fixtures_dir/fetch"
ruby_install_dir="$test_fixtures_dir/fetch_test"

test_file="$ruby_install_dir/db.txt"

Expand Down Expand Up @@ -61,7 +61,7 @@ function test_fetch_with_unknown_key()

function tearDown()
{
rm -r "$ruby_install_dir"
rm -rf "$ruby_install_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2

0 comments on commit 84b7598

Please sign in to comment.