From 22762c1243a703628e5676a5d530315fa7632bb8 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 28 Jan 2026 23:02:37 +0000 Subject: [PATCH] test(linter/plugins): conformance tester allow skipping tests which did not run with `RuleTester` (#18677) In conformance tester, process errors for when a test case was not run with the correct `RuleTester` in the same way as other errors. This allows skipping them if this behavior is expected (e.g. unit tests which don't use `RuleTester`). --- apps/oxlint/conformance/src/capture.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/oxlint/conformance/src/capture.ts b/apps/oxlint/conformance/src/capture.ts index 09a93845e6945..3c1b84692ca93 100644 --- a/apps/oxlint/conformance/src/capture.ts +++ b/apps/oxlint/conformance/src/capture.ts @@ -113,18 +113,20 @@ export function it(code: string, fn: () => void): void { testResult.isPassed = true; } catch (err) { - testResult.testCase = currentTest; + if (currentTest === null) { + // oxlint-disable-next-line no-ex-assign + err = new Error("Test case was not run with `RuleTester`"); + currentTest = { code }; + } else if (!(err instanceof Error)) { + // oxlint-disable-next-line no-ex-assign + err = new Error("Unknown error"); + } - if (!(err instanceof Error)) { - testResult.error = new Error("Unknown error"); - } else if (currentTest === null) { - testResult.error = new Error("Test case was not run with `RuleTester`"); - } else { - testResult.error = err; + testResult.testCase = currentTest; + testResult.error = err; - const ruleName = describeStack[0]; - if (shouldSkipTest(ruleName, currentTest, code, err)) testResult.isSkipped = true; - } + const ruleName = describeStack[0]; + if (shouldSkipTest(ruleName, currentTest, code, err)) testResult.isSkipped = true; } finally { // Reset current test currentTest = null;