-
-
Notifications
You must be signed in to change notification settings - Fork 111
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(core,developer): use NDEBUG
flag to disable assertions in release build
#12715
fix(core,developer): use NDEBUG
flag to disable assertions in release build
#12715
Conversation
…or VC++ This disables assertions in release builds in Windows only. Other platforms may have different outcomes. Fixes: #12619
User Test ResultsTest specification and instructions User tests are not required Test Artifacts |
{$IFDEF DEBUG} | ||
configuration := 'debug'; | ||
{$ELSE} | ||
configuration := 'release'; | ||
{$ENDIF} | ||
Exit(keyman_root + 'core\build\x86\'+configuration+'\src\' + Filename); |
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.
Allows us to test both release and debug builds of Core in the Debugger when running within the keymanapp/keyman repo
Hmm, unit tests have very unexpectedly failed for Test: Keyman Core - Windows (Common) with this minimal change. More digging needed, tomorrow. |
Ah, you made the change in |
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.
LGTM
I constrained the check to msvc though |
Ah, right. For Linux at least it's the same, so I think we should move it outside of the msvc section. |
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.
LGTM
… on all platforms
Had a real yak shave this morning with disabling assertions in release builds in our C/C++ code. It turns out that our unit tests use `assert()` which we intended to use from `test_assert.h`, but in some cases `cassert` or `assert.h` had been #included after `test_assert.h`, overriding our special `assert()` macro. The chain of includes is somewhat hard to puzzle out -- it's often buried several levels deep. This meant that a release build would drop all test assertions, meaning most tests passed, unsurprisingly, as there were no assertions left to fail ... but some tests failed with crashes because we optimized out important lines such as `assert(some_important_function())`. I was quite unhappy with this fragility, so I have opted to rename `assert()` to `test_assert()` in all of our home-grown C/C++ unit tests, which further highlighted unit tests which were only using the C/C++ `assert()` and not ours, so then had to figure out which unit test executables needed to have `test_assert` added, and then ... then ... discovered a bug in `test_color.h`, where we were #including `io.h`/`unistd.h` inside a `namespace console_color {}` block, which just happened to be the first ref to those beautiful headers, and thus (because `#pragma once`) meant that useful little functions like `access()` were no longer accessible to us in the global namespace. I have also audited Every Single Call to `assert()` to verify that we do not do Important Work inside the parentheses, and, apart from those offending unit tests, now resolved with `test_assert()`, it looks like all is good. I would like to present one very well-shaved yak in this commit. Fixes: #12619
…ions-vcwin-release-build
@@ -7,7 +7,7 @@ | |||
# | |||
|
|||
# Note: this version of cmpfiles ignores line endings, which is better for platform independence | |||
cmpfiles = ['-c', 'import sys; a = open(sys.argv[1], \'r\').read(); b = open(sys.argv[2], \'r\').read(); exit(not (a==b))'] | |||
cmpfiles = ['-c', 'import sys; a = open(sys.argv[1], \'r\').read(); b = open(sys.argv[2], \'r\').read(); sys.exit(not (a==b))'] |
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.
Unrelated ... but maybe due to my python version? In any case sys.exit
is probably safer
NDEBUG
flag to disable assertions in release build for VC++NDEBUG
flag to disable assertions in release build
big changes due to assert() in unit tests
The yak shave isn't over:
Presumably |
..changing of assert_failed to test_assert_failed looks good in all files;
|
Is the discussion on d71cb56 the kind we want to summarize into Particularly the fragility of assert() and tests |
We could add something to our test wiki; it's not really internal Keyman-relevant documentation, more a trap-for-young-players-in-c++ (i.e. how to use tools properly) |
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.
questions about ldml_*.cpp
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.
lgtm
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.
lgtm
re-review
…ions-vcwin-release-build
Changes in this pull request will be available for download in Keyman version 18.0.150-alpha |
This disables assertions in release builds for all meson-built projects.
See d71cb56 for deeper discussion on the yak shave that impacted all the unit tests.
Fixes: #12619
Fixes: #12453 (by implication)
@keymanapp-test-bot skip