-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Make test libraries configuration agnostic #378
Conversation
ccc7a1e
to
eddcfe4
Compare
src/libraries/Directory.Build.props
Outdated
<DefineConstants>$(DefineConstants),DEBUG,TRACE</DefineConstants> | ||
<!-- Test projects should be configuration agnostic. --> | ||
<DefineConstants Condition="'$(IsTestProject)' != 'true'">$(DefineConstants),DEBUG</DefineConstants> | ||
<DefineConstants>$(DefineConstants),TRACE</DefineConstants> |
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.
Is there a good reason to keep TRACE
defined?
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.
It doesn't seem like it. From doing a grep, I saw that there are only a few usages of this constant, but the projects that use it, either define it on the files or on the csproj itself.
Should we just remove those conditionals and defines? It seems like it is always defined, therefore, those methods are always available?
...ibraries/System.Diagnostics.DiagnosticSource/tests/DiagnosticSourceEventSourceBridgeTests.cs
Show resolved
Hide resolved
A better way to do this may be to |
I would scope this change to:
But I would keep |
I gave this more thought as well and I agree with Jan that we shouldn't undefine DEBUG. |
Yeah there where a couple in some Diagnostics tests.
Ok. I will work on that. |
eddcfe4
to
b3eec67
Compare
@jkotas @ViktorHofer could you please take a look? |
src/libraries/System.Runtime/tests/System/Reflection/MethodBaseTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Reflection/MethodBodyTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
Show resolved
Hide resolved
...braries/System.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.cs
Outdated
Show resolved
Hide resolved
Fixed all comments. Thanks for the review. |
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
Outdated
Show resolved
Hide resolved
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.
Thanks, LGTM.
In order to be able to build tests in one configuration and then use a shared framework that was built against another configuration we need to make our tests to test for specific behavior with an
||
.If this could introduce bugs where a Release code could be returning valid values for Debug but that's wrong, I'm happy to change this to do runtime checks instead, anyway we should not be testing framework configuration specific behavior based on the configuration the tests were built.
For Contracts tests, I did leave Configuration dependency, as that depends on what the test assembly was built against but not what shared framework we're running on. So Debug test assembly should work on Release and Debug shared framework. Also if the test assembly is built for Release mode it should work on any shared framework.