aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apps/bun-create-next.sh23
-rw-r--r--test/apps/bun-create-react.sh14
-rw-r--r--test/apps/bun-dev-index-html.sh20
-rw-r--r--test/apps/bun-dev.sh16
-rw-r--r--test/apps/bun-install-lockfile-status.sh6
-rw-r--r--test/apps/bun-install-utf8.sh8
-rw-r--r--test/apps/bun-install.sh10
-rw-r--r--test/apps/bun-run-check.sh59
8 files changed, 58 insertions, 98 deletions
diff --git a/test/apps/bun-create-next.sh b/test/apps/bun-create-next.sh
index eb523d223..d8e148282 100644
--- a/test/apps/bun-create-next.sh
+++ b/test/apps/bun-create-next.sh
@@ -4,20 +4,21 @@ set -euo pipefail
# The important part of this test: make sure that bun.js successfully loads
# The most likely reason for this test to fail is that something broke in the JavaScriptCore <> bun integration
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
-DIR=$(mktemp -d -t next-app)
-$BUN_BIN create next "$DIR"
+rm -rf /tmp/next-app
+mkdir -p /tmp/next-app
+$BUN_BIN create next /tmp/next-app
if (($?)); then
echo "bun create failed"
exit 1
fi
-echo "hi!" >"$DIR/public/file.txt"
-echo "export default 'string';" >"$DIR/file.js"
+echo "hi!" >/tmp/next-app/public/file.txt
+echo "export default 'string';" >/tmp/next-app/file.js
-cd "$DIR"
+cd /tmp/next-app
BUN_CRASH_WITHOUT_JIT=1 $BUN_BIN dev --port 8087 &
sleep 0.1
curl --fail -Ss http://localhost:8087/
@@ -27,7 +28,7 @@ if [[ "$(curl --fail -sS http://localhost:8087/file.txt)" != "hi!" ]]; then
echo ""
echo ""
echo "ERR: Expected 'hi!', got '$(curl --fail -sS http://localhost:8087/file.txt)'"
- killall -9 "$(basename "$BUN_BIN")" || echo ""
+ killall -9 $(basename $BUN_BIN) || echo ""
exit 1
fi
@@ -36,12 +37,12 @@ if [[ "$(curl --fail -sS http://localhost:8087/file.js)" != *"string"* ]]; then
echo ""
echo ""
echo "ERR: Expected file to contain string got '$(curl --fail -sS http://localhost:8087/file.js)'"
- killall -9 "$(basename "$BUN_BIN")" || echo ""
+ killall -9 $(basename $BUN_BIN) || echo ""
exit 1
fi
# very simple HMR test
-echo "export default 'string';" >"$DIR/file2.js"
+echo "export default 'string';" >/tmp/next-app/file2.js
sleep 0.1
if [[ "$(curl --fail -sS http://localhost:8087/file2.js)" != *"string"* ]]; then
@@ -49,8 +50,8 @@ if [[ "$(curl --fail -sS http://localhost:8087/file2.js)" != *"string"* ]]; then
echo ""
echo ""
echo "ERR: Expected file to contain string got '$(curl --fail -sS http://localhost:8087/file2.js)'"
- killall -9 "$(basename "$BUN_BIN")" || echo ""
+ killall -9 $(basename $BUN_BIN) || echo ""
exit 1
fi
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
diff --git a/test/apps/bun-create-react.sh b/test/apps/bun-create-react.sh
index 2997eb7b1..40055196b 100644
--- a/test/apps/bun-create-react.sh
+++ b/test/apps/bun-create-react.sh
@@ -1,20 +1,20 @@
#!/usr/bin/env bash
-set -euo pipefail
+killall -9 $(basename $BUN_BIN) || echo ""
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+rm -rf /tmp/react-app
+mkdir -p /tmp/react-app
+$BUN_BIN create react /tmp/react-app
-DIR=$(mktemp -d -t react-app)
-$BUN_BIN create react "$DIR"
if (($?)); then
echo "bun create failed"
exit 1
fi
-cd "$DIR"
-BUN_CRASH_WITHOUT_JIT=1 $BUN_BIN dev --port 8087 &
+cd /tmp/react-app
+BUN_CRASH_WITHOUT_JIT=1 $BUN_BIN --port 8087 &
sleep 0.005
-curl --fail http://localhost:8087/ && curl --fail http://localhost:8087/src/index.jsx && killall -9 "$(basename "$BUN_BIN")" && echo "✅ bun create react passed."
+curl --fail http://localhost:8087/ && curl --fail http://localhost:8087/src/index.jsx && killall -9 $(basename $BUN_BIN) && echo "✅ bun create react passed."
exit $?
diff --git a/test/apps/bun-dev-index-html.sh b/test/apps/bun-dev-index-html.sh
index 77891f0c7..f34bf11a2 100644
--- a/test/apps/bun-dev-index-html.sh
+++ b/test/apps/bun-dev-index-html.sh
@@ -2,9 +2,9 @@
set -euo pipefail
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
-DIR=$(mktemp -d -t bun-dev-check)
+dir=$(mktemp -d --suffix=bun-dev-check)
index_content="<html><body>index.html</body></html>"
bacon_content="<html><body>bacon.html</body></html>"
@@ -14,14 +14,14 @@ css_not_transpiled_content="@import url(/index.js); @import url(/i-dont-exist.cs
css_is_transpiled_import="*{background-color:red;}"
css_is_transpiled="@import url(./css_is_transpiled_import.css);"
-echo $index_content >"$DIR/index.html"
-echo $js_content >"$DIR/index.js"
-echo $bacon_content >"$DIR/bacon.html"
-echo $static_content >"$DIR/static.txt"
-echo $css_not_transpiled_content >"$DIR/css_not_transpiled_content.css"
+echo $index_content >"$dir/index.html"
+echo $js_content >"$dir/index.js"
+echo $bacon_content >"$dir/bacon.html"
+echo $static_content >"$dir/static.txt"
+echo $css_not_transpiled_content >"$dir/css_not_transpiled_content.css"
-cd "$DIR"
-$BUN_BIN dev --port 8087 &
+cd $dir
+$BUN_BIN --port 8087 &
sleep 0.005
if [[ "$(curl --fail -sS http://localhost:8087/)" != "$index_content" ]]; then
@@ -65,5 +65,5 @@ if [[ "$(curl --fail -sS http://localhost:8087/bacon.html)" != "$bacon_content"
exit 1
fi
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
echo "✅ bun dev index html check passed."
diff --git a/test/apps/bun-dev.sh b/test/apps/bun-dev.sh
index 77fb75be8..be1902965 100644
--- a/test/apps/bun-dev.sh
+++ b/test/apps/bun-dev.sh
@@ -2,23 +2,23 @@
set -euo pipefail
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
-DIR=$(mktemp -d -t bun-dev-check)
+dir=$(mktemp -d --suffix=bun-dev-check)
index_content="<html><body>index.html</body></html>"
bacon_content="<html><body>bacon.html</body></html>"
js_content="console.log('hi')"
-mkdir -p "$DIR/public"
+mkdir -p $dir/public
-echo $index_content >"$DIR/public/index.html"
-echo $js_content >"$DIR/index.js"
-echo $bacon_content >"$DIR/public/bacon.html"
+echo $index_content >"$dir/public/index.html"
+echo $js_content >"$dir/index.js"
+echo $bacon_content >"$dir/public/bacon.html"
-cd "$DIR"
+cd $dir
-$BUN_BIN dev --port 8087 &
+$BUN_BIN --port 8087 &
sleep 0.005
if [ "$(curl --fail -sS http://localhost:8087/)" != "$index_content" ]; then
diff --git a/test/apps/bun-install-lockfile-status.sh b/test/apps/bun-install-lockfile-status.sh
index 5e168b8e2..96b39a09e 100644
--- a/test/apps/bun-install-lockfile-status.sh
+++ b/test/apps/bun-install-lockfile-status.sh
@@ -2,11 +2,11 @@
set -euo pipefail
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
-DIR=$(mktemp -d -t bun-lockfile)
+dir=$(mktemp -d --suffix=bun-lockfile)
-cd "$DIR"
+cd $dir
$BUN_BIN add react
diff --git a/test/apps/bun-install-utf8.sh b/test/apps/bun-install-utf8.sh
index ca6858513..28e644708 100644
--- a/test/apps/bun-install-utf8.sh
+++ b/test/apps/bun-install-utf8.sh
@@ -2,13 +2,13 @@
set -euo pipefail
-killall -9 "$(basename "$BUN_BIN")" || echo ""
+killall -9 $(basename $BUN_BIN) || echo ""
-DIR=$(mktemp -d -t bun-ADD)
+dir=$(mktemp -d --suffix=bun-ADD)
-cd "$DIR"
+cd $dir
-# https://github.com/oven-sh/bun/issues/115
+# https://github.com/Jarred-Sumner/bun/issues/115
echo '{ "author": "Arnaud Barré (https://github.com/ArnaudBarre)" }' >package.json
$BUN_BIN add react
diff --git a/test/apps/bun-install.sh b/test/apps/bun-install.sh
index c705a6b37..6ca07c20f 100644
--- a/test/apps/bun-install.sh
+++ b/test/apps/bun-install.sh
@@ -2,9 +2,9 @@
set -euo pipefail
-DIR=$(mktemp -d -t bun-install-test-1)
+dir=$(mktemp -d --suffix=bun-install-test-1)
-cd "$DIR"
+cd $dir
${NPM_CLIENT:-$(which bun)} add react react-dom @types/react @babel/parser esbuild
echo "console.log(typeof require(\"react\").createElement);" >index.js
@@ -47,7 +47,7 @@ fi
${NPM_CLIENT:-$(which bun)} remove react-dom
if [ -d "node_modules/react-dom" ]; then
- echo "ERR: react-dom module still exists in $DIR"
+ echo "ERR: react-dom module still exists in $dir"
exit 1
fi
@@ -68,14 +68,14 @@ if echo "$yarn_dot_lock" | grep -q "@types/react"; then
fi
if echo "$yarn_dot_lock" | grep -q "@types/react"; then
- echo "ERR: @types/react module still exists in $DIR"
+ echo "ERR: @types/react module still exists in $dir"
exit 1
fi
${NPM_CLIENT:-$(which bun)} remove react
if [ -d "node_modules/react" ]; then
- echo "ERR: react module still exists in $DIR"
+ echo "ERR: react module still exists in $dir"
exit 1
fi
diff --git a/test/apps/bun-run-check.sh b/test/apps/bun-run-check.sh
index c86062f7b..39c2892a7 100644
--- a/test/apps/bun-run-check.sh
+++ b/test/apps/bun-run-check.sh
@@ -1,12 +1,9 @@
#!/usr/bin/env bash
# TODO: move this test to bun once we have a child_process equivalent.
+(killall -9 $(basename $BUN_BIN) || echo "") >/dev/null 2>&1
-set -euo pipefail
-
-(killall -9 "$(basename "$BUN_BIN")" || echo "") >/dev/null 2>&1
-
-# https://github.com/oven-sh/bun/issues/40
+# https://github.com/Jarred-Sumner/bun/issues/40
# Define a function (details aren't important)
fn() { :; }
# The important bit: export the function
@@ -14,47 +11,9 @@ export -f fn
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"
+cp ./bun-run-check-package.json /tmp/bun-run-check/package.json
+cd /tmp/bun-run-check
$BUN_BIN run bash -- -c ""
@@ -63,13 +22,13 @@ if (($?)); then
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
+# https://github.com/Jarred-Sumner/bun/issues/53
+rm -f /tmp/bun-run-out.expected.txt /tmp/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 >/tmp/bun-run-out.txt
+npm run --silent argv -- foo bar baz >/tmp/bun-run-out.expected.txt
-cmp -s "$DIR/bun-run-out.expected.txt" "$DIR/bun-run-out.txt"
+cmp -s /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt
if (($?)); then
echo "argv failed"
exit 1