diff --git a/scripts/verify-conformance-fixtures.mjs b/scripts/verify-conformance-fixtures.mjs index 856f662030..b18a1d7003 100644 --- a/scripts/verify-conformance-fixtures.mjs +++ b/scripts/verify-conformance-fixtures.mjs @@ -45,14 +45,13 @@ process.stdout.write( ); async function resolveSourceRoot(manifestPath, declaredSourceRoot) { + if (declaredSourceRoot !== undefined) + return realpath(resolve(process.cwd(), declaredSourceRoot)); const candidates = [ - declaredSourceRoot === undefined - ? null - : resolve(process.cwd(), declaredSourceRoot), resolve(process.cwd(), "tests/conformance"), resolve(dirname(dirname(dirname(manifestPath))), "tests/conformance"), resolve(dirname(manifestPath), "../../tests/conformance"), - ].filter((candidate) => candidate !== null); + ]; for (const candidate of candidates) { try { return await realpath(candidate); diff --git a/tests/conformance/package/conformanceFixtureVerifier.test.ts b/tests/conformance/package/conformanceFixtureVerifier.test.ts index dea444064a..05345ea70a 100644 --- a/tests/conformance/package/conformanceFixtureVerifier.test.ts +++ b/tests/conformance/package/conformanceFixtureVerifier.test.ts @@ -170,3 +170,22 @@ it("preserves a carriage return that belongs to an nm symbol name", () => { "rea_inventory_0000\r", ]); }); + +it("refuses a missing explicit source root even when a default exists", async () => { + const { commands, root } = await ownedFixture("rea-fixture-source-root-"); + await mkdir(join(root, "tests", "conformance"), { recursive: true }); + const manifest = join(root, "manifest.json"); + await writeFile(manifest, "{}"); + const selected = join(root, "selected-sources"); + await expect( + commands.exec(process.execPath, [verifier, manifest, selected], { + cwd: root, + timeout: 10_000, + }), + ).rejects.toMatchObject({ + code: 1, + snapshot: { + stderr: { text: expect.stringContaining(selected) }, + }, + }); +});