test: add workspace monorepo bun install test
Co-authored-by: Eriyc <50216491+Eriyc@users.noreply.github.com>
This commit is contained in:
@@ -76,3 +76,22 @@ sh_test(
|
|||||||
args = ["$(location //internal:bun_install.bzl)"],
|
args = ["$(location //internal:bun_install.bzl)"],
|
||||||
data = ["//internal:bun_install.bzl"],
|
data = ["//internal:bun_install.bzl"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sh_test(
|
||||||
|
name = "bun_install_workspaces_test",
|
||||||
|
srcs = ["workspaces.sh"],
|
||||||
|
args = select({
|
||||||
|
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
|
||||||
|
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
|
||||||
|
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
|
||||||
|
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
|
||||||
|
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
|
||||||
|
}),
|
||||||
|
data = select({
|
||||||
|
":linux_x86_64": ["@bun_linux_x64//:bun"],
|
||||||
|
":linux_aarch64": ["@bun_linux_aarch64//:bun"],
|
||||||
|
":darwin_x86_64": ["@bun_darwin_x64//:bun"],
|
||||||
|
":darwin_aarch64": ["@bun_darwin_aarch64//:bun"],
|
||||||
|
"//conditions:default": ["@bun_linux_x64//:bun"],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|||||||
46
tests/install_test/workspaces.sh
Executable file
46
tests/install_test/workspaces.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
bun_path="$1"
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "${workdir}"' EXIT
|
||||||
|
|
||||||
|
mkdir -p "${workdir}/packages/pkg-a" "${workdir}/packages/pkg-b"
|
||||||
|
|
||||||
|
cat >"${workdir}/package.json" <<'JSON'
|
||||||
|
{
|
||||||
|
"name": "workspace-root",
|
||||||
|
"private": true,
|
||||||
|
"workspaces": ["packages/*"]
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
cat >"${workdir}/packages/pkg-a/package.json" <<'JSON'
|
||||||
|
{
|
||||||
|
"name": "@workspace/pkg-a",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js"
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
cat >"${workdir}/packages/pkg-a/index.js" <<'JS'
|
||||||
|
module.exports = { value: 42 };
|
||||||
|
JS
|
||||||
|
|
||||||
|
cat >"${workdir}/packages/pkg-b/package.json" <<'JSON'
|
||||||
|
{
|
||||||
|
"name": "@workspace/pkg-b",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@workspace/pkg-a": "workspace:*"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"check": "bun -e \"const { value } = require('@workspace/pkg-a'); if (value !== 42) process.exit(1)\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
"${bun_path}" install --cwd "${workdir}" >/dev/null
|
||||||
|
rm -rf "${workdir}/node_modules" "${workdir}/packages/pkg-b/node_modules"
|
||||||
|
"${bun_path}" install --cwd "${workdir}" --frozen-lockfile >/dev/null
|
||||||
|
"${bun_path}" run --cwd "${workdir}/packages/pkg-b" check >/dev/null
|
||||||
Reference in New Issue
Block a user