-
Notifications
You must be signed in to change notification settings - Fork 743
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
Change release builds to be optimized #4350
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.
You are on a roll.
Did you check how it affects end user debugging?
I had to change to draft as there seems to be some tests checking that optimizations are off.
As discussed in original issue, I would assume debugging experience is the same for NUnit developers when developing in debug mode (IDE setting). I don't see a normal use case of consumers of the NUnit library for debugging say, why Assert behaves they way it does that often. I myself am accustomed to stepping into 3rd party code and if optimized, it's "normal" for debugger stepping behaving a bit wonky. IDEs usually download the symbols etc and use source link to get the code in question. |
@lahma Any idea why the build failed? |
@manfred-brands I believe the reason was just this assert here https://github.com/nunit/nunit/blob/master/src/NUnitFramework/tests/TestDataAssemblyTests.cs . So I changed test data projects not be to be optimized even if Release build set (like in CI). |
So test projects can also be set to Optimize=true (the default now). Had to fix two things:
|
@@ -20,8 +20,10 @@ public DefaultConstraintTests() | |||
[Test] public void Success_Int() => AssertSuccess(default(int)); | |||
[Test] public void Success_NullableInt() => AssertSuccess(default(int?)); | |||
[Test] public void Success_Long() => AssertSuccess(default(long)); | |||
#if !NETFRAMEWORK // the error message is different between class framework and newer .NET runtimes with optimized builds |
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.
Curious. Do you recall how it's different? I could see stack traces changes, but I'm not sure what else could.
I'm a little concerned that this loses some test coverage on netfx runs. Is there a way we could keep the coverage of the the DefaultStructWithOverriddenEquals
scenario here on all builds?
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.
Oops, I see now that you explained the difference. I'll have to take a closer look here. I'm still curious if we can avoid losing the netfx coverage here
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.
I was a bit surprised about this too but I would believe this is quite the corner case, I don't think it will much difference when deciphering a failed Assert in test log. As said, I would believe they were already getting the same message if they were using optimized code against the assert.
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.
I've pulled your branch and this test seems to pass for me locally on all platforms, including net462 if I remove the conditional compilation. Does it matter if the ToString()
differs?
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.
@stevenaw here's the error if the assert is removed: https://github.com/nunit/nunit/actions/runs/4739738110/jobs/8414851760?pr=4350#step:8:423
Errors, Failures and Warnings
1) Failed : NUnit.Framework.Constraints.DefaultConstraintTests.Success_DefaultStructWithOverriddenEquals
Expected: default
But was: NUnit.Framework.Constraints.DefaultConstraintTests+StructWithStrangeEquals
at NUnit.Framework.Constraints.DefaultConstraintTests.AssertSuccess[T](T actual)
at NUnit.Framework.Constraints.DefaultConstraintTests.Success_DefaultStructWithOverriddenEquals()
Run Settings
Number of Test Workers: 2
Work Directory: D:\a\nunit\nunit\src\NUnitFramework\tests\bin\Release\net462
Internal Trace: Off
It also fails for me locally, I pushed back the version that has the precompilation directive.
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.
I have upgraded my SDK to the same as the build server used, but it is still not failing for me.
This is scary, code that works only on some machines.
@stevenaw Does this test fail for you?
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.
I missed it earlier but @stevenaw already said the tests worked for him as well.
I suggest to remove the test and the bad struct.
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.
I removed the test case but kept the struct as it's referenced in equality test that isn't broken. I force pushed the version - not sure how you want your history but single commit probably cleaner as I guess you don't squash merge commits by default.
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.
That test case is covered by the ImmutableArray case and the weird Equatable implementation will confuse any reader. Please remove it.
Yes, single commit is preferred by me
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.
Done and force-pushed.
672ca7a
to
700c063
Compare
* set test data projects not be be optimized as non-optimized behavior is expected
Thanks @lahma |
As discussed in #4149 , seems like a good time with 4.0 nearing to try out again distributing optimized release builds. With this PR removing the forced no-optimize and BenchmarkDotNet project proves that artifacts can now be consumed as release builds (no longer need to disable validator).
Quick benchmark test for changes. Shows > 10% time reduction in best cases (very feature-limited benchmarks of course).
Before (master)
After (this PR)