Skip to content

Commit

Permalink
better matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJang27 committed Dec 2, 2024
1 parent 161d433 commit 4ed00a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
28 changes: 25 additions & 3 deletions tests/driver/tool_driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,35 @@ lint:
stdout: string;
stderr: string;
exitCode: number;
details?: string;
}> => {
try {
const { stdout, stderr } = await this.runTrunk(["tools", "install", toolName, "--ci"]);
return { exitCode: 0, stdout, stderr };
return { exitCode: 0, stdout, stderr, details: undefined };
} catch (e: any) {
// trunk-ignore(eslint/@typescript-eslint/no-unsafe-member-access)
return { exitCode: e.code as number, stdout: e.stdout as string, stderr: e.stderr as string };
let details = undefined;
/* eslint-disable-next-line
@typescript-eslint/no-unsafe-call,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-assignment
*/
const detailsPath = e.stdout.match(/\.trunk\/out\/(.+\.yaml)/);
if (detailsPath) {
details = await fs.promises.readFile(
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access */
path.resolve(this.sandboxPath ?? "", detailsPath[0]),
"utf8",
);
}

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
return {
exitCode: e.code as number,
stdout: e.stdout as string,
stderr: e.stderr as string,
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
details,
};
}
};

Expand Down
3 changes: 2 additions & 1 deletion tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ export const toolInstallTest = ({
expect(installResult).toMatchObject({
exitCode: 0,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
stdout: expect.stringContaining(toolVersion),
stdout: expect.stringMatching(`${toolName}.+${toolVersion}(?!.*trunk)`),
stderr: "",
details: undefined,
});
expect(installResult.stdout).not.toContain("Failures:");
});
Expand Down

0 comments on commit 4ed00a0

Please sign in to comment.