-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add shell and exec commands #118
Open
gportay
wants to merge
3
commits into
savoirfairelinux:master
Choose a base branch
from
gportay:add-shell-and-exec-commands
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# validate the behavior of run command that do not preserve arguments | ||
|
||
set -o pipefail | ||
|
||
. "$(dirname "$0")"/jtest.inc "$1" | ||
cqfd="$TDIR/.cqfd/cqfd" | ||
|
||
cd $TDIR/ | ||
|
||
jtest_prepare "cqfd run do not preserve the arguments" | ||
if ( ! $cqfd run /bin/sh -c 'printf "0=$0,*=$*,#=$#"' zero one two three ) \ | ||
| grep "0=sh,\*=,#=0"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# validate the behavior of exec command | ||
|
||
set -o pipefail | ||
|
||
. "$(dirname "$0")"/jtest.inc "$1" | ||
cqfd="$TDIR/.cqfd/cqfd" | ||
|
||
cd $TDIR/ | ||
|
||
jtest_prepare "cqfd exec with no argument should fail" | ||
if ! $cqfd exec; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd exec with argument should succeed" | ||
if $cqfd exec true; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd exec should return same status" | ||
if $cqfd exec exit 10; | ||
test "$?" -eq 10; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd exec should preserve the arguments" | ||
if $cqfd exec /bin/sh -c 'printf "0=$0,*=$*,#=$#"' zero one two three \ | ||
| grep "0=zero,\*=one two three,#=3$"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# validate the behavior of shell command | ||
|
||
set -o pipefail | ||
|
||
unset CQFD_SHELL | ||
|
||
. "$(dirname "$0")"/jtest.inc "$1" | ||
cqfd="$TDIR/.cqfd/cqfd" | ||
|
||
cd $TDIR/ | ||
|
||
jtest_prepare "cqfd shell should succeed with no stdin" | ||
if $cqfd shell </dev/null; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should read commands from stdin" | ||
if ( ! $cqfd shell <<<"tty" ) | grep "not a tty"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should preserve the arguments" | ||
if $cqfd shell -c 'printf "0=$0,*=$*,#=$#"' zero one two three \ | ||
| grep "0=zero,\*=one two three,#=3$"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd shell should fail with 127 if \$CQFD_SHELL is not found" | ||
if CQFD_SHELL=/bin/non-existant-shell $cqfd shell <<<"tty"; | ||
test "$?" -eq 127; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd sh should succeed and use sh" | ||
if $cqfd sh <<<'printf "$0"' \ | ||
| grep "^sh$"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd bash should succeed and use bash" | ||
if $cqfd bash <<<'printf "$0"' \ | ||
| grep "^bash$"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd dash should succeed and use dash" | ||
if $cqfd dash <<<'printf "$0"' \ | ||
| grep "dash"; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi | ||
|
||
jtest_prepare "cqfd zsh should fail with 127" | ||
if $cqfd zsh <<<'printf "$0"'; | ||
test "$?" -eq 127; then | ||
jtest_result pass | ||
else | ||
jtest_result fail | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
at this line should it be
cqfd_shell="/bin/$1"
? It seems like it works on my end this wayThere 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.
Yes it "should" but without the hardcoded path "/bin".