diff --git a/ext/test/custom-exit-behavior b/ext/test/custom-exit-behavior index 7669c6e..7bbe628 100755 --- a/ext/test/custom-exit-behavior +++ b/ext/test/custom-exit-behavior @@ -4,7 +4,6 @@ set -uexo pipefail usage() { echo "Usage: $(basename "$0")"; } misuse() { usage 1>&2; exit 2; } -tk() { lein trampoline run "$@"; } test $# -eq 0 || misuse @@ -13,8 +12,9 @@ tmpdir="$(cd "$tmpdir" && pwd)" trap "$(printf 'rm -rf %q' "$tmpdir")" EXIT rc=0 -tk -d -b <(echo puppetlabs.trapperkeeper.custom-exit-behavior-test/custom-exit-behavior-test-service) \ - 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? +./tk -cp "$(pwd)/test" -- \ + -d -b <(echo puppetlabs.trapperkeeper.custom-exit-behavior-test/custom-exit-behavior-test-service) \ + 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? cat "$tmpdir/out" "$tmpdir/err" test "$rc" -eq 7 grep -F 'Some excitement!' "$tmpdir/out" diff --git a/ext/test/top-level-cli b/ext/test/top-level-cli index 030a89b..d0e436e 100755 --- a/ext/test/top-level-cli +++ b/ext/test/top-level-cli @@ -14,7 +14,7 @@ trap "$(printf 'rm -rf %q' "$tmpdir")" EXIT ## Test handling an unknown option rc=0 -./tk --invalid-option 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? +./tk -- --invalid-option 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? cat "$tmpdir/out" "$tmpdir/err" test "$rc" -eq 1 grep -F 'Unknown option: "--invalid-option"' "$tmpdir/err" @@ -22,7 +22,7 @@ grep -F 'Unknown option: "--invalid-option"' "$tmpdir/err" ## Test --help rc=0 -./tk --help 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? +./tk -- --help 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? cat "$tmpdir/out" "$tmpdir/err" test "$rc" -eq 0 grep -F 'Path to bootstrap config file' "$tmpdir/out" @@ -32,7 +32,7 @@ test $(wc -c < "$tmpdir/out") -eq 650 ## Test handling a missing bootstrap file rc=0 -./tk frobnicate ... 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? +./tk -- frobnicate ... 1>"$tmpdir/out" 2>"$tmpdir/err" || rc=$? cat "$tmpdir/out" "$tmpdir/err" test "$rc" -eq 1 grep -F 'Unable to find bootstrap.cfg file via --bootstrap-config' "$tmpdir/err" diff --git a/tk b/tk index 8aa98b4..b16378e 100755 --- a/tk +++ b/tk @@ -1,9 +1,40 @@ #!/usr/bin/env bash -set -e +set -ueo pipefail + +usage() { echo "Usage: tk JVM_ARG ... -- TK_ARG ..."; } +misuse() { usage 1>&2; exit 2; } jar_glob='trapperkeeper-*-SNAPSHOT-standalone.jar' +# Believe last -cp wins for java, and here, any final -cp path will be +# placed in front of the jar. + +cp='' +jvm_args=() +while test $# -gt 0; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -cp) + shift + test $# -gt 0 || misuse + cp="$1" + shift + ;; + --) + shift + break + ;; + *) + shift + jvm_args+=("$1") + ;; + esac +done + if test "${TRAPPERKEEPER_JAR:-}"; then jar="$TRAPPERKEEPER_JAR" else @@ -28,4 +59,11 @@ if ! test -e "$jar"; then exit 2 fi -exec java -jar "$jar" "$@" +set -x +if test "$cp"; then + cp="$cp:$jar" +else + cp="$jar" +fi + +exec java -cp "$cp" clojure.main -m puppetlabs.trapperkeeper.main "$@"