test(package): stabilize package layout dry-runs

This commit is contained in:
YeonGyu-Kim
2026-05-28 14:43:06 +09:00
parent a3595c415f
commit a936490a6f
2 changed files with 12 additions and 6 deletions
+6 -3
View File
@@ -1,6 +1,6 @@
/// <reference types="bun-types" /> /// <reference types="bun-types" />
import { afterAll, beforeAll, describe, expect, test } from "bun:test" import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test"
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { dirname, join, relative, sep } from "node:path" import { dirname, join, relative, sep } from "node:path"
import { fileURLToPath } from "node:url" import { fileURLToPath } from "node:url"
@@ -25,13 +25,16 @@ const fakeInternalArtifactCleanupPaths = [
...fakeInternalSkillArtifactRootPaths, ...fakeInternalSkillArtifactRootPaths,
...fakeInternalCommandArtifactPaths, ...fakeInternalCommandArtifactPaths,
] as const ] as const
const packageLayoutTestTimeoutMs = 60_000
setDefaultTimeout(packageLayoutTestTimeoutMs)
let originalPackageJsonText: string | null = null let originalPackageJsonText: string | null = null
let packageJsonWasTemporarilyModified = false let packageJsonWasTemporarilyModified = false
class PackDryRunError extends Error { class PackDryRunError extends Error {
constructor(readonly exitCode: number, readonly stderr: string) { constructor(readonly exitCode: number, readonly stderr: string) {
super(`bun pm pack --dry-run failed with exit code ${exitCode}: ${stderr}`) super(`bun pm pack --dry-run --ignore-scripts failed with exit code ${exitCode}: ${stderr}`)
this.name = "PackDryRunError" this.name = "PackDryRunError"
} }
} }
@@ -90,7 +93,7 @@ function parsePackedPaths(output: string): Set<string> {
async function packDryRunPaths(): Promise<Set<string>> { async function packDryRunPaths(): Promise<Set<string>> {
const packProcess = Bun.spawn({ const packProcess = Bun.spawn({
cmd: ["bun", "pm", "pack", "--dry-run"], cmd: ["bun", "pm", "pack", "--dry-run", "--ignore-scripts"],
cwd: repositoryRoot, cwd: repositoryRoot,
stdout: "pipe", stdout: "pipe",
stderr: "pipe", stderr: "pipe",
+6 -3
View File
@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test" import { describe, expect, setDefaultTimeout, test } from "bun:test"
import { existsSync, readdirSync } from "node:fs" import { existsSync, readdirSync } from "node:fs"
import { join, relative, sep } from "node:path" import { join, relative, sep } from "node:path"
import { fileURLToPath } from "node:url" import { fileURLToPath } from "node:url"
@@ -6,10 +6,13 @@ import { fileURLToPath } from "node:url"
const repositoryRoot = fileURLToPath(new URL("..", import.meta.url)) const repositoryRoot = fileURLToPath(new URL("..", import.meta.url))
const commandRoots = [".opencode/command", ".agents/command"] as const const commandRoots = [".opencode/command", ".agents/command"] as const
const skillRoots = [".opencode/skills", ".agents/skills"] as const const skillRoots = [".opencode/skills", ".agents/skills"] as const
const packageLayoutTestTimeoutMs = 60_000
setDefaultTimeout(packageLayoutTestTimeoutMs)
class PackDryRunError extends Error { class PackDryRunError extends Error {
constructor(readonly exitCode: number, readonly stderr: string) { constructor(readonly exitCode: number, readonly stderr: string) {
super(`bun pm pack --dry-run failed with exit code ${exitCode}: ${stderr}`) super(`bun pm pack --dry-run --ignore-scripts failed with exit code ${exitCode}: ${stderr}`)
this.name = "PackDryRunError" this.name = "PackDryRunError"
} }
} }
@@ -98,7 +101,7 @@ function parsePackedPaths(output: string): Set<string> {
async function packDryRunPaths(): Promise<Set<string>> { async function packDryRunPaths(): Promise<Set<string>> {
const packProcess = Bun.spawn({ const packProcess = Bun.spawn({
cmd: ["bun", "pm", "pack", "--dry-run"], cmd: ["bun", "pm", "pack", "--dry-run", "--ignore-scripts"],
cwd: repositoryRoot, cwd: repositoryRoot,
stdout: "pipe", stdout: "pipe",
stderr: "pipe", stderr: "pipe",