Skip to content

Commit cbedbee

Browse files
committed
Fix tests, update instructions
1 parent 2076441 commit cbedbee

13 files changed

Lines changed: 30 additions & 16 deletions

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This file provides guidance to AI agents (Claude, Gemini, etc.) when working wit
99
- **External library packaging:** Libraries imported by transpiler files (ielib, folib) must use **named re-exports** (`export { X } from './module'`), not star re-exports (`export * from './module'`). Ambient declarations (`declare function`, `declare const`) must live in `.d.ts` files, not `.ts` files. See folib's `src/index.ts` for the correct pattern.
1010
- **URI normalization:** All URIs entering the provider system are normalized via `normalizeUri()` from `core/normalized-uri.ts`. The `ProviderRegistry` handles this at the gateway. If you add new URI-accepting methods to the registry, normalize them. If you use URIs as Map/Set keys elsewhere, use `NormalizedUri` branded type.
1111
- **User-facing messages:** Never call `connection.window.showInformationMessage/showWarningMessage/showErrorMessage` directly in server code. Use `showInfo()`, `showWarning()`, `showError()`, or `showErrorWithActions()` from `user-messages.ts` — they auto-decode `file://` URIs to readable paths. An oxlint rule enforces this.
12+
- **Temporary artifacts:** Put transient test/build files under the repo-level `tmp/` directory (or `os.tmpdir()` when system temp is required). Do not create ad hoc temp directories under source trees like `server/test/`, `cli/test/`, or `scripts/**`.
1213

1314
## Project Overview
1415

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ Press F5 in VSCode to launch the Extension Development Host. Server attaches on
3434
Server logs: Output panel, "BGforge MLS" channel.
3535

3636
TS plugin logs: set `"typescript.tsserver.log": "verbose"` in settings, check Output panel under "TypeScript".
37+
38+
## Temporary Files
39+
40+
Keep transient test/build artifacts under the repo-level `tmp/` directory unless a tool specifically requires system temp storage.
41+
42+
Do not create temporary directories inside source or fixture trees such as `server/test/`, `cli/test/`, or `scripts/**`.

cli/test/bin-cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function run(...args: string[]): { code: number; stdout: string; stderr: string
2828
}
2929

3030
describe("bin CLI integration", () => {
31-
const tmpDir = path.resolve("cli/test/.tmp-bin");
31+
const tmpDir = path.resolve("tmp/cli-test-bin");
3232

3333
beforeEach(() => {
3434
if (!fs.existsSync(CLI)) {

cli/test/cli-utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe("safeProcess", () => {
100100
});
101101

102102
describe("findFiles", () => {
103-
const tmpDir = path.join(process.cwd(), "cli/test/.tmp-findfiles");
103+
const tmpDir = path.resolve("tmp/cli-test-findfiles");
104104

105105
beforeEach(() => {
106106
fs.mkdirSync(path.join(tmpDir, "sub"), { recursive: true });
@@ -217,7 +217,7 @@ describe("runCli", () => {
217217
let exitSpy: ReturnType<typeof vi.spyOn>;
218218
let logSpy: ReturnType<typeof vi.spyOn>;
219219
let errorSpy: ReturnType<typeof vi.spyOn>;
220-
const tmpDir = path.join(process.cwd(), "cli/test/.tmp-runcli");
220+
const tmpDir = path.resolve("tmp/cli-test-runcli");
221221

222222
beforeEach(() => {
223223
exitSpy = vi.spyOn(process, "exit").mockImplementation(() => { throw new Error("exit"); });

cli/test/format-cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function run(...args: string[]): { code: number; stdout: string; stderr: string
2727
}
2828

2929
describe("format CLI integration", () => {
30-
const tmpDir = path.resolve("cli/test/.tmp-format");
30+
const tmpDir = path.resolve("tmp/cli-test-format");
3131

3232
beforeEach(() => {
3333
if (!fs.existsSync(CLI)) {

cli/test/transpile-cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function run(...args: string[]): { code: number; stdout: string; stderr: string
2929
}
3030

3131
describe("transpile CLI integration", () => {
32-
const tmpDir = path.resolve("cli/test/.tmp-transpile");
32+
const tmpDir = path.resolve("tmp/cli-test-transpile");
3333

3434
beforeEach(() => {
3535
if (!fs.existsSync(CLI)) {

knip.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ const config: KnipConfig = {
2424
],
2525
},
2626
server: {
27-
// Entry resolved from package.json "main" field (src/server.ts).
28-
// No explicit entry needed here.
27+
// Point knip at the TypeScript source entry directly.
28+
// The package.json "main" field targets the built JS output.
29+
entry: ["src/server.ts"],
2930
// vitest.smoke.config.ts is a separate config run by scripts/test.sh, not imported.
3031
ignore: [
3132
"**/*.d.ts",
3233
"vitest.smoke.config.ts",
3334
// Created at runtime by enum-transform.test.ts, may exist during parallel Knip runs
3435
...(isProductionKnip
35-
? ["vitest.integration.config.ts", "test/integration/**", "test/tmp-bundle-test/**"]
36+
? [
37+
"src/**",
38+
"vitest.integration.config.ts",
39+
"test/integration/**",
40+
]
3641
: []),
3742
],
3843
},

scripts/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ See also: [CONTRIBUTING.md](../CONTRIBUTING.md) | [docs/architecture.md](../docs
2727
- **Smoke test** (`test/smoke-stdio.test.ts`) -- requires a built server bundle (`pnpm build:base:server`). Run as part of `pnpm test` instead, which builds the bundle first.
2828
- **Integration tests** (`test/integration/`) -- require external repos cloned via `pnpm test:external`. Run standalone with `cd server && pnpm test:integration`, or as part of `pnpm test` (which clones repos first).
2929

30+
## Temporary Artifacts
31+
32+
Store transient logs, generated scratch files, and test temp directories under the repo-level `tmp/` directory.
33+
34+
Avoid writing temporary data into source and fixture trees such as `server/test/`, `cli/test/`, `scripts/**`, or `grammars/**`.
35+
3036
## Running individual tests
3137

3238
```bash

server/test/enum-transform.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe("expandEnumPropertyAccess — externalized enums", () => {
270270

271271
describe("bundle (esbuild integration)", () => {
272272
// Temp directory for creating ielib-like package structures
273-
const tmpDir = path.resolve(__dirname, "tmp-bundle-test");
273+
const tmpDir = path.resolve("tmp/server-test-bundle");
274274

275275
function writeTmpFile(relPath: string, content: string): string {
276276
const filePath = path.join(tmpDir, relPath);

server/test/inline-functions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ describe("collectReferencedIdentifiers", () => {
242242
});
243243

244244
describe("extractInlineFunctionsFromFiles", () => {
245-
const tmpDir = path.resolve(__dirname, "tmp-inline-test");
245+
const tmpDir = path.resolve("tmp/server-test-inline");
246246

247247
function writeTmpFile(name: string, content: string): string {
248248
if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir, { recursive: true });

0 commit comments

Comments
 (0)