diff options
Diffstat (limited to '')
| -rw-r--r-- | test/apps/bun-run-check-nameless-package.json | 6 | ||||
| -rw-r--r-- | test/apps/bun-run-check.sh | 47 |
2 files changed, 50 insertions, 3 deletions
diff --git a/test/apps/bun-run-check-nameless-package.json b/test/apps/bun-run-check-nameless-package.json new file mode 100644 index 000000000..8ace03613 --- /dev/null +++ b/test/apps/bun-run-check-nameless-package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "this-should-work": "echo \"✅ bun run test passed!\"", + "argv": "node -e 'console.log(process.argv)'" + } +} diff --git a/test/apps/bun-run-check.sh b/test/apps/bun-run-check.sh index a904959e9..c86062f7b 100644 --- a/test/apps/bun-run-check.sh +++ b/test/apps/bun-run-check.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# TODO: move this test to bun once we have a child_process equivalent. + set -euo pipefail (killall -9 "$(basename "$BUN_BIN")" || echo "") >/dev/null 2>&1 @@ -10,9 +12,48 @@ fn() { :; } # The important bit: export the function export -f fn -DIR=$(mktemp -d -t bun-run-check) +rm -rf /tmp/bun-run-check +mkdir -p /tmp/bun-run-check +DIR=/tmp/bun-run-check cp ./bun-run-check-package.json "$DIR/package.json" +cp ./bun-run-check-nameless-package.json "$DIR/package.json" + +cd "$DIR" + +$BUN_BIN run bash -- -c "" + +if (($?)); then + echo "Bash exported functions are broken" + exit 1 +fi + +# https://github.com/oven-sh/bun/issues/53 +rm -f "$DIR/bun-run-out.expected.txt" "$DIR/bun-run-out.txt" >/dev/null 2>&1 + +$BUN_BIN run --silent argv -- foo bar baz >"$DIR/bun-run-out.txt" +npm run --silent argv -- foo bar baz >"$DIR/bun-run-out.expected.txt" + +cmp -s "$DIR/bun-run-out.expected.txt" "$DIR/bun-run-out.txt" +if (($?)); then + echo "argv failed" + exit 1 +fi + +$BUN_BIN run --silent this-should-work + +if (($?)); then + echo "this-should work failed" + exit 1 +fi + +# Run it a second time with our other script which has no name + +rm -rf /tmp/bun-run-check +mkdir -p /tmp/bun-run-check +DIR=/tmp/bun-run-check + +cd "../" cd "$DIR" $BUN_BIN run bash -- -c "" @@ -25,8 +66,8 @@ fi # https://github.com/oven-sh/bun/issues/53 rm -f "$DIR/bun-run-out.expected.txt" "$DIR/bun-run-out.txt" >/dev/null 2>&1 -$BUN_BIN run --silent argv -- foo bar baz > "$DIR/bun-run-out.txt" -npm run --silent argv -- foo bar baz > "$DIR/bun-run-out.expected.txt" +$BUN_BIN run --silent argv -- foo bar baz >"$DIR/bun-run-out.txt" +npm run --silent argv -- foo bar baz >"$DIR/bun-run-out.expected.txt" cmp -s "$DIR/bun-run-out.expected.txt" "$DIR/bun-run-out.txt" if (($?)); then |
