mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
9d7d60c5e0
* test(coverage): declare every public command's six platform coverage judgments once One row per public command in test/integration/command-coverage/declarations.ts carries the android-emulator, ios-simulator, macOS, tvOS, web and Linux classifications with the same fields the six per-platform manifests use today. Each platform's Record<PublicCommand, ...> is projected from that table at load time by a small per-platform view module, so no projected record is committed. No judgment is derived from another platform's: all six stay authored per command. * test(coverage): read the projected per-platform coverage view The six coverage smoke tests, live harnesses and coverage reports now import the platform view module that projects the declaration table. Both the depgraph blast-radius query and the device-lane test follow the iOS and macOS paths. * test(coverage): delete the six per-platform coverage manifests Their rows now live once, per command, in the declaration table; each platform's record is projected from it at load time. * fix(check-affected): extend macos-coverage and integration-node ownership to command-coverage/ test/integration/command-coverage/declarations.ts now carries the per-command coverage judgments that used to live directly under test/integration/macos-e2e/. Its nested path wasn't matched by macosCoverageOwnership (top-level or macos-e2e/ only) or isNodeIntegrationPath (no nested segments), so it fell through to vitest-related, which can't actually run its node --test consumers. Extend both rules to also match test/integration/command-coverage/.
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
import {
|
|
WEB_PLATFORM_COVERAGE_CLASSIFICATION_SUMMARY,
|
|
liveCommandsForWebSmoke,
|
|
} from './coverage.ts';
|
|
|
|
export type WebSmokeStep = {
|
|
command: string;
|
|
status: number;
|
|
};
|
|
|
|
export async function runCleanupWithCoverageReport(
|
|
artifactDir: string,
|
|
steps: readonly WebSmokeStep[],
|
|
cleanup: () => Promise<void>,
|
|
): Promise<void> {
|
|
let cleanupFailed = false;
|
|
let cleanupError: unknown;
|
|
let reportFailed = false;
|
|
let reportError: unknown;
|
|
try {
|
|
try {
|
|
await cleanup();
|
|
} catch (error) {
|
|
cleanupFailed = true;
|
|
cleanupError = error;
|
|
}
|
|
} finally {
|
|
try {
|
|
writeCoverageReport(artifactDir, steps);
|
|
} catch (error) {
|
|
reportFailed = true;
|
|
reportError = error;
|
|
}
|
|
}
|
|
if (cleanupFailed && reportFailed) {
|
|
throw new AggregateError(
|
|
[cleanupError, reportError],
|
|
'web smoke cleanup and coverage reporting failed',
|
|
);
|
|
}
|
|
if (cleanupFailed) throw cleanupError;
|
|
if (reportFailed) throw reportError;
|
|
}
|
|
|
|
export function writeCoverageReport(artifactDir: string, steps: readonly WebSmokeStep[]): string {
|
|
const reportPath = path.join(artifactDir, 'coverage-report.json');
|
|
fs.writeFileSync(
|
|
reportPath,
|
|
JSON.stringify(
|
|
{
|
|
classificationSummary: WEB_PLATFORM_COVERAGE_CLASSIFICATION_SUMMARY,
|
|
liveCommands: liveCommandsForWebSmoke(),
|
|
steps,
|
|
},
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
return reportPath;
|
|
}
|