-
Notifications
You must be signed in to change notification settings - Fork 195
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
Error messages not captured with exit codes #5052
Comments
From @jmarrec: It’s a corner case... We’ve had to put some fail-safe / error handling in the CLI in a bunch of places to avoid issues (...), and we haven’t though of this one |
Ok, so I initially thought the only difference was that the C++ CLI will report this error to The $ openstudio run_analysis.rb --fail 2> /dev/null
Error: Threw a fail statement.
Backtrace:
/home/julien/Software/Others/OpenStudio/src/cli/test/run_analysis.rb:30:in `<top (required)>'
eval:139:in `require'
eval:139:in `require'
:/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
eval:5:in `<main>' The issue is that the scripting language does not see that STDOUT bit. In ruby: [1] test(main)> @command = "openstudio run_analysis.rb -f"
[2] test(main)> system(@command)
Error: Threw a fail statement.
Backtrace:
/home/julien/Software/Others/OpenStudio/src/cli/test/run_analysis.rb:30:in `<top (required)>'
eval:139:in `require'
eval:139:in `require'
:/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
eval:5:in `<main>'
Failed to execute '/home/julien/Software/Others/OpenStudio/src/cli/test/run_analysis.rb'
[3] test(main)> o, e, s = Open3.capture3("openstudio run_analysis.rb -f")
=> ["", "Failed to execute '/home/julien/Software/Others/OpenStudio/src/cli/test/run_analysis.rb'\n", #<Process::Status: pid 33552 exit 1>] The bit that prints the backtrace is here: OpenStudio/src/cli/UpdateCommand.cpp Lines 58 to 90 in 5de13e3
It's possible this is a flushing issue. |
ok, so I can fix it by explicitly flushing I'd advocate that this should NOT have been reported to That'd mean if you explictly wanted to test the failure messages, you'd have to make a spec helper like this
Or this (untested on windows):
|
Hum, closely related is the fact that if you run a file that has minitests in it via the CLI, the return code is 0 even if the tests fail... the (test) $ ruby test_fail_stdout.rb -n test_ruby_fail_backticks
Run options: -n test_ruby_fail_backticks --seed 10755
# Running:
Failed to execute '/Users/julien/Software/Others/OpenStudio/src/cli/test/./execute_ruby_script_fail.rb'
F
Finished in 0.412776s, 2.4226 runs/s, 4.8452 assertions/s.
1) Failure:
FailTest#test_ruby_fail_backticks [test_fail_stdout.rb:24]:
Expected "" to include "Error: Threw a fail statement.".
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
(test) $ echo $?
1
----
(test) $ openstudio test_fail_stdout.rb -n test_ruby_fail_backticks
Run options: -n test_ruby_fail_backticks --seed 31024
# Running:
Failed to execute '/Users/julien/Software/Others/OpenStudio/src/cli/test/execute_ruby_script_fail.rb'
F
Finished in 0.896169s, 1.1159 runs/s, 2.2317 assertions/s.
1) Failure:
FailTest#test_ruby_fail_backticks [/Users/julien/Software/Others/OpenStudio/src/cli/test/test_fail_stdout.rb:24]:
Expected "" to include "Error: Threw a fail statement.".
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
(test) $ echo $?
0 |
@kbenne I'm bumping into this #5052 (comment) again. Basically @wenyikuang reported some failures to run OpenStudio/src/cli/test/test_bundle.rb Lines 16 to 28 in 969f480
have been failing for a while, it's just that CMake doesn't see the issue.
|
Issue overview
For a ruby script called by the CLI,
fail "xxx"
has different behavior between 3.6.1 and 3.7.0.Current Behavior
You can output capture (e.g., using "`" characters) the fail statement.
Expected Behavior
The fail statement output is no longer captured.
Steps to Reproduce
run_analysis.rb.txt
test_fail.rb.txt
Possible Solution
Details
Environment
Some additional details about your environment for this issue (if relevant):
Context
This breaks some of our tests for ResStock.
The text was updated successfully, but these errors were encountered: