Skip to content

Commit c290ae8

Browse files
committed
favor: restore test running
1 parent dc79713 commit c290ae8

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

packages/core/src/entry/testing/cli/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ async function main() {
112112
}
113113

114114
const { cases, patterns, antipatterns } = await testplanner(
115+
environment,
115116
parseSmokeConfig(smoke),
116117
...positionals,
117118
);
@@ -154,11 +155,11 @@ No testcases were specified!
154155
console.info(
155156
`${testplan
156157
.map(
157-
({ testcase, environment }) =>
158+
({ testcase, testenv }) =>
158159
`${testcase}${
159160
plan || verbose
160161
? `\n` +
161-
JSON.stringify(environment, null, 2)
162+
JSON.stringify(testenv, null, 2)
162163
.split("\n")
163164
.slice(1, -1)
164165
.join("\n") +

packages/core/src/entry/testing/cli/runner.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ declare global {
5454
export type TestSetup = {
5555
test: () => Promise<void>;
5656
testcase: string;
57-
environment: Record<string, unknown>;
57+
testenv: Record<string, unknown>;
5858
};
5959

6060
const inflight = new AsyncLocalStorage<{
@@ -111,11 +111,7 @@ ${failing.map(({ testcase }) => `${testcase}: FAIL\n`).join("")}
111111

112112
export async function executeSelectedTests(
113113
configuration: PardonTestConfiguration,
114-
selectedTests: {
115-
test: () => Promise<void>;
116-
testcase: string;
117-
environment: Record<string, unknown>;
118-
}[],
114+
selectedTests: TestSetup[],
119115
report: string,
120116
ff: boolean | undefined,
121117
) {
@@ -136,7 +132,7 @@ export async function executeSelectedTests(
136132

137133
const testResults = await all_disconnected(
138134
selectedTests.map(
139-
async ({ test, testcase, environment: { ...testenv } }) =>
135+
async ({ test, testcase, testenv: { ...testenv } }) =>
140136
await concurrently(() =>
141137
/*
142138
* `concurrently(() => disconnected(...))`
@@ -665,9 +661,7 @@ export async function loadTests(
665661
const trialRegistry = await flushTrialRegistry(configuration);
666662

667663
return {
668-
testplanner: async (smokeConfig?: SmokeConfig, ...filter: string[]) => {
669-
const testenv = { ...environment };
670-
664+
async testplanner(testenv: Record<string, unknown>, smokeConfig?: SmokeConfig, ...filter: string[]) {
671665
const alltestcases = describeCases(
672666
configuration.closing || (() => {}),
673667
trialRegistry.flatMap(({ descriptions }) => {
@@ -693,13 +687,13 @@ export async function loadTests(
693687
environment: {
694688
testcase,
695689
"::testexecution": testexecution,
696-
...environment
690+
...testenv
697691
},
698692
}) =>
699693
({
700-
test: () => testexecution(environment),
694+
test: () => testexecution(testenv),
701695
testcase,
702-
environment,
696+
testenv,
703697
}) as TestSetup,
704698
);
705699

packages/favor/electron/pardon-worker.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ const currentHttpSequence = new AsyncLocalStorage<{
5858
values: Record<string, unknown>;
5959
}>();
6060

61-
type TestSetup = ReturnType<
61+
type TestSetup = Awaited<ReturnType<
6262
Awaited<ReturnType<typeof loadTests>>["testplanner"]
63-
>[number];
63+
>>["cases"][number];
6464

6565
export type TestStepPayloads = {
6666
"test:run:start": {
6767
id: "test:event";
6868
type: "test:run:start";
6969
run: TestRunId;
70-
tests: Pick<TestSetup, "testcase" | "environment">[];
70+
tests: Pick<TestSetup, "testcase" | "testenv">[];
7171
input: string;
7272
};
7373
"test:case:start": {
@@ -593,9 +593,8 @@ const handlers = {
593593
{ smoke, filter }: { smoke?: SmokeConfig; filter?: string[] },
594594
) {
595595
const { testing } = await ready;
596-
return (await testing)
597-
?.testplanner(environment, smoke, ...(filter || []))
598-
?.map(({ environment, testcase }) => ({ environment, testcase }));
596+
const testplan = await (await testing)?.testplanner(environment, smoke, ...(filter || []));
597+
return testplan.cases.map(({ testenv, testcase }) => ({ testenv, testcase }));
599598
},
600599
async executeTestcases(
601600
testenv: Record<string, unknown>,
@@ -607,18 +606,20 @@ const handlers = {
607606
) {
608607
const testRun: TestRunId = `T${nextTestRunId++}`;
609608
const { testing } = await ready;
610-
const tests = (await testing)?.testplanner(
609+
const testplan = await (await testing)?.testplanner(
611610
testenv,
612611
undefined,
613612
...testcases,
614613
);
615614

615+
const tests = (await testplan)?.cases;
616+
616617
parentPort!.postMessage(
617618
ship({
618619
id: "test:event",
619620
type: "test:run:start",
620621
run: testRun,
621-
tests: tests,
622+
tests,
622623
input,
623624
}) satisfies TestStepPayloads["test:run:start"],
624625
);

packages/favor/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/favor/src/components/InfoDrawer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function InfoDrawer(
2626
side?: Parameters<typeof Drawer>[0]["side"];
2727
"no-close-button"?: boolean;
2828
},
29-
) {
29+
): JSX.Element {
3030
const [ourProps, contentProps] = splitProps(props, [
3131
"side",
3232
"children",

packages/favor/src/components/TestcaseSystem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export default function TestcaseSystem(props: {
225225
class="flex max-h-[80%] flex-col bg-lime-300 dark:bg-lime-700"
226226
content={
227227
<div class="flex flex-initial flex-col overflow-auto">
228-
<KeyValueCopier data={item.environment} />
228+
<KeyValueCopier data={item.testenv} />
229229
</div>
230230
}
231231
>
@@ -380,7 +380,7 @@ function compileTestReport(events: TestEventType[]) {
380380
events: TestEventType[];
381381
sequences: TestSequenceRecord[];
382382
input: string;
383-
tests: { testcase: string; environment: Record<string, unknown> }[];
383+
tests: { testcase: string; testenv: Record<string, unknown> }[]; // Pick<TestSetup, "testcase" | "testenv">[]
384384
testcases: Record<
385385
string,
386386
{

0 commit comments

Comments
 (0)