@fliwright/tdd 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/dist/baseline/AppCapabilityResetAdapter.d.ts +6 -0
- package/dist/baseline/AppCapabilityResetAdapter.js +41 -0
- package/dist/baseline/BaselineManager.d.ts +67 -0
- package/dist/baseline/BaselineManager.js +145 -0
- package/dist/baseline/StorageResetAdapter.d.ts +19 -0
- package/dist/baseline/StorageResetAdapter.js +43 -0
- package/dist/daemon/DaemonTransport.d.ts +37 -0
- package/dist/daemon/DaemonTransport.js +1 -0
- package/dist/daemon/FlutterDaemonController.d.ts +20 -0
- package/dist/daemon/FlutterDaemonController.js +120 -0
- package/dist/daemon/FlutterDaemonEndpointSource.d.ts +23 -0
- package/dist/daemon/FlutterDaemonEndpointSource.js +37 -0
- package/dist/daemon/ReloadStrategy.d.ts +28 -0
- package/dist/daemon/ReloadStrategy.js +72 -0
- package/dist/daemon/SubprocessDaemonTransport.d.ts +32 -0
- package/dist/daemon/SubprocessDaemonTransport.js +171 -0
- package/dist/diagnostics/TddFailureContext.d.ts +56 -0
- package/dist/diagnostics/TddFailureContext.js +220 -0
- package/dist/executor/FocusedRerunRecipe.d.ts +7 -0
- package/dist/executor/FocusedRerunRecipe.js +64 -0
- package/dist/executor/PersistentTestExecutor.d.ts +56 -0
- package/dist/executor/PersistentTestExecutor.js +235 -0
- package/dist/executor/TestRunResults.d.ts +13 -0
- package/dist/executor/TestRunResults.js +19 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +13 -0
- package/dist/runtime/TddRuntime.d.ts +73 -0
- package/dist/runtime/TddRuntime.js +552 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +2 -0
- package/package.json +42 -3
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { mkdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { basename, join, resolve } from 'node:path';
|
|
3
|
+
import { FLIWRIGHT_RUNS_ROOT_ENV, RunArtifactStore, parseTimelineData, resolveFliwrightRunsRoot, resolveFliwrightRuntimeRoot, resolveFliwrightCacheRoot, mergeFliwrightConfig, readFliwrightEnvironment, writeFliwrightConfigSnapshot } from '@fliwright/core';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { startVitest } from 'vitest/node';
|
|
6
|
+
import { focusAndRerun } from './FocusedRerunRecipe.js';
|
|
7
|
+
import { collectResultsFromModules } from './TestRunResults.js';
|
|
8
|
+
export class PersistentTestExecutor {
|
|
9
|
+
vitest;
|
|
10
|
+
previousDefaultScenario;
|
|
11
|
+
previousScenarioMode;
|
|
12
|
+
previousVmServiceUrl;
|
|
13
|
+
previousVmUrl;
|
|
14
|
+
previousTddMode;
|
|
15
|
+
previousScreenshotMode;
|
|
16
|
+
previousFailureTimeoutMs;
|
|
17
|
+
previousRunsRoot;
|
|
18
|
+
previousRunId;
|
|
19
|
+
previousSharedConfig;
|
|
20
|
+
previousProjectRoot;
|
|
21
|
+
runsRoot;
|
|
22
|
+
envApplied = false;
|
|
23
|
+
async boot(opts) {
|
|
24
|
+
if (this.vitest)
|
|
25
|
+
return;
|
|
26
|
+
// Apply env first; if anything after it throws, restore it so the CLI connection worker is not
|
|
27
|
+
// left with TDD env vars leaking into unrelated (batch) test runs.
|
|
28
|
+
await this.applyRuntimeEnv(opts);
|
|
29
|
+
try {
|
|
30
|
+
this.vitest = await startVitest('test', [], {
|
|
31
|
+
root: looksLikeConfigFile(opts.configRoot) ? undefined : resolve(opts.configRoot),
|
|
32
|
+
config: looksLikeConfigFile(opts.configRoot) ? resolve(opts.configRoot) : undefined,
|
|
33
|
+
watch: true,
|
|
34
|
+
standalone: true,
|
|
35
|
+
reporters: [],
|
|
36
|
+
pool: 'forks',
|
|
37
|
+
maxWorkers: 1,
|
|
38
|
+
}, {
|
|
39
|
+
// macOS FSEvents can deliver a config write from before boot after a
|
|
40
|
+
// focused run starts, causing Vite to close its active module cache.
|
|
41
|
+
...(process.platform === 'darwin' ? { server: { watch: { usePolling: true } } } : {}),
|
|
42
|
+
plugins: [{
|
|
43
|
+
name: 'fliwright-runner',
|
|
44
|
+
config(config) {
|
|
45
|
+
const runtimeConfig = config;
|
|
46
|
+
(runtimeConfig.test ??= {}).runner ??= fileURLToPath(import.meta.resolve('@fliwright/vitest/runner'));
|
|
47
|
+
},
|
|
48
|
+
}],
|
|
49
|
+
});
|
|
50
|
+
if (!this.vitest)
|
|
51
|
+
throw new Error('Failed to start Vitest');
|
|
52
|
+
// A directly used executor can receive storage through the project's
|
|
53
|
+
// Vitest preset. Resolve the same root the worker actually receives.
|
|
54
|
+
const workerRoot = this.vitest.projects[0]?.config.env?.FLIWRIGHT_RUNS_ROOT;
|
|
55
|
+
if (workerRoot)
|
|
56
|
+
this.runsRoot = resolve(String(workerRoot));
|
|
57
|
+
await mkdir(this.runsRoot, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
await this.dispose().catch(() => undefined);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async rerun(file, testName) {
|
|
65
|
+
if (!this.vitest)
|
|
66
|
+
throw new Error('PersistentTestExecutor not booted');
|
|
67
|
+
// The public API returns the exact run we requested. A reporter's next
|
|
68
|
+
// event may instead belong to a watcher refresh (or contain no modules).
|
|
69
|
+
const run = await focusAndRerun(this.vitest, file, testName);
|
|
70
|
+
const files = run.testModules;
|
|
71
|
+
const results = collectResultsFromModules(files);
|
|
72
|
+
const picked = results.find((result) => result.status === 'red') ?? results[0];
|
|
73
|
+
const resolvedTestName = picked?.fullName ?? testName;
|
|
74
|
+
const errors = [
|
|
75
|
+
...results.filter((result) => result.status === 'red').map((result) => result.message ?? `${result.fullName} failed.`),
|
|
76
|
+
...files.flatMap((module) => [module, ...module.children.allSuites()].flatMap((suite) => suite.errors().map((error) => error.message))),
|
|
77
|
+
...run.unhandledErrors.map((error) => error instanceof Error ? error.message
|
|
78
|
+
: error && typeof error === 'object' && 'message' in error ? String(error.message) : String(error)),
|
|
79
|
+
];
|
|
80
|
+
const failed = errors.length > 0 || files.some((module) => module.state() === 'failed') || !picked;
|
|
81
|
+
const timelineArtifacts = await this.readTimelineArtifacts(picked);
|
|
82
|
+
const failureDetails = picked?.status === 'red' && resolvedTestName
|
|
83
|
+
? await this.readFailureDetails(picked)
|
|
84
|
+
: undefined;
|
|
85
|
+
return {
|
|
86
|
+
status: failed ? 'red' : 'green',
|
|
87
|
+
testName: resolvedTestName,
|
|
88
|
+
failure: failed ? { message: errors.join('\n') || (!picked
|
|
89
|
+
? 'Focused run returned no matching test result.' : 'Focused test module failed.') } : undefined,
|
|
90
|
+
failureDetails,
|
|
91
|
+
timelinePath: failureDetails?.artifacts?.timelinePath ?? timelineArtifacts.timelinePath,
|
|
92
|
+
timelineNodeId: failureDetails?.artifacts?.timelineNodeId ?? timelineArtifacts.timelineNodeId,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async dispose() {
|
|
96
|
+
try {
|
|
97
|
+
await this.vitest?.close();
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
this.vitest = undefined;
|
|
101
|
+
if (this.envApplied)
|
|
102
|
+
this.restoreRuntimeEnv();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
restoreRuntimeEnv() {
|
|
106
|
+
restoreEnv('FLIWRIGHT_SCENARIO_MODE', this.previousScenarioMode);
|
|
107
|
+
restoreEnv('FLIWRIGHT_DEFAULT_SCENARIO', this.previousDefaultScenario);
|
|
108
|
+
restoreEnv('FLIWRIGHT_VM_SERVICE_URL', this.previousVmServiceUrl);
|
|
109
|
+
restoreEnv('FLIWRIGHT_VM_URL', this.previousVmUrl);
|
|
110
|
+
restoreEnv('FLIWRIGHT_TDD_MODE', this.previousTddMode);
|
|
111
|
+
restoreEnv('FLIWRIGHT_SCREENSHOT_MODE', this.previousScreenshotMode);
|
|
112
|
+
restoreEnv('FLIWRIGHT_FAILURE_TIMEOUT_MS', this.previousFailureTimeoutMs);
|
|
113
|
+
restoreEnv(FLIWRIGHT_RUNS_ROOT_ENV, this.previousRunsRoot);
|
|
114
|
+
restoreEnv('FLIWRIGHT_RUN_ID', this.previousRunId);
|
|
115
|
+
restoreEnv('FLIWRIGHT_CONFIG_PATH', this.previousSharedConfig);
|
|
116
|
+
restoreEnv('FLIWRIGHT_PROJECT_ROOT', this.previousProjectRoot);
|
|
117
|
+
this.envApplied = false;
|
|
118
|
+
}
|
|
119
|
+
async applyRuntimeEnv(opts) {
|
|
120
|
+
this.snapshotPreviousEnv();
|
|
121
|
+
try {
|
|
122
|
+
process.env.FLIWRIGHT_TDD_MODE = '1';
|
|
123
|
+
process.env.FLIWRIGHT_SCENARIO_MODE = opts.scenarioMode ?? 'attach';
|
|
124
|
+
if (opts.defaultScenario)
|
|
125
|
+
process.env.FLIWRIGHT_DEFAULT_SCENARIO = opts.defaultScenario;
|
|
126
|
+
if (opts.vmServiceUrl) {
|
|
127
|
+
process.env.FLIWRIGHT_VM_SERVICE_URL = opts.vmServiceUrl;
|
|
128
|
+
process.env.FLIWRIGHT_VM_URL = opts.vmServiceUrl;
|
|
129
|
+
}
|
|
130
|
+
const projectRoot = looksLikeConfigFile(opts.configRoot) ? resolve(opts.configRoot, '..') : resolve(opts.configRoot);
|
|
131
|
+
const config = mergeFliwrightConfig({ projectRoot, project: opts.sharedConfig, environment: readFliwrightEnvironment(process.env), explicit: { runsRoot: opts.runsRoot } });
|
|
132
|
+
this.runsRoot = resolveFliwrightRunsRoot({ projectRoot, runsRoot: config.runsRoot });
|
|
133
|
+
await mkdir(this.runsRoot, { recursive: true });
|
|
134
|
+
if (opts.sharedConfig) {
|
|
135
|
+
config.cacheRoot = resolveFliwrightCacheRoot({ projectRoot, cacheRoot: config.cacheRoot });
|
|
136
|
+
config.runsRoot = this.runsRoot;
|
|
137
|
+
process.env.FLIWRIGHT_CONFIG_PATH = writeFliwrightConfigSnapshot(config, { projectRoot, cacheRoot: config.cacheRoot });
|
|
138
|
+
}
|
|
139
|
+
process.env.FLIWRIGHT_PROJECT_ROOT = projectRoot;
|
|
140
|
+
if (config.runsRoot)
|
|
141
|
+
process.env[FLIWRIGHT_RUNS_ROOT_ENV] = this.runsRoot;
|
|
142
|
+
process.env.FLIWRIGHT_SCREENSHOT_MODE = process.env.FLIWRIGHT_SCREENSHOT_MODE ?? 'base64';
|
|
143
|
+
process.env.FLIWRIGHT_FAILURE_TIMEOUT_MS = process.env.FLIWRIGHT_FAILURE_TIMEOUT_MS ?? '5000';
|
|
144
|
+
this.envApplied = true;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// mkdir/writeFile can throw; restore anything we already wrote so we never leak partial env.
|
|
148
|
+
this.restoreRuntimeEnv();
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
snapshotPreviousEnv() {
|
|
153
|
+
this.previousScenarioMode = process.env.FLIWRIGHT_SCENARIO_MODE;
|
|
154
|
+
this.previousDefaultScenario = process.env.FLIWRIGHT_DEFAULT_SCENARIO;
|
|
155
|
+
this.previousVmServiceUrl = process.env.FLIWRIGHT_VM_SERVICE_URL;
|
|
156
|
+
this.previousVmUrl = process.env.FLIWRIGHT_VM_URL;
|
|
157
|
+
this.previousTddMode = process.env.FLIWRIGHT_TDD_MODE;
|
|
158
|
+
this.previousScreenshotMode = process.env.FLIWRIGHT_SCREENSHOT_MODE;
|
|
159
|
+
this.previousFailureTimeoutMs = process.env.FLIWRIGHT_FAILURE_TIMEOUT_MS;
|
|
160
|
+
this.previousRunsRoot = process.env[FLIWRIGHT_RUNS_ROOT_ENV];
|
|
161
|
+
this.previousRunId = process.env.FLIWRIGHT_RUN_ID;
|
|
162
|
+
this.previousSharedConfig = process.env.FLIWRIGHT_CONFIG_PATH;
|
|
163
|
+
this.previousProjectRoot = process.env.FLIWRIGHT_PROJECT_ROOT;
|
|
164
|
+
}
|
|
165
|
+
attemptDirectory(result) {
|
|
166
|
+
const identity = result?.runIdentity;
|
|
167
|
+
if (!this.runsRoot || !identity)
|
|
168
|
+
return undefined;
|
|
169
|
+
return new RunArtifactStore({ runsRoot: this.runsRoot, runId: identity.runId })
|
|
170
|
+
.attemptDir(identity.testId, identity.attemptId);
|
|
171
|
+
}
|
|
172
|
+
async readFailureDetails(result) {
|
|
173
|
+
const directory = this.attemptDirectory(result);
|
|
174
|
+
if (!directory)
|
|
175
|
+
return undefined;
|
|
176
|
+
try {
|
|
177
|
+
const attempt = JSON.parse(await readFile(join(directory, 'result.json'), 'utf8'));
|
|
178
|
+
if (!attempt.failureContextPath)
|
|
179
|
+
return undefined;
|
|
180
|
+
const failureContextPath = join(directory, attempt.failureContextPath);
|
|
181
|
+
const entries = JSON.parse(await readFile(failureContextPath, 'utf8'));
|
|
182
|
+
const entry = entries.filter((candidate) => candidate.testName === result?.testName).at(-1);
|
|
183
|
+
if (!entry)
|
|
184
|
+
return undefined;
|
|
185
|
+
const screenshotBase64 = entry.screenshot?.path
|
|
186
|
+
? (await readFile(join(directory, entry.screenshot.path))).toString('base64') : undefined;
|
|
187
|
+
return {
|
|
188
|
+
assertion: entry.assertion, source: entry.source,
|
|
189
|
+
artifacts: { failureContextPath, screenshotBase64, widgetTree: entry.widgetTree,
|
|
190
|
+
...await this.readTimelineArtifacts(result) },
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async readTimelineArtifacts(result) {
|
|
198
|
+
const directory = this.attemptDirectory(result);
|
|
199
|
+
if (!directory)
|
|
200
|
+
return {};
|
|
201
|
+
try {
|
|
202
|
+
const timelinePath = join(directory, 'timeline.json');
|
|
203
|
+
const timeline = parseTimelineData(await readFile(timelinePath, 'utf8'));
|
|
204
|
+
if (!timeline)
|
|
205
|
+
return {};
|
|
206
|
+
return { timelinePath, timelineNodeId: timeline.agentVisibleFailures?.[0]?.timelineNodeId };
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return {};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function restoreEnv(name, value) {
|
|
214
|
+
if (value === undefined)
|
|
215
|
+
delete process.env[name];
|
|
216
|
+
else
|
|
217
|
+
process.env[name] = value;
|
|
218
|
+
}
|
|
219
|
+
export function defaultArtifactsRoot(configRoot) {
|
|
220
|
+
const root = looksLikeConfigFile(configRoot) ? resolve(configRoot, '..') : resolve(configRoot);
|
|
221
|
+
return resolveFliwrightRunsRoot({ projectRoot: root });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Default RuntimeSnapshot status-file path a read-only monitor (e.g. the VS Code TDD Loop panel)
|
|
225
|
+
* polls: `~/.fliwright/<project-path>/runtime/tdd-status.json`. The project root is derived from the same
|
|
226
|
+
* configRoot convention as {@link defaultArtifactsRoot}.
|
|
227
|
+
*/
|
|
228
|
+
export function defaultStatusFilePath(configRoot) {
|
|
229
|
+
const root = looksLikeConfigFile(configRoot) ? resolve(configRoot, '..') : resolve(configRoot);
|
|
230
|
+
return join(resolveFliwrightRuntimeRoot({ projectRoot: root }), 'runtime', 'tdd-status.json');
|
|
231
|
+
}
|
|
232
|
+
function looksLikeConfigFile(configRoot) {
|
|
233
|
+
const name = basename(configRoot);
|
|
234
|
+
return /\.[cm]?[jt]s$/.test(name);
|
|
235
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TestModule } from 'vitest/node';
|
|
2
|
+
export interface CollectedResult {
|
|
3
|
+
testName: string;
|
|
4
|
+
fullName: string;
|
|
5
|
+
status: 'red' | 'green';
|
|
6
|
+
message?: string;
|
|
7
|
+
runIdentity?: {
|
|
8
|
+
runId: string;
|
|
9
|
+
testId: string;
|
|
10
|
+
attemptId: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function collectResultsFromModules(modules: TestModule[]): CollectedResult[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function collectResultsFromModules(modules) {
|
|
2
|
+
const results = [];
|
|
3
|
+
for (const module of modules) {
|
|
4
|
+
for (const testCase of module.children.allTests()) {
|
|
5
|
+
const result = testCase.result();
|
|
6
|
+
if (result.state !== 'passed' && result.state !== 'failed')
|
|
7
|
+
continue;
|
|
8
|
+
const identity = testCase.meta().fliwrightRun;
|
|
9
|
+
results.push({
|
|
10
|
+
...(identity ? { runIdentity: identity } : {}),
|
|
11
|
+
testName: testCase.name,
|
|
12
|
+
fullName: testCase.fullName,
|
|
13
|
+
status: result.state === 'passed' ? 'green' : 'red',
|
|
14
|
+
message: result.errors?.map((error) => error.message).join('\n'),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return results;
|
|
19
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { AppHandle, AppStartParams, DaemonMessage, DaemonTransport } from './daemon/DaemonTransport.js';
|
|
2
|
+
export { FlutterDaemonController } from './daemon/FlutterDaemonController.js';
|
|
3
|
+
export { FlutterDaemonEndpointSource } from './daemon/FlutterDaemonEndpointSource.js';
|
|
4
|
+
export type { FlutterDaemonEndpointSourceOptions } from './daemon/FlutterDaemonEndpointSource.js';
|
|
5
|
+
export { SubprocessDaemonTransport, parseDaemonLines } from './daemon/SubprocessDaemonTransport.js';
|
|
6
|
+
export { decideSync, isStructuralFileChange, looksStructuralAfterReload, } from './daemon/ReloadStrategy.js';
|
|
7
|
+
export type { SyncDecision } from './daemon/ReloadStrategy.js';
|
|
8
|
+
export type { SubprocessDaemonTransportOptions } from './daemon/SubprocessDaemonTransport.js';
|
|
9
|
+
export { BaselineManager } from './baseline/BaselineManager.js';
|
|
10
|
+
export type { ResetAdapter, ResetContext, StorageResetOutcome, } from './baseline/BaselineManager.js';
|
|
11
|
+
export { AuthTokensResetAdapter, LocalDbResetAdapter, SecureStorageResetAdapter, StorageBackedResetAdapters, StorageResetAdapter, } from './baseline/StorageResetAdapter.js';
|
|
12
|
+
export { AppCapabilityResetAdapters, IsolatesResetAdapter, PermissionsResetAdapter, TimersResetAdapter, WebviewResetAdapter, } from './baseline/AppCapabilityResetAdapter.js';
|
|
13
|
+
export { TddRuntime } from './runtime/TddRuntime.js';
|
|
14
|
+
export { PersistentTestExecutor } from './executor/PersistentTestExecutor.js';
|
|
15
|
+
export type { BootOptions, TestRunOutcome } from './executor/PersistentTestExecutor.js';
|
|
16
|
+
export { defaultArtifactsRoot, defaultStatusFilePath } from './executor/PersistentTestExecutor.js';
|
|
17
|
+
export { focusAndRerun } from './executor/FocusedRerunRecipe.js';
|
|
18
|
+
export { collectResultsFromModules } from './executor/TestRunResults.js';
|
|
19
|
+
export type { CollectedResult } from './executor/TestRunResults.js';
|
|
20
|
+
export { buildTddFailureContext, classifyFailure } from './diagnostics/TddFailureContext.js';
|
|
21
|
+
export type { BuildTddFailureContextInput, TddFailureArtifacts, TddFailureAssertion, TddFailureContext, TddFailureKind, TddRecoveryHint, TddRecoveryHintKind, TddFailureSource, } from './diagnostics/TddFailureContext.js';
|
|
22
|
+
export type { CycleOpts, ResetAdapterResult, ResetCategory, ResetReport, RuntimeSnapshot, BaselineConfig, StartOpts, TddCycleAttempt, TddCycleResult, TddSyncResult, TddRuntimeDeps, } from './types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { FlutterDaemonController } from './daemon/FlutterDaemonController.js';
|
|
2
|
+
export { FlutterDaemonEndpointSource } from './daemon/FlutterDaemonEndpointSource.js';
|
|
3
|
+
export { SubprocessDaemonTransport, parseDaemonLines } from './daemon/SubprocessDaemonTransport.js';
|
|
4
|
+
export { decideSync, isStructuralFileChange, looksStructuralAfterReload, } from './daemon/ReloadStrategy.js';
|
|
5
|
+
export { BaselineManager } from './baseline/BaselineManager.js';
|
|
6
|
+
export { AuthTokensResetAdapter, LocalDbResetAdapter, SecureStorageResetAdapter, StorageBackedResetAdapters, StorageResetAdapter, } from './baseline/StorageResetAdapter.js';
|
|
7
|
+
export { AppCapabilityResetAdapters, IsolatesResetAdapter, PermissionsResetAdapter, TimersResetAdapter, WebviewResetAdapter, } from './baseline/AppCapabilityResetAdapter.js';
|
|
8
|
+
export { TddRuntime } from './runtime/TddRuntime.js';
|
|
9
|
+
export { PersistentTestExecutor } from './executor/PersistentTestExecutor.js';
|
|
10
|
+
export { defaultArtifactsRoot, defaultStatusFilePath } from './executor/PersistentTestExecutor.js';
|
|
11
|
+
export { focusAndRerun } from './executor/FocusedRerunRecipe.js';
|
|
12
|
+
export { collectResultsFromModules } from './executor/TestRunResults.js';
|
|
13
|
+
export { buildTddFailureContext, classifyFailure } from './diagnostics/TddFailureContext.js';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { CycleOpts, RuntimeSnapshot, BaselineConfig, StartOpts, TddCycleResult, TddSyncResult, TddRuntimeDeps } from '../types.js';
|
|
2
|
+
export declare class TddRuntime {
|
|
3
|
+
private readonly daemon;
|
|
4
|
+
private readonly executor;
|
|
5
|
+
private readonly driverFactory;
|
|
6
|
+
private readonly injectedBaseline?;
|
|
7
|
+
private baseline?;
|
|
8
|
+
private driver?;
|
|
9
|
+
private app?;
|
|
10
|
+
private vmServiceUrl?;
|
|
11
|
+
private configRoot?;
|
|
12
|
+
private sharedConfig?;
|
|
13
|
+
private startAppParams?;
|
|
14
|
+
private defaultScenarioName?;
|
|
15
|
+
private baselineConfig;
|
|
16
|
+
private focusedTest?;
|
|
17
|
+
private lastResult?;
|
|
18
|
+
private started;
|
|
19
|
+
private launchMode;
|
|
20
|
+
private driverConnections;
|
|
21
|
+
private startSignature?;
|
|
22
|
+
private updatedAtMs;
|
|
23
|
+
private readonly endpointLeases;
|
|
24
|
+
private operationChain;
|
|
25
|
+
private statusFilePath?;
|
|
26
|
+
private statusWriteChain;
|
|
27
|
+
constructor(deps?: TddRuntimeDeps);
|
|
28
|
+
start(opts: StartOpts): Promise<RuntimeSnapshot>;
|
|
29
|
+
/** Interrupt owned transports/execution; the operation chain still drains before reuse. */
|
|
30
|
+
cancel(): Promise<void>;
|
|
31
|
+
/** Wait for real work, including a cycle whose caller already received timeout. */
|
|
32
|
+
whenIdle(): Promise<void>;
|
|
33
|
+
focus(file: string, testName?: string): Promise<void>;
|
|
34
|
+
/** Select the named scenario that Vitest fixtures prepare before every attempt. */
|
|
35
|
+
setDefaultScenario(name: string): Promise<RuntimeSnapshot>;
|
|
36
|
+
setBaselineConfig(config: BaselineConfig): Promise<RuntimeSnapshot>;
|
|
37
|
+
syncApp(sync: Exclude<NonNullable<CycleOpts['sync']>, 'auto'>): Promise<TddSyncResult>;
|
|
38
|
+
cycle(testName?: string, opts?: CycleOpts): Promise<TddCycleResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Reconnect after a VM disconnect (design §8). Daemon-start relaunches the app and rebinds to the
|
|
41
|
+
* fresh VM service; attach retries the original URL. If the URL changed, the executor is rebooted
|
|
42
|
+
* so fixtures pick up the new `FLIWRIGHT_VM_SERVICE_URL`. Throws on failure; the caller surfaces a
|
|
43
|
+
* structured error. Awaited on the cycle chain so it never races an in-flight rerun.
|
|
44
|
+
*/
|
|
45
|
+
reconnect(): Promise<RuntimeSnapshot>;
|
|
46
|
+
private reconnectNow;
|
|
47
|
+
private verifyManagedEndpoint;
|
|
48
|
+
private runCycleWithEscalation;
|
|
49
|
+
private timeoutResult;
|
|
50
|
+
private performCycle;
|
|
51
|
+
/**
|
|
52
|
+
* Best-effort, non-blocking dump of {@link snapshot} to {@link statusFilePath}, serialized so
|
|
53
|
+
* concurrent writes never interleave. Read-only monitors (VS Code TDD Loop panel) poll this file
|
|
54
|
+
* instead of opening a second driver connection. Never throws; failures are swallowed.
|
|
55
|
+
*/
|
|
56
|
+
private persistStatus;
|
|
57
|
+
private persistStatusTo;
|
|
58
|
+
/** Current endpoint for an owning CLI host; changes after managed reconnect. */
|
|
59
|
+
get endpoint(): string | undefined;
|
|
60
|
+
snapshot(): RuntimeSnapshot;
|
|
61
|
+
stop(opts?: {
|
|
62
|
+
keepAppAlive?: boolean;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
private markUpdated;
|
|
65
|
+
private enqueueOperation;
|
|
66
|
+
private controlPhase;
|
|
67
|
+
private sync;
|
|
68
|
+
/** True only when a daemon-started app advertised restart support (gates auto-escalation). */
|
|
69
|
+
private canRestart;
|
|
70
|
+
private requireDriver;
|
|
71
|
+
private requireBaseline;
|
|
72
|
+
private cleanupStartedResources;
|
|
73
|
+
}
|