From f9d2c362637c500e0563893e43996b08f9f974c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 08:43:51 +0000 Subject: [PATCH] test: add workspace monorepo bun install test Co-authored-by: Eriyc <50216491+Eriyc@users.noreply.github.com> --- tests/install_test/BUILD.bazel | 19 +++++++++++++ tests/install_test/workspaces.sh | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 tests/install_test/workspaces.sh diff --git a/tests/install_test/BUILD.bazel b/tests/install_test/BUILD.bazel index 92ac944..d8758dd 100644 --- a/tests/install_test/BUILD.bazel +++ b/tests/install_test/BUILD.bazel @@ -76,3 +76,22 @@ sh_test( args = ["$(location //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"], + }), +) diff --git a/tests/install_test/workspaces.sh b/tests/install_test/workspaces.sh new file mode 100755 index 0000000..30ce9ef --- /dev/null +++ b/tests/install_test/workspaces.sh @@ -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