Skip to content

[root.exe] Use non-zero exit status when invalid arguments are passed #19196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025

Conversation

hageboeck
Copy link
Member

@hageboeck hageboeck commented Jun 26, 2025

Followup to #19195:
RDF IMT tutorials didn't run since 10 months, since the following passed with a 0 exit status:

$ root '-e "ROOT::EnableImplicitMT(4)"' ...
root: unrecognized option '-e "ROOT::EnableImplicitMT(4)"'
Try 'root --help' for more information.
  2965/2993 Test tutorial-analysis-dataframe-df102_NanoAODDimuonAnalysis ............. Passed 0.15 sec

To avoid similar problem in the future, I suggest here to exit with a non-zero exit status. I chose 2 because 1 usually means that the script/macro/command that was running in the interpreter failed:

bin/root -b -q -e "invalid"; echo $?
1

Whereas a failure to parse the argument would now be:

$ root '-e "ROOT::EnableImplicitMT(4)"'; echo $?
2

Copy link
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

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

LGTM.

Side note: The RUFF does not seem to handle well deleted files, see:
https://github.com/root-project/root/actions/runs/15901873603/job/44846574695?pr=19196
which says:

Run files=$(cat changed_files.txt | grep '\.py$' || echo "")
Error: tutorials/.enableImplicitMTWrapper.py:1:1: E902 No such file or directory (os error 2)
Error: Process completed with exit code 123.

Copy link

github-actions bot commented Jun 27, 2025

Test Results

    20 files      20 suites   3d 11h 41m 11s ⏱️
 3 117 tests  3 115 ✅ 0 💤 2 ❌
60 745 runs  60 741 ✅ 2 💤 2 ❌

For more details on these failures, see this check.

Results for commit a07f891.

♻️ This comment has been updated with latest results.

@hageboeck
Copy link
Member Author

LGTM.

Side note: The RUFF does not seem to handle well deleted files, see: https://github.com/root-project/root/actions/runs/15901873603/job/44846574695?pr=19196 which says:

Run files=$(cat changed_files.txt | grep '\.py$' || echo "")
Error: tutorials/.enableImplicitMTWrapper.py:1:1: E902 No such file or directory (os error 2)
Error: Process completed with exit code 123.

@pcanal I had noticed the same, but this problem was fixed in the mean time here: #19197

This invocation
  root.exe "-e EnableImplicitMT(4)" (single argument instead of two)
broke the IMT tutorials, but went undetected.

Here, we set the exit status to 2 if root.exe's arguments could not be
parsed correctly. (When the interpreter command fails, the exit status is
set to 1, so these two cases can be told apart.)

Since the executable now exits with a non-zero status, the test had to
be pulled out of gtest, and is now split into one that tests the exit
status and one that checks the error message.
@hageboeck hageboeck merged commit 527756b into root-project:master Jul 2, 2025
22 of 25 checks passed
@hageboeck hageboeck deleted the root_exitStatus branch July 2, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants