-
-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warn user that installation will fail if she doesn't have necessary write permissions #466
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,22 @@ source "$ruby_install_dir/checksums.sh" | |
# | ||
function pre_install() | ||
{ | ||
|
||
local status | ||
local exisiting_part_dir="${install_dir%/*}" | ||
|
||
mkdir -p "$src_dir" || return $? | ||
mkdir -p "${install_dir%/*}" || return $? | ||
|
||
while [ ! -d "$exisiting_part_dir" ]; do | ||
exisiting_part_dir="${exisiting_part_dir%/*}" | ||
done | ||
|
||
if [ ! -w "$exisiting_part_dir" ]; then | ||
fail "Installation directory is not writable by the user : ${exisiting_part_dir}" | ||
status=$? | ||
fi | ||
|
||
mkdir -p "${install_dir%/*}" || return $status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're going to hate me for constantly suggesting alternative approaches, but I think recursively checking each parent directory is unnecessary: local parent_dir="${install_dir%/*}"
if [[ ! -d "$parent_dir" ]]; then
mkdir -p "$parent_dir" || fail "cannot create installation directory"
elif [[ ! -w "$parent_dir" ]]; then
fail "installation directory is not writable"
fi
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think the above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be |
||
} | ||
|
||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
. ./test/helper.sh | ||
|
||
test_install_dir="$test_fixtures_dir/no_write_permissions_test" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe to make this test more explicit, you could add another variable called |
||
|
||
function setUp() | ||
{ | ||
mkdir -p "$test_install_dir/bin" | ||
chmod -w "$test_install_dir/bin" | ||
} | ||
|
||
function test_no_write_permissions() | ||
{ | ||
local output status | ||
output="$(ruby-install --install-dir "$test_install_dir/bin/rubies" ruby 2>&1)" | ||
status=$? | ||
|
||
assertEquals "did not return 0" 255 $status | ||
assertTrue "did not print a message to STDOUT" \ | ||
'[[ "$output" == *"Installation directory is not writable by the user"* ]]' | ||
} | ||
|
||
function tearDown() | ||
{ | ||
rm -rf "$test_install_dir" | ||
} | ||
|
||
SHUNIT_PARENT=$0 . $SHUNIT2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail
callsexit -1
, sostatus=$?
has no effect. Maybe you want to useerror
and thenreturn 1
?