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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

@@ -8,34 +8,6 @@
using testing::internal::CaptureStderr;
using testing::internal::GetCapturedStderr;

TEST(TRint, ExitOnUnknownArgs)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test removed?

Copy link
Member Author

@hageboeck hageboeck Jun 26, 2025

Choose a reason for hiding this comment

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

Because I cannot make it pass. Now that TApplication exits with status 2, the end of this test cannot be reached. It will always fail.

It is replaced by

 add_test(NAME root_exitStatus COMMAND $<TARGET_FILE:root.exe> "-e invalid")
 set_property(TEST root_exitStatus PROPERTY WILL_FAIL TRUE)

which admittedly doesn't test the error message, but it does test that root exits with != 0

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 12h 53m 49s ⏱️
 3 067 tests  3 067 ✅ 0 💤 0 ❌
59 740 runs  59 740 ✅ 0 💤 0 ❌

Results for commit 4720fd7.

♻️ 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.

Also add test for non-zero exit when invalid arguments are passed.
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.

3 participants