Skip to content

Hook errors to pFUnit exception system#2233

Open
timofeymukha wants to merge 17 commits intoExtremeFLOW:developfrom
timofeymukha:tests/execptions
Open

Hook errors to pFUnit exception system#2233
timofeymukha wants to merge 17 commits intoExtremeFLOW:developfrom
timofeymukha:tests/execptions

Conversation

@timofeymukha
Copy link
Collaborator

Adds errors.f90, which for now just contains a copy of our errors from utils.f90, but they are hooked up to the system pfunit uses
for exceptions.

Basically, there is subroutine pointer, that by default points:

  • For errors to a routine that calls error stop
  • For warnings to a routine that does nothing.

For unit tests, there is a module error_redirection.f90 added, which switches the pointers to a routine that registers a pfunit exception. This way one can do tests like

  subroutine test_neko_error_raises()
    call neko_error("boom")
    @assertExceptionRaised()
  end subroutine test_neko_error_raises

to make sure we are raising an error. In reality, it is some object that is tested that calls neko_error of course.

A separate question is whether to actually move errors and warnings out to their own module, or to add stuff to utils.f90. I feel like if we add more error later, it would be nice with a separate module.

The

error_redirection.F90: ../error_redirection/error_redirection.F90
	cp $< $@

seems to be the only way to get thigns to comple.

Bonus: added a CHANGELOG.md

@timofeymukha timofeymukha added enhancement New feature or request don't merge Don't merge yet! labels Dec 15, 2025
@timfelle
Copy link
Collaborator

Could one not add an error function overload similar to error plain and error message? That way we do not need to introduce a new file system?

@timofeymukha timofeymukha removed the don't merge Don't merge yet! label Dec 17, 2025
@timofeymukha
Copy link
Collaborator Author

Not sure what happened to the ARM runs... I am trying to move the default throw routines to utils.f90, maybe default initialization to a submodule routine is flaky...

@njansson
Copy link
Collaborator

Not sure what happened to the ARM runs... I am trying to move the default throw routines to utils.f90, maybe default initialization to a submodule routine is flaky...

It seems like it stops when error boom is thrown.

FAIL: errors/errors_test
========================

ERROR STOP 

Error termination. Backtrace:
#0  0xffebb964d44b in ???
#1  0xffebb964e277 in ???
#2  0xffebb964fa17 in ???
#3  0xaac59507e437 in __utils_MOD_default_throw_error
	at common/utils.f90:131
#4  0xaac59507c373 in ???
#5  0xaac59508b887 in __pf_testmethod_MOD_runmethod
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestMethod.F90:89
#6  0xaac5950b8b0b in __pf_testcase_MOD_runbare
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestCase.F90:136
#7  0xaac5950b8abb in __pf_testcase_MOD_runbare_surrogate
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestCase.F90:146
#8  0xaac5950d4423 in __pf_testresult_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestResult.F90:237
#9  0xaac5950b8c67 in inner_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestCase.F90:121
#10  0xaac5950b8d17 in __pf_testcase_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestCase.F90:108
#11  0xaac59508e3b3 in __pf_testsuite_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestSuite.F90:109
#12  0xaac59508e3b3 in __pf_testsuite_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestSuite.F90:109
#13  0xaac5950d6e6f in __pf_testrunner_MOD_runwithresult
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestRunner.F90:139
#14  0xaac5950dad03 in __pf_testrunner_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/core/TestRunner.F90:117
#15  0xaac595098feb in __funit_MOD_generic_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/FUnit.F90:123
#16  0xaac59509f1f3 in __funit_MOD_run
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/FUnit.F90:33
#17  0xaac59509f25b in funit_main_
	at /home/runner/work/neko/tmp/pfunit-v4.15.0-Ubuntu-24.04.3-LTS-ARM64-gfortran-14/src/funit/funit_main.F90:16
#18  0xaac59507bfb7 in ???
#19  0xaac59507bff7 in ???
#20  0xffebb94584c3 in ???
#21  0xffebb9458597 in ???
#22  0xaac59507ba6f in ???
#23  0xffffffffffffffff in ???
 *** ERROR: boom ***
.FAIL errors/errors_test (exit status: 1)

@timofeymukha
Copy link
Collaborator Author

OK, it seems this just doesn't work properly on ARM, I have no idea why at this point. I have even added an explicit call to redirect in a @before routine, which should not even be needed.

@timofeymukha timofeymukha added the don't merge Don't merge yet! label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

don't merge Don't merge yet! enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants