From 455239f59406ca39ab731812867a23b23001b218 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Fri, 27 Jan 2017 21:41:50 +0000 Subject: [PATCH 1/2] make tests independent of bin locations On my system (Arch Linux), the commands {mv,rm,sed} live under `/usr/bin`, not under `/bin`. So the tests were failing. This commit hard-codes the initial paths to make the tests independent on their real paths. --- test/lib/git/shell_shortcuts_test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index b826a0b..76d23fd 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -33,9 +33,9 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } # Test aliases - alias mv="nocorrect mv" - alias rm="rm --option" - alias sed="sed" + alias mv="nocorrect /bin/mv" + alias rm="/bin/rm --option" + alias sed="/bin/sed" # Test already wrapped commands alias cat="exec_scmb_expand_args /bin/cat" From 6f4babeced9b283b3a2d842cbb967d0ca4a0af24 Mon Sep 17 00:00:00 2001 From: Wilhelmina Drengwitz Date: Tue, 31 Jan 2017 15:50:14 -0500 Subject: [PATCH 2/2] Extend tests to use conditional exe paths --- test/lib/git/shell_shortcuts_test.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 76d23fd..522b586 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -33,11 +33,11 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } # Test aliases - alias mv="nocorrect /bin/mv" - alias rm="/bin/rm --option" - alias sed="/bin/sed" + alias mv="nocorrect $(which mv)" + alias rm="$(which rm) --option" + alias sed="$(which sed)" # Test already wrapped commands - alias cat="exec_scmb_expand_args /bin/cat" + alias cat="exec_scmb_expand_args $(which cat)" # Run shortcut wrapping source "$scmbDir/lib/git/shell_shortcuts.sh" @@ -59,11 +59,11 @@ assertAliasEquals(){ #----------------------------------------------------------------------------- test_shell_command_wrapping() { - assertAliasEquals "exec_scmb_expand_args /bin/rm --option" "rm" - assertAliasEquals "exec_scmb_expand_args nocorrect /bin/mv" "mv" - assertAliasEquals "exec_scmb_expand_args /bin/sed" "sed" - assertAliasEquals "exec_scmb_expand_args /bin/cat" "cat" - assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" + assertAliasEquals "exec_scmb_expand_args $(which rm) --option" "rm" + assertAliasEquals "exec_scmb_expand_args nocorrect $(which mv)" "mv" + assertAliasEquals "exec_scmb_expand_args $(which sed)" "sed" + assertAliasEquals "exec_scmb_expand_args $(which cat)" "cat" + assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" assertIncludes "$(declare -f ln)" "ln ()" assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln" }