revive icon indicating copy to clipboard operation
revive copied to clipboard

Add support of relative line numbers to `//MATCH`

Open vbvictor opened this issue 5 months ago • 3 comments

Is your feature request related to a problem? Please describe.

When writing test-cases where with more than one // MATCH per line, developer need to use absolute line numbers like this: // MATCH:30, // MATCH:31. This makes test code harder to modify and support because every change to code above MATCH: needs recalculation of absolute line-numbers.

Describe the solution you'd like

Add support of new MATCH syntax with relative line numbers: MATCH:[-1], MATCH:[+1]. With this syntax, test will look for a message on the previous or the following line of "match" message. More verbose alternative could be MATCH:[@LINE - 1], MATCH:[@LINE + 1].

Additional context

Other test-framework for linters use it, e.g like this.

vbvictor avatar Jul 19 '25 10:07 vbvictor

It's great, because I had the exact same idea when I saw your PR.

I'm unsure about the format, but I'm convinced about the feature

ccoVeille avatar Jul 19 '25 10:07 ccoVeille

I'm unsure about the format, but I'm convinced about the feature

I lean towards verbose format. Little formal description of how I see parsing: When we have [] after MATCH: it means "evaluation" context inside []. In "evaluation" @line or @LINE will be current line of the MATCH (possible more macros with @ in the future). Inside [] we can add (+) or subtract (-) a number of lines (possible more operations in the future).

vbvictor avatar Jul 19 '25 12:07 vbvictor

For records, I worked on the file that handles the test suites you want to improve

It's for something different, but you could be interested.

  • #1431

ccoVeille avatar Jul 20 '25 21:07 ccoVeille