Skip to content

Fix #335: Return proper exit code in hoc execution#1633

Merged
alexsavulescu merged 6 commits into
masterfrom
weji/hoc_exitcode
Apr 6, 2022
Merged

Fix #335: Return proper exit code in hoc execution#1633
alexsavulescu merged 6 commits into
masterfrom
weji/hoc_exitcode

Conversation

@WeinaJi

@WeinaJi WeinaJi commented Feb 15, 2022

Copy link
Copy Markdown
Collaborator

Changes covered in this PR:

  • Return proper exit code in hoc_main1 and hoc_run1
  • Enable hoc_quit to exit with a use-specified status code

@WeinaJi

WeinaJi commented Mar 4, 2022

Copy link
Copy Markdown
Collaborator Author

please retest

@WeinaJi WeinaJi force-pushed the weji/hoc_exitcode branch from bcccd73 to 171b031 Compare March 4, 2022 09:27
@WeinaJi WeinaJi force-pushed the weji/hoc_exitcode branch from 39a1a55 to 1c4ef1f Compare March 25, 2022 17:55
@codecov-commenter

codecov-commenter commented Mar 25, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1633 (2f1bca5) into master (a343dfa) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1633      +/-   ##
==========================================
+ Coverage   45.43%   45.46%   +0.02%     
==========================================
  Files         551      551              
  Lines      113144   113149       +5     
==========================================
+ Hits        51403    51438      +35     
+ Misses      61741    61711      -30     
Impacted Files Coverage Δ
src/ivoc/ivocmain.cpp 74.85% <100.00%> (ø)
src/oc/hoc.cpp 67.33% <100.00%> (+2.23%) ⬆️
test/unit_tests/unit_test.cpp 100.00% <100.00%> (ø)
src/oc/hoc_oop.cpp 67.28% <0.00%> (+0.79%) ⬆️
src/oc/hoc_init.cpp 91.86% <0.00%> (+5.81%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@alexsavulescu alexsavulescu added this to the Release v8.2 milestone Mar 28, 2022
@WeinaJi

WeinaJi commented Apr 4, 2022

Copy link
Copy Markdown
Collaborator Author

This PR is ready for review.
BTW, I didn't manage to add the unit-test to check the status code after calling quit(exitcode) in c++ or python. The exit execution of quit() had failed ctest.

@nrnhines nrnhines left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Nice improvment. This seems basically sound to me and

$ nrniv temp.hoc
NEURON -- VERSION 8.2.dev-12-gfa5ca235 weji/hoc_exitcode (fa5ca235) 2022-03-28
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2021
See http://neuron.yale.edu/neuron/credits

nrniv: division by zero
 in temp.hoc near line 1
 1/0
    ^
hines@hines-T7500:~/neuron/temp/build$ echo $?
1

where

$ cat temp.hoc
1/0

It might be possible in the future to extend that behavior to

$ nrniv -c '1/0'
NEURON -- VERSION 8.2.dev-12-gfa5ca235 weji/hoc_exitcode (fa5ca235) 2022-03-28
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2021
See http://neuron.yale.edu/neuron/credits

nrniv: division by zero
 near line 1
 1/0
    ^
nrniv: arg not valid statement: 1/0
 near line 0
 ^
hines@hines-T7500:~/neuron/temp/build$ echo $?
0

@WeinaJi WeinaJi marked this pull request as ready for review April 5, 2022 08:05
@alexsavulescu

Copy link
Copy Markdown
Member

BTW, I didn't manage to add the unit-test to check the status code after calling quit(exitcode) in c++ or python. The exit execution of quit() had failed ctest.

Maybe this could work:

set_tests_properties(<quithoc_testname> PROPERTIES WILL_FAIL TRUE)

@WeinaJi WeinaJi force-pushed the weji/hoc_exitcode branch from 2f1bca5 to 41553e5 Compare April 5, 2022 10:41
@alexsavulescu

Copy link
Copy Markdown
Member

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Neuron doesn't return exit code to command line when there is an error

4 participants