Skip to content

Commit

Permalink
Add signal() test
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Feb 23, 2020
1 parent 7abb348 commit a702a1b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/libexec.sh
Expand Up @@ -119,15 +119,17 @@ sleep_wait() {
esac
}


if $SHELLSPEC_KILL -0 $$ 2>/dev/null; then
signal() {
"$SHELLSPEC_KILL" "$1" "$2"
}
else
signal() {
"$SHELLSPEC_KILL" -s "${1#-}" "$2"
}
fi
signal() {
if $SHELLSPEC_KILL -0 $$ 2>/dev/null; then
signal() {
"$SHELLSPEC_KILL" "$1" "$2"
}
else
signal() {
"$SHELLSPEC_KILL" -s "${1#-}" "$2"
}
fi
signal "$@"
}

use puts putsn
17 changes: 17 additions & 0 deletions spec/libexec_spec.sh
Expand Up @@ -84,4 +84,21 @@ Describe 'libexec.sh'
The lines of stdout should eq 2
End
End

Describe "signal()"
posix_kill() { eval SHELLSPEC_KILL=echo && true; }
non_posix_kill() { eval SHELLSPEC_KILL=echo && false; }

It "calls kill (posix)"
BeforeCall SHELLSPEC_KILL=posix_kill
When call signal -TERM 0
The stdout should eq "-TERM 0"
End

It "calls kill (non-posix)"
BeforeCall SHELLSPEC_KILL=non_posix_kill
When call signal -TERM 0
The stdout should eq "-s TERM 0"
End
End
End

0 comments on commit a702a1b

Please sign in to comment.