mirror of
https://github.com/fsquillace/junest.git
synced 2026-07-28 13:34:00 +00:00
Fix wrapper when passing multiple arguments and add unit tests
This change come from the PR #289
This commit is contained in:
parent
98775b538f
commit
73b8bec8db
2 changed files with 32 additions and 3 deletions
|
|
@ -33,12 +33,12 @@ function create_wrappers() {
|
|||
# Arguments inside a variable (i.e. `JUNEST_ARGS`) separated by quotes
|
||||
# are not recognized normally unless using `eval`. More info here:
|
||||
# https://github.com/fsquillace/junest/issues/262
|
||||
# https://github.com/fsquillace/junest/pull/287
|
||||
cat <<EOF > "${JUNEST_HOME}/usr/bin_wrappers/${file}"
|
||||
#!/usr/bin/env bash
|
||||
|
||||
JUNEST_ARGS=\${JUNEST_ARGS:-ns}
|
||||
|
||||
eval junest "\${JUNEST_ARGS}" -- ${file} "\$(printf "%q" "\$@")"
|
||||
eval "junest_args_array=(\${JUNEST_ARGS:-ns})"
|
||||
junest "\${junest_args_array[@]}" -- ${file} "\$@"
|
||||
EOF
|
||||
chmod +x "${JUNEST_HOME}/usr/bin_wrappers/${file}"
|
||||
done
|
||||
|
|
|
|||
|
|
@ -43,6 +43,35 @@ function test_create_wrappers_executable_file(){
|
|||
assertTrue "myfile wrapper should exist" "[ -x $JUNEST_HOME/usr/bin_wrappers/myfile ]"
|
||||
}
|
||||
|
||||
function test_create_wrappers_verify_content(){
|
||||
# Test for:
|
||||
# https://github.com/fsquillace/junest/issues/262
|
||||
# https://github.com/fsquillace/junest/issues/292
|
||||
touch "$JUNEST_HOME"/usr/bin/myfile
|
||||
chmod +x "$JUNEST_HOME"/usr/bin/myfile
|
||||
export JUNEST_ARGS="ns --fakeroot -b '--bind /run /run2'"
|
||||
assertCommandSuccess create_wrappers
|
||||
assertEquals "" "$(cat "$STDOUTF")"
|
||||
|
||||
# Mock junest command to capture the actual output generated from myfile script
|
||||
junest(){
|
||||
for arg in "$@"
|
||||
do
|
||||
echo "$arg"
|
||||
done
|
||||
}
|
||||
assertEquals "ns
|
||||
--fakeroot
|
||||
-b
|
||||
--bind /run /run2
|
||||
--
|
||||
myfile
|
||||
pacman
|
||||
-Rsn
|
||||
neovim
|
||||
new package" "$(source "$JUNEST_HOME"/usr/bin_wrappers/myfile pacman -Rsn neovim 'new package')"
|
||||
}
|
||||
|
||||
function test_create_wrappers_already_exist(){
|
||||
touch "$JUNEST_HOME"/usr/bin/myfile
|
||||
chmod +x "$JUNEST_HOME"/usr/bin/myfile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue