diff --git a/packages/seed/src/cli.ts b/packages/seed/src/cli.ts index 0c288c2daf0..ae3b24c632d 100644 --- a/packages/seed/src/cli.ts +++ b/packages/seed/src/cli.ts @@ -73,7 +73,7 @@ function addTestCommand(cli: Argv) { const tests: Promise[] = []; for (const generator of generators) { - if (argv.workspace != null && !argv.generator?.includes(generator.workspaceName)) { + if (argv.generator != null && !argv.generator.includes(generator.workspaceName)) { continue; } const testRunner = new DockerTestRunner({ diff --git a/packages/seed/src/commands/rewrite-inputs/rewriteInputsForWorkspace.ts b/packages/seed/src/commands/rewrite-inputs/rewriteInputsForWorkspace.ts index e7e209a36f2..92268baac5b 100644 --- a/packages/seed/src/commands/rewrite-inputs/rewriteInputsForWorkspace.ts +++ b/packages/seed/src/commands/rewrite-inputs/rewriteInputsForWorkspace.ts @@ -31,7 +31,7 @@ export async function rewriteInputsForWorkspace({ for (const fixture of fixtures) { const fixtureConfig = generator.workspaceConfig.fixtures?.[fixture]; const docker = parseDockerOrThrow(generator.workspaceConfig.docker); - const absolutePathToFernDefinition = AbsoluteFilePath.of( + const absolutePathToAPIDefinition = AbsoluteFilePath.of( path.join(__dirname, FERN_DIRECTORY, APIS_DIRECTORY, fixture) ); const absolutePathToOutput = join(generator.absolutePathToWorkspace, RelativeFilePath.of(fixture)); @@ -41,7 +41,7 @@ export async function rewriteInputsForWorkspace({ `${generator.workspaceName}:${fixture} - ${fixtureConfigInstance.outputFolder}` ); const fernWorkspace = await convertGeneratorWorkspaceToFernWorkspace({ - absolutePathToWorkspace: absolutePathToFernDefinition, + absolutePathToAPIDefinition, taskContext, fixture }); @@ -71,7 +71,7 @@ export async function rewriteInputsForWorkspace({ } else { const taskContext = taskContextFactory.create(`${generator.workspaceName}:${fixture}`); const fernWorkspace = await convertGeneratorWorkspaceToFernWorkspace({ - absolutePathToWorkspace: absolutePathToFernDefinition, + absolutePathToAPIDefinition, taskContext, fixture }); diff --git a/packages/seed/src/commands/run/runWithCustomFixture.ts b/packages/seed/src/commands/run/runWithCustomFixture.ts index bff87878995..9253229c7de 100644 --- a/packages/seed/src/commands/run/runWithCustomFixture.ts +++ b/packages/seed/src/commands/run/runWithCustomFixture.ts @@ -37,7 +37,7 @@ export async function runWithCustomFixture({ }); const fernWorkspace = await convertGeneratorWorkspaceToFernWorkspace({ - absolutePathToWorkspace: pathToFixture, + absolutePathToAPIDefinition: pathToFixture, taskContext, fixture: "custom" }); diff --git a/packages/seed/src/commands/test/printTestCases.ts b/packages/seed/src/commands/test/printTestCases.ts index 4f2d03d4c35..4169fd9f4b6 100644 --- a/packages/seed/src/commands/test/printTestCases.ts +++ b/packages/seed/src/commands/test/printTestCases.ts @@ -8,7 +8,8 @@ export function printTestCases(result: TestRunner.TestResult[]): void { Result: r.type, "Generation Time": r.metrics.generationTime, "Compile Time": r.metrics.compileTime, - "Failure Type": r.type === "failure" ? r.cause : "" + "Failure Type": r.type === "failure" ? r.cause : "", + "Failure Message": r.type === "failure" ? r.message : "" }; }); printTable(items); diff --git a/packages/seed/src/commands/test/test-runner/TestRunner.ts b/packages/seed/src/commands/test/test-runner/TestRunner.ts index e6384756ce1..8e3c55eb669 100644 --- a/packages/seed/src/commands/test/test-runner/TestRunner.ts +++ b/packages/seed/src/commands/test/test-runner/TestRunner.ts @@ -72,6 +72,7 @@ export declare namespace TestRunner { } export abstract class TestRunner { + private built: boolean = false; protected readonly generator: GeneratorWorkspace; protected readonly lock: Semaphore; protected readonly taskContextFactory: TaskContextFactory; @@ -97,6 +98,11 @@ export abstract class TestRunner { * Runs the generator. */ public async run({ fixture, configuration }: TestRunner.RunArgs): Promise { + if (!this.built) { + await this.build(); + this.built = true; + } + const metrics: TestRunner.TestCaseMetrics = {}; const fixtureConfig = this.generator.workspaceConfig.fixtures?.[fixture]; @@ -110,13 +116,14 @@ export abstract class TestRunner { }; } - const absolutePathToWorkspace = AbsoluteFilePath.of( + const id = configuration != null ? `${fixture}:${configuration.outputFolder}` : `${fixture}`; + const absolutePathToAPIDefinition = AbsoluteFilePath.of( path.join(__dirname, FERN_DIRECTORY, APIS_DIRECTORY, fixture) ); - const taskContext = this.taskContextFactory.create(`${this.generator.workspaceName}:${fixture}`); + const taskContext = this.taskContextFactory.create(`${this.generator.workspaceName}:${id}`); const outputFolder = configuration?.outputFolder ?? fixture; const fernWorkspace = await convertGeneratorWorkspaceToFernWorkspace({ - absolutePathToWorkspace, + absolutePathToAPIDefinition, taskContext, fixture }); @@ -137,9 +144,9 @@ export abstract class TestRunner { const generationStopwatch = new Stopwatch(); generationStopwatch.start(); await this.runGenerator({ - id: configuration != null ? `${fixture}:${configuration.outputFolder}` : `${fixture}`, + id, fernWorkspace, - absolutePathToWorkspace, + absolutePathToWorkspace: this.generator.absolutePathToWorkspace, irVersion: this.generator.workspaceConfig.irVersion, outputVersion: configuration?.outputVersion, language: this.generator.workspaceConfig.language, diff --git a/packages/seed/src/utils/convertSeedWorkspaceToFernWorkspace.ts b/packages/seed/src/utils/convertSeedWorkspaceToFernWorkspace.ts index dce47ac7bc0..4ac1bb10c42 100644 --- a/packages/seed/src/utils/convertSeedWorkspaceToFernWorkspace.ts +++ b/packages/seed/src/utils/convertSeedWorkspaceToFernWorkspace.ts @@ -4,15 +4,15 @@ import { convertOpenApiWorkspaceToFernWorkspace, FernWorkspace, loadAPIWorkspace export async function convertGeneratorWorkspaceToFernWorkspace({ fixture, - absolutePathToWorkspace, + absolutePathToAPIDefinition, taskContext }: { fixture: string; - absolutePathToWorkspace: AbsoluteFilePath; + absolutePathToAPIDefinition: AbsoluteFilePath; taskContext: TaskContext; }): Promise { const workspace = await loadAPIWorkspace({ - absolutePathToWorkspace, + absolutePathToWorkspace: absolutePathToAPIDefinition, context: taskContext, cliVersion: "DUMMY", workspaceName: fixture diff --git a/seed/openapi/imdb/custom-overrides/.inputs/config.json b/seed/openapi/imdb/custom-overrides/.inputs/config.json index bda5b7cf80d..eb45a4a77b3 100644 --- a/seed/openapi/imdb/custom-overrides/.inputs/config.json +++ b/seed/openapi/imdb/custom-overrides/.inputs/config.json @@ -13,7 +13,7 @@ } } }, - "workspaceName": "api", + "workspaceName": "imdb", "organization": "seed", "environment": { "type": "local" diff --git a/seed/openapi/imdb/json-format/.inputs/config.json b/seed/openapi/imdb/json-format/.inputs/config.json index 4ee6412abd1..3663a993b49 100644 --- a/seed/openapi/imdb/json-format/.inputs/config.json +++ b/seed/openapi/imdb/json-format/.inputs/config.json @@ -9,7 +9,7 @@ "customConfig": { "format": "json" }, - "workspaceName": "api", + "workspaceName": "imdb", "organization": "seed", "environment": { "type": "local" diff --git a/seed/openapi/imdb/no-custom-config/.inputs/config.json b/seed/openapi/imdb/no-custom-config/.inputs/config.json index b17a96d8a8c..5182727f96a 100644 --- a/seed/openapi/imdb/no-custom-config/.inputs/config.json +++ b/seed/openapi/imdb/no-custom-config/.inputs/config.json @@ -7,7 +7,7 @@ "path": "../" }, "customConfig": null, - "workspaceName": "api", + "workspaceName": "imdb", "organization": "seed", "environment": { "type": "local"