Skip to content

ReFrame should not try loading files that do not have a registered test #3672

In review

Description

@vkarak

ReFrame will load a Python file as a test if it has a "reframe" import or the @simple_test decorator:

return self._has_import or self._has_regression_test

I think this is wrong, because in a recursive load with -R, the loader may pick up utility or library files that are meant to be imported by others tests and not directly, causing weird warnings. ReFrame should only load files that actually want to register tests.

Activity

  1. added theissue type on May 22, 2026
  2. added this to the ReFrame 4.11.1 milestone on Nov 25, 2026
  3. self-assigned this
    on Nov 25, 2026
  4. moved this from Todo to In Progress in ReFrame Backlogon Nov 25, 2026
  5. moved this from In Progress to Merge To Develop in ReFrame Backlogon Nov 30, 2026
  6. gppezzi commented on Dec 3, 2026

    @gppezzi
    Contributor

    The #3756 validator has a false-negative class that will ship silently in 4.11.1: files that DO register tests, but dynamically through a factory, are rejected.

    Example: cscs-reframe-tests' alps.py (65 checks) instantiates Check(...) objects whose classes are registered by utils.py via rfm.simple_test(), but since the file itself contains no simple_test usage, it is rejected as "not a test file" and silently dropped (reason logged at debug level only; -l reports 0 checks; exit status 0).

    Reproducer: reframe -c alps.py -l → "Found 0 check(s)" on any tree including e5db0af, vs 65 checks on develop (pre-#3756).

    Since the whole cscs-reframe-tests integration suite uses this dynamic pattern, recursive loads (e.g. -c checks/ -R) lose their checks with no diagnostic.

    Could you consider
    (a) logging validation rejections at warning level so silent loss is visible, and
    (b) an escape hatch (config option or CLI flag) to load files without source validation while suites migrate?

  7. moved this from Merge To Develop to In Progress in ReFrame Backlogon Dec 3, 2026
  8. vkarak commented on Dec 3, 2026

    @vkarak
    ContributorAuthor

    Good catch. In the past it likely worked because of the deliberate import here:

    https://github.com/eth-cscs/cscs-reframe-tests/blob/65fce256642415b09dbb93cb6cabc3747d435fcb/checks/system/integration/alps.py#L842

    Honestly, I don't know what would be the best solution for this in order to remain in 4.11.1 as it will require additional functionality. We should likely revert the change and schedule it for 5.0.

  9. vkarak commented on Dec 3, 2026

    @vkarak
    ContributorAuthor

    Thinking more on this, a possible solution would be for the check file validator to treat any read of the simple_test decorator in a file as a sign of possible reframe test file. This would require you though to add in alps.py a stray statement:

    rfm.simple_test

    which I find better from the stray import because (a) the import would not be stray any more and (b) this will tell ReFrame explicitly "look this is a test file."

    Now for the suggestions: I agree with (a) but only for non-recursive loads, because otherwise it defies what this bug tries to fix and would issue false warnings. For (b) I don't think we need an extra option or configuration, but rather properly document how test files are identified, which brings us to the question of whether this is acceptable for 4.11.1 or is it breaking documented behaviour.

    And I believe it is not breaking documented behaviour, because how tests are loaded is a bit of a grey area right now. Here are the mentions:

    The documentation never states precisely which files ReFrame treats as test files. It only says the loader checks whether a file "looks like a ReFrame test." Accepting any file that imports reframe was an implementation detail. The docs describe registration as applying @simple_test to a class, and the one example of registering by hand calls rfm.simple_test in the file being loaded. The module argument of make_test() exists so ReFrame's test generator options can place generated tests in the right module. It was not originally meant as a way for helper code to register tests for another file and, if it were, the tutorial example would have caught the need of the stray import used as a workaround in alps.py.

    So, in summary, I'm going to further fine tune this fix for 4.11.1 by:

    1. Treating any file with a read of rfm.simple_test as a test file.
    2. Issuing a warning if a non-reframe-file is passed with -c but not with -c -R
    3. Documenting properly what ReFrame treats like a test file and how helper files can be used to actually register tests.

    @gppezzi Would that be ok for your workflows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions