Skip to content

modified-only may triggers twice some tests #4835

@LecrisUT

Description

@LecrisUT

This is extracted from #4813 (comment)

The code path in question is

directories = [Path(name).parent for name in output.stdout.split('\n')]
modified = {
f"^/{re.escape(str(directory))}" for directory in directories if directory
}
if not modified:
# Nothing was modified, do not select anything
return []
self.debug(f"Limit to modified test dirs: {modified}", level=3)
self.data.test.extend(TestsWithAdjusts(name=name) for name in modified)

If we consider a plan structure like

$ tmt plans ls
/foo/py313
/foo/py314
$ tree .
.
└── foo
    ├── main.fmf
    ├── py313.fmf
    └── py314
        └── main.fmf

And we add 2 files so that the structure is now

$ tree .
.
└── foo
    ├── file.txt
    ├── main.fmf
    ├── py313.fmf
    └── py314
        ├── file.txt
        └── main.fmf

The directories above resolves to foo and foo/py314. This creates a problem when these are then used to resolve tree.tests(name) because it would run the tests for

        summary: 3 tests selected
            /foo/py313
            /foo/py314
            /foo/py314

(/foo/py314 appearing twice)


The best solution I have for this is to only pass it the change closest to the fmf root (only foo in this case). This needs some additional changes since we are currently implicitly only handling the fmf root is the same as the git root, but for this we need to relax this hidden assumption or better account for it

$ git log --format= --stat --name-only HEAD^..HEAD
fmf_tree/foo/file.txt
fmf_tree/foo/py314/file.txt

(the fmf_tree there is unexpected, we want it to have resolved to foo/file.txt and foo/py314/file.txt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    backlog

    Status

    triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions