diff --git a/README.md b/README.md index c17d028..ececab0 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ This repository is a fork of alexharv074's [bash_placebo](https://github.com/alexharv074/bash_placebo). -Major difference between the two projects is this project is built to generate mock commands for unit testing with any bash command while the original is built specifically to mock `aws` cli commands. - ## Installation The tool can be installed just by copying the script from the master branch into your path somewhere. E.g. diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index 06fdf53..cc8112f 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -21,9 +21,13 @@ steps: gem install simplecov-cobertura displayName: 'Installing Dependencies' -- script: | - bashcov --skip-uncovered test/placebo.sh +- task: Bash@3 displayName: 'Running Unit Test' + inputs: + targetType: 'inline' + script: | + bashcov --skip-uncovered "test/placebo.sh" + exit $? - task: PublishCodeCoverageResults@1 displayName: 'Publish code coverage' diff --git a/placebo b/placebo index 3664d15..6993cca 100644 --- a/placebo +++ b/placebo @@ -81,8 +81,12 @@ pill_log() { } pill_detach() { - [[ "$1" == "-h" ]] && \ - _usage detach && return + while test $# -gt 0; do + case "$1" in + -h) _usage detach; return;; + *) break;; + esac + done local f funcs funcs="_usage @@ -170,7 +174,7 @@ _save_func() { if [[ ! $contains ]] ; then local s="$a() { - _check_response \$(source "$RES_PATH" "\$@") \$? + _check_response -r \"\$(source "$RES_PATH" "\$@")\" -c \"\$?\" } " echo $s | cat - $COMMAND_PATH > temp && mv temp $COMMAND_PATH @@ -220,18 +224,26 @@ _create_new() { if [[ "$a" == "-c" ]] ; then cat >> "$f" <