Skip to content

Commit a428677

Browse files
committed
clean
1 parent 0098587 commit a428677

File tree

12 files changed

+343
-227
lines changed

12 files changed

+343
-227
lines changed

e2e/scripts/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class Cli {
1111
public stdout = '';
1212
public stderr = '';
1313
private stdoutListeners: Array<() => void> = [];
14-
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: will use it
1514
private stderrListeners: Array<() => void> = [];
1615

1716
constructor(

e2e/test-coverage/fixtures/src/string.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export const countWords = (str: string): number => {
2121

2222
export const truncate = (str: string, maxLength: number): string => {
2323
if (str.length <= maxLength) return str;
24-
return str.slice(0, maxLength - 3) + '...';
24+
return `${str.slice(0, maxLength - 3)}...`;
2525
};

packages/vscode/AGENTS.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Repository Guidelines
1+
# Repository guidelines
22

33
Concise contributor guide for the Rstest VS Code extension package.
44

5-
## Project Structure & Module Organization
5+
## Project structure & module organization
66

77
- `src/` — TypeScript sources. Key modules: `extension.ts` (entry/TestController), `testTree.ts` (builds TestItem tree), `parserTest.ts` (SWC-based parser), `master.ts` (spawns worker), `worker/` (runner + reporter).
88
- `tests/` — E2E tests under `tests/suite/**`. Compiled to `tests-dist/` for the Extension Host.
99
- `tests/unit/**` — Unit tests executed by `@rstest/core` with fixtures in `tests/unit/fixtures`.
1010
- `dist/` — Built extension output. Do not edit.
1111
- Config: `tsconfig.json`, `tsconfig.test.json`, `rslib.config.ts`, `rstest.config.ts`.
1212

13-
## Build, Test, and Development Commands
13+
## Build, test, and development commands
1414

1515
- `npm run build` — Build with `rslib` (use `build:local` for sourcemaps).
1616
- `npm run watch` — Rebuild on change.
@@ -19,25 +19,25 @@ Concise contributor guide for the Rstest VS Code extension package.
1919
- `npm run test:e2e` — Compile tests and run VS Code Extension Host E2E (downloads VS Code on first run).
2020
- `npm run lint` — Run Biome checks.
2121

22-
## Coding Style & Naming Conventions
22+
## Coding style & naming conventions
2323

2424
- Language: TypeScript, 2-space indentation. Keep changes minimal and focused.
2525
- Naming: camelCase for files and symbols; PascalCase for classes; follow existing patterns (e.g., `testTree.ts`, `parserTest.ts`).
2626
- Linting: Biome (`npm run lint`). Prefer simple, readable logic over cleverness.
2727

28-
## Testing Guidelines
28+
## Testing guidelines
2929

3030
- Name tests `*.test.ts`. Place parser/unit tests in `tests/unit/**`; E2E tests in `tests/suite/**` (loaded by the E2E runner only).
3131
- E2E opens `tests/fixtures` workspace automatically; use `toLabelTree()` from `tests/suite/index.test.ts` for stable tree assertions.
3232
- Typical loop: `npm run typecheck``npm run test:unit``npm run test:e2e`.
3333

34-
## Commit & Pull Request Guidelines
34+
## Commit & pull request guidelines
3535

3636
- Write clear, imperative commit messages; keep PRs small and scoped. Reference issues (e.g., `Fixes #123`).
3737
- Include rationale, testing notes, and screenshots/logs if relevant (e.g., label trees, error output).
3838
- Avoid unrelated refactors; update or add tests with behavior changes.
3939

40-
## Architecture Overview
40+
## Architecture overview
4141

4242
- Two-process design: VS Code extension (`extension.ts`) communicates with a worker (`worker/index.ts`) via WebSocket. Main sends `WorkerInitData`/`WorkerRunTestData`; worker emits `WorkerEventFinish`.
4343

packages/vscode/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The extension activates automatically when your workspace contains Rstest config
1919
| ---------------------------- | -------- | -------- | -------------------------------- | ------------------------------------------------------------- |
2020
| `rstest.testFileGlobPattern` | string[] | Resource | `["**/*.test.*", "**/*.spec.*"]` | Glob pattern(s) used to discover test files in the workspace. |
2121

22-
## How it Works
22+
## How it works
2323

2424
- On activation, the extension scans for test files using `rstest.testFileGlobPattern` and creates a Test Explorer tree.
2525
- File system watchers keep the tree synchronized as files are created, modified, or deleted.
@@ -35,11 +35,12 @@ Common commands (run from this package):
3535
- `npm run test:unit` — Unit tests via Rstest
3636
- `npm run test:e2e` — VS Code Extension Host E2E tests
3737

38-
### Packaging & Publishing
38+
### Packaging & publishing
3939

4040
- Local package (current platform): `npm run package:vsix`
4141
- Publish (current platform): `npm run publish:vsce` (requires `VSCE_PAT`)
4242

4343
CI
44+
4445
- On tag push or manual dispatch, GitHub Actions runs on Linux and publishes for all platforms using `vsce publish --target` (win32/darwin/linux; x64 and arm64).
4546
- Configure the `VSCE_PAT` repository secret for Marketplace publishing.

packages/vscode/src/extension.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -231,34 +231,6 @@ class Rstest {
231231
}
232232
};
233233

234-
// const runTestQueue = async () => {
235-
// for (const { test, data } of queue) {
236-
// run.appendOutput(`Running ${test.id}\r\n`);
237-
// if (run.token.isCancellationRequested) {
238-
// run.skipped(test);
239-
// } else {
240-
// run.started(test);
241-
// await data.run(test, run, this.api);
242-
// }
243-
244-
// const lineNo = test.range!.start.line;
245-
// const fileCoverage = coveredLines.get(test.uri!.toString());
246-
// const lineInfo = fileCoverage?.[lineNo];
247-
// if (lineInfo) {
248-
// (lineInfo.executed as number)++;
249-
// }
250-
251-
// run.appendOutput(`Completed ${test.id}\r\n`);
252-
// }
253-
254-
// // TODO: support coverage in the future
255-
// // for (const [uri, statements] of coveredLines) {
256-
// // run.addCoverage(new MarkdownFileCoverage(uri, statements));
257-
// // }
258-
259-
// run.end();
260-
// };
261-
262234
discoverTests(request.include ?? gatherTestItems(this.ctrl.items))
263235
.then(() => run.end())
264236
.catch((error) => {
@@ -279,12 +251,6 @@ class Rstest {
279251

280252
return;
281253
}
282-
283-
// async initialize(context: vscode.ExtensionContext) {
284-
// context.subscriptions.push(
285-
// ...startWatchingWorkspace(this.ctrl, this.fileChangedEmitter),
286-
// );
287-
// }
288254
}
289255

290256
function getOrCreateFile(controller: vscode.TestController, uri: vscode.Uri) {

packages/vscode/src/logger.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export class Logger implements vscode.Disposable {
5050
}
5151

5252
public dispose() {
53-
this.disposables.forEach((disposable) => disposable.dispose());
53+
this.disposables.forEach((disposable) => {
54+
disposable.dispose();
55+
});
5456
this.channel.dispose();
5557
}
5658

packages/vscode/src/master.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import getPort from 'get-port';
55
import vscode from 'vscode';
66
import type { WebSocket } from 'ws';
77
import { WebSocketServer } from 'ws';
8-
8+
import { logger } from './logger';
99
import type {
1010
WorkerEvent,
1111
WorkerEventFinish,
1212
WorkerRunTestData,
1313
} from './types';
14-
import { logger } from './logger';
1514

1615
export class RstestApi {
1716
public ws: WebSocket | null = null;
@@ -137,6 +136,10 @@ export class RstestApi {
137136
const workerPath = path.resolve(__dirname, 'worker.js');
138137
const port = await getPort();
139138
const wsAddress = `ws://localhost:${port}`;
139+
logger.debug('Spawning worker process', {
140+
workerPath,
141+
wsAddress,
142+
});
140143
const rstestProcess = spawn('node', [...execArgv, workerPath], {
141144
stdio: 'pipe',
142145
env: {
@@ -148,19 +151,20 @@ export class RstestApi {
148151

149152
rstestProcess.stdout?.on('data', (d) => {
150153
const content = d.toString();
151-
logger.debug('🟢 worker', content.trimEnd());
154+
logger.debug('worker stdout', content.trimEnd());
152155
});
153156

154157
rstestProcess.stderr?.on('data', (d) => {
155158
const content = d.toString();
156-
logger.error('🔴 worker', content.trimEnd());
159+
logger.error('worker stderr', content.trimEnd());
157160
});
158161

159162
const server = createServer().listen(port).unref();
160163
const wss = new WebSocketServer({ server });
161164

162165
wss.once('connection', (ws) => {
163166
this.ws = ws;
167+
logger.debug('Worker connected', { wsAddress });
164168
const { cwd, rstestPath } = this.resolveRstestPath()[0];
165169
ws.send(
166170
JSON.stringify({
@@ -169,11 +173,21 @@ export class RstestApi {
169173
cwd,
170174
}),
171175
);
176+
logger.debug('Sent init payload to worker', { cwd, rstestPath });
172177

173178
ws.on('message', (_data) => {
174179
const _message = JSON.parse(_data.toString()) as WorkerEvent;
175180
if (_message.type === 'finish') {
176181
const message: WorkerEventFinish = _message;
182+
logger.debug('Received worker completion event', {
183+
id: message.id,
184+
testResultCount: Array.isArray(message.testResults)
185+
? message.testResults.length
186+
: undefined,
187+
testFileResultCount: Array.isArray(message.testFileResults)
188+
? message.testFileResults.length
189+
: undefined,
190+
});
177191
// Check if we have a pending promise for this test ID
178192
const promiseObj = this.testPromises.get(message.id);
179193
if (promiseObj) {
@@ -186,7 +200,9 @@ export class RstestApi {
186200
});
187201
});
188202

189-
rstestProcess.on('exit', () => {});
203+
rstestProcess.on('exit', (code, signal) => {
204+
logger.debug('Worker process exited', { code, signal });
205+
});
190206
}
191207

192208
public async createRstestWorker() {}

0 commit comments

Comments
 (0)