You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReFrame should not try loading files that do not have a registered test #3672
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.
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?
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.
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:
simple_test docstring: "Class decorator for registering tests with ReFrame". It describes the decorated class only.
Tutorial, first test: @simple_test "registers a test class with the framework and makes it available for running".
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:
Treating any file with a read of rfm.simple_test as a test file.
Issuing a warning if a non-reframe-file is passed with -c but not with -c -R
Documenting properly what ReFrame treats like a test file and how helper files can be used to actually register tests.
Activity
gppezzi commentedon Dec 3, 2026
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?
vkarak commentedon Dec 3, 2026
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.
vkarak commentedon Dec 3, 2026
Thinking more on this, a possible solution would be for the check file validator to treat any read of the
simple_testdecorator in a file as a sign of possible reframe test file. This would require you though to add inalps.pya stray statement: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
reframewas an implementation detail. The docs describe registration as applying@simple_testto a class, and the one example of registering by hand callsrfm.simple_testin the file being loaded. The module argument ofmake_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 inalps.py.So, in summary, I'm going to further fine tune this fix for 4.11.1 by:
rfm.simple_testas a test file.-cbut not with-c -R@gppezzi Would that be ok for your workflows?