-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix #5162 - Capture exit
from Ruby
#5166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmarrec OK great. We need this. The question is when to merge?
I think @wenyikuang should tag the RC based on the current head of the develop branch, but if the two of you think we can squeak this in for RC1, then I'm ok with that too. Ultimately your call @wnykuang
I think we might get some new failures from ctest as a result of this. (which is a feature not a bug of course) |
Hummmm I no longer have any minitest output. test_minitest.rb require 'minitest'
require 'minitest/autorun'
class MyTest < Minitest::Test
def test_fail
assert 0 == 1
end
end |
Eventually I need build the binary from scratch so its not a big difference. |
I'd say wait, I have some issues with it. Maybe it'll go in RC2. e52af4d kinda fixes it, but I don't like it one bit Minitest failures still end up exiting with an exitcode = 0 obviously... |
I tried to define it externally to the class definition but getting a linker error due to multiple definitions, so just constexpr-if it up.
… `OpenStudioCLI.execute_ruby_script`
… zero return code
// ruby_cleanup calls ruby_finalize | ||
int ex = ruby_cleanup(0); | ||
if (ex != 0) { | ||
fmt::print("RubyEngine return code was {}\n", ex); | ||
exit(ex); | ||
} | ||
//ruby_finalize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbenne here is the most important change.
Originally I had fixed it by using an at_exit block in executeRubyScriptCommand. THe Kernel.exit! was sufficient to propagate it to C++. But the issue was that this would be returning zero : openstudio -e "at_exit { exit 12 }"
. So I thought "Wouldn't it be more logical to install that at_exit in the RubyEngine itself?" and that's when I realized ruby has a ruby_cleanup which returns the final exit code, so we should use that
at_exit {{
exit_code = ($! and $!.kind_of? SystemExit) ? $!.status : 0
STDOUT.flush
STDERR.flush
if exit_code != 0
Kernel.exit!(exit_code)
end
}}
if (Python_EXECUTABLE) | ||
add_test(NAME OpenStudioCLI.minitest_fail | ||
COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test/run_minitest_fail.py" $<TARGET_FILE:openstudio> | ||
) | ||
if (SYSTEM_RUBY_EXECUTABLE) | ||
add_test(NAME RubyTest.minitest_fail | ||
COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test/run_minitest_fail.py" "${SYSTEM_RUBY_EXECUTABLE}" | ||
) | ||
endif() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new tests
CI Results for 3b70376:
|
// ruby_cleanup calls ruby_finalize | ||
int ex = ruby_cleanup(0); | ||
if (ex != 0) { | ||
fmt::print("RubyEngine return code was {}\n", ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmarrec Did you mean to leave this in or was it for debugging? Seems weird that this is now printed.
Pull request overview
Note: this does fix the Minitest return value, even with the
minitest/autorun
using at_exithttps://github.com/minitest/minitest/blob/ea9caafc0754b1d6236a490d59e624b53209734a/lib/minitest.rb#L66-L89
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.