Skip to content

Invalid line number in runner generator in very specific case #288

@trond-snekvik

Description

@trond-snekvik

If I create two test functions where the name of the second is a subset of the first, the second will get reported with the same line as the first in the test runner. To reproduce, make a test with these two test functions:

void test_my_function_invalid_behavior(void)
{}

void test_my_function(void)
{}

Creates output

test_file.c:test_my_function_invalid_behavior:11:PASS
test_file.c:test_my_function:11:PASS

Note that the second must be a subset of the first, and there can't be any other test-functions between them.

The issue comes from this line:

next unless line =~ /#{tests_and_line_numbers[i][:test]}/

This regex either needs an added white space and opening parenthesis here, to ensure that we're matching to the end of the function, or the source index iteration should be source_index += index + 1 on line 123, to avoid matching on the same function twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions