Skip to content

Commit 80a7dd4

Browse files
committed
Test RUBIES sort order and spaces in the path.
1 parent f92524f commit 80a7dd4

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ install:
44
- sudo apt-get install shunit2 zsh ruby
55

66
before_script:
7-
- echo yes | rvm implode
7+
- sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm /usr/local/bin/rvm
88
- __rvm_unload
99

1010
script: make test

share/chruby/chruby.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ CHRUBY_VERSION="0.3.8"
33
function chruby_rubies()
44
{
55
find "$@" -mindepth 1 -maxdepth 1 -type "d" 2>/dev/null |
6-
sed -e "h" -e "s/.*\///" -e "s/-/./g" -e "G" -e "s/\n/ /" |
7-
sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | cut -d " " -f 2
6+
sed -e "h" -e 's/.*\///' -e 's/-/./g' -e "G" -e 's/\n/ /' |
7+
sort -t "." -k "1,1" -k "2,2n" -k "3,3n" -k "4,4n" | sed 's/[^ ]* //'
88
}
99

1010
RUBIES=($(chruby_rubies "$PREFIX/opt/rubies" "$HOME/.rubies"))

test/chruby_test.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,22 @@ function tearDown()
1212
RUBIES=(${original_rubies[@]})
1313
}
1414

15-
function test_chruby_default_RUBIES()
15+
function test_chruby_rubies_sort_order()
1616
{
17-
assertEquals "did not correctly populate RUBIES" \
18-
"$test_ruby_root" \
19-
"${RUBIES[*]}"
17+
actual_order=""
18+
for ruby in "${RUBIES[@]}"; do
19+
actual_order="$actual_order ${ruby##*/}"
20+
done
21+
actual_order="${actual_order##?}"
22+
23+
assertEquals "did not natural version sort" "$test_rubies_order" "$actual_order"
24+
}
25+
26+
function test_chruby_rubies_spaces()
27+
{
28+
detected_ruby=$(chruby_rubies "${test_ruby_dir%/*}/r u b i e s")
29+
30+
assertEquals "did not work with spaces in RUBIES path" "ruby-2.1.2" "${detected_ruby##*/}"
2031
}
2132

2233
function test_chruby_2_0()

test/helper.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ test_ruby_engine="ruby"
1212
test_ruby_version="2.0.0"
1313
test_ruby_patchlevel="353"
1414
test_ruby_api="2.0.0"
15-
test_ruby_root="$PWD/test/opt/rubies/$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
15+
test_ruby_dir="$PWD/test/opt/rubies"
16+
test_ruby_root="$test_ruby_dir/$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
17+
test_rubies_order="jruby-1.7.9 jruby-1.7.14 rbx-2.2.9 rbx-2.2.10 rbx-10.0.0 ruby-1.9.3-p547 ruby-1.9.3-preview1 ruby-1.9.3-rc1 ruby-2.0.0-p0 ruby-2.0.0-p195 ruby-2.0.0-p247 ruby-2.0.0-p353"
1618

1719
test_path="$PATH"
1820
test_gem_home="$HOME/.gem/$test_ruby_engine/$test_ruby_version"

test/setup

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ test_ruby_root="$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
173173
mkdir -p "$PREFIX/opt/rubies"
174174
cd "$PREFIX/opt/rubies"
175175

176+
mkdir -p "jruby-1.7.9" "jruby-1.7.14" "rbx-2.2.9" "rbx-2.2.10" "rbx-10.0.0" \
177+
"ruby-1.9.3-p547" "ruby-1.9.3-preview1" "ruby-1.9.3-rc1" "ruby-2.0.0-p0" \
178+
"ruby-2.0.0-p195" "ruby-2.0.0-p247" "ruby-2.0.0-p353"
179+
180+
mkdir -p "$PREFIX/opt/r u b i e s/ruby-2.1.2"
181+
176182
log "Downloading $test_ruby_url ..."
177183
download "$test_ruby_url" "$test_ruby_archive" || fail "Download failed"
178184

0 commit comments

Comments
 (0)