Skip to content

Commit 84b7598

Browse files
committed
Better compartmentalize test fixture files and rm -rf them.
* tearDown actually runs an additional time after all test_* functions have been called. kward/shunit2#112
1 parent bd41b2e commit 84b7598

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

test/cli-tests/no_reinstall_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
. ./test/helper.sh
44

5-
test_install_dir="$test_fixtures_dir/install_dir"
5+
test_install_dir="$test_fixtures_dir/no_reinstall_test"
66

77
function setUp()
88
{
@@ -22,7 +22,7 @@ function test_no_reinstall_when_ruby_executable_exists()
2222

2323
function tearDown()
2424
{
25-
rm -r "$test_install_dir"
25+
rm -rf "$test_install_dir"
2626
}
2727

2828
SHUNIT_PARENT=$0 . $SHUNIT2

test/functions-tests/apply_patches_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
. ./test/helper.sh
44
. ./share/ruby-install/functions.sh
55

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

@@ -30,7 +30,7 @@ function test_apply_patches()
3030

3131
function tearDown()
3232
{
33-
rm -r "$src_dir/$ruby_dir_name"
33+
rm -rf "$src_dir"
3434
}
3535

3636
SHUNIT_PARENT=$0 . $SHUNIT2

test/functions-tests/download_patches_test.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
. ./test/helper.sh
44
. ./share/ruby-install/functions.sh
55

6+
src_dir="$test_fixtures_dir/download_patches_test"
7+
68
patches=("https://gist.github.com/funny-falcon/2981959/raw/ary-queue.diff" "local.patch")
79
ruby_dir_name="ruby-1.9.3-p448"
810

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

1820
assertTrue "did not download patches to \$src_dir/\$ruby_dir_name" \
1921
'[[ -f "$src_dir/$ruby_dir_name/ary-queue.diff" ]]'
22+
2023
assertEquals "did not update \$patches" \
2124
"${patches[0]}" "$src_dir/$ruby_dir_name/ary-queue.diff"
25+
26+
ls "$src_dir/$ruby_dir_name"
2227
}
2328

2429
function tearDown()
2530
{
26-
rm -r "$src_dir/$ruby_dir_name"
31+
rm -rf "$src_dir"
2732
}
2833

2934
SHUNIT_PARENT=$0 . $SHUNIT2

test/ruby-versions-tests/download_ruby_versions_file_test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
. ./test/helper.sh
44
. ./share/ruby-install/ruby-versions.sh
55

6+
ruby_install_cache_dir="$test_fixtures_dir/download_ruby_versions_file_test"
7+
68
ruby="ruby"
79
file="stable.txt"
10+
811
expected_path="$ruby_install_cache_dir/$ruby/$file"
912

1013
function test_download_ruby_versions_file_with_no_parent_dir()
@@ -42,7 +45,7 @@ function test_download_ruby_versions_file_with_existing_file()
4245

4346
function tearDown()
4447
{
45-
rm -rf "$ruby_install_cache_dir/$ruby"
48+
rm -rf "$ruby_install_cache_dir"
4649
}
4750

4851
SHUNIT_PARENT=$0 . $SHUNIT2

test/util-tests/fetch_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
. ./test/helper.sh
44

5-
ruby_install_dir="$test_fixtures_dir/fetch"
5+
ruby_install_dir="$test_fixtures_dir/fetch_test"
66

77
test_file="$ruby_install_dir/db.txt"
88

@@ -61,7 +61,7 @@ function test_fetch_with_unknown_key()
6161

6262
function tearDown()
6363
{
64-
rm -r "$ruby_install_dir"
64+
rm -rf "$ruby_install_dir"
6565
}
6666

6767
SHUNIT_PARENT=$0 . $SHUNIT2

0 commit comments

Comments
 (0)