Repository navigation
Refactor how test case metadata is obtained. - #2268
Conversation
0540d05 to
d23affb
Compare
| { | ||
| TargetingNetFramework = 1, | ||
| TargetingNetCore = 2, | ||
| UsingIllink = 4, |
There was a problem hiding this comment.
I don't like this mode. Can such tests be fixed or files excluded in your build?
There was a problem hiding this comment.
Good point. Technically, it would be nice we could run the tests that are currently using this.
I was able to get these tests running. It took 2 changes.
-
I hardcoded some hack logic in our
UnityTestCaseCompilerto tweak the references when we seeillink.dllappear. I don't see a clean way to handle this. I can live with the hack in our test framework. -
I need to change
Driver.FindStepin order to getSubStepDispatcherUsagepassing. It tries to add a step beforeMarkStep, however, we have aUnityMarkStepwhich inherits fromMarkStep. I thought a nice way to deal with this would be to changeFindStepto look like.
static IStep FindStep (Pipeline pipeline, string name)
{
foreach (IStep step in pipeline.GetSteps ()) {
Type t = step.GetType ();
while (t.BaseType != null) {
if (t.Name == name)
return step;
t = t.BaseType;
}
}
return null;
}
Are you OK with that? If so, I can update the PR with the necessary changes.
Alternatively, I can make FindStep virtual and then override it in our linker.
There was a problem hiding this comment.
Alternatively, I can make FindStep virtual and then override it in our linker.
That's my preference too
| #if NETCOREAPP | ||
| [IgnoreTestCase ("--exclude-feature is not supported on .NET Core")] | ||
| #endif | ||
| [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] |
There was a problem hiding this comment.
Does --exclude-feature have value for you? If not I'd suggest to delete the tests
There was a problem hiding this comment.
We still use it for etw and com.
| public static void Main () | ||
| { | ||
| #if NETCOREAPP | ||
| #if SUPPORTS_DEFAULT_INTERFACE_METHODS |
There was a problem hiding this comment.
It looks like the #if NETCOREAPP was added because this code wouldn't compile against .NET Framework. There are types such as IDynamicInterfaceCastable that don't exist.
We haven't pulled this test into our fork yet. And it looks like removing all of the #ifs in this file wouldn't cause us any issues if we did have this test.
Is it OK if we leave these #ifs in the PR and you can remove them later if you don't want them? I don't care either way. I mostly want to avoid having this PR held up longer.
There was a problem hiding this comment.
I don't think this has much to do with DIM as it's simply API available since net5. Would changing the define to NET_5_0 work for you?
There was a problem hiding this comment.
I was thinking about this more last night and you're right, this is really specific to net5, not DIM. I'll fix it.
There was a problem hiding this comment.
I changed it back to NETCOREAPP instead of NET_5_0.
d23affb to
1bb5cee
Compare
We are updating our `Unity.Linker.Tests` project to target net5. This means our NUnit tests will run on net5. The catch is, we will still be running our linker on assemblies compiled against mono based profiles. This is the first time there has been a difference between the target framework of the unit tests and the test cases. This presents us with a problem. The `TestCaseCollector` is running in `Mono.Linker.Tests` (which will be targeting net5 for us) this means that it's reference to `Mono.Linker.Tests.Cases` is also on net5. This leads to `TestCaseMetadataProvider` give back attribute information from a NETCOREAPP compiled assembly. Causing our tests to run with the NETCOREAPP behavior and that's not what we want. This PR does a few things to make the test framework more flexible to this new need. * Move compilation related methods from `TestCaseMetadataProvider` to `TestCaseCompilationMetadataProvider`. * `TestCaseCompilationMetadataProvider` provides metadata from the solution compiled test case assembly. This is the only build available to bootstrap the test case building process. This means that attributes related to this metadata should *not* use #if's to control when they are defined. * `TestCaseMetadataProvider` - Will contain linker related metadata and test framework asserting metadata. These attributes can continue to use #if's. This metadata provider will now obtain it's information from the expectations version of the test case assembly after it has been compiled in the sandbox. * A new `[TestCaseRequirements]` attribute has been added. This allows a test case to declare the requirements that must be met by the driving test framework in order for the test to run. * `[IgnoreTestCase]` usages inside #if's have been changed to use `[TestCaseRequirements]` * `TestRunCharacteristics.SupportsDefaultInterfaceMethods` was added and default interface methods were placed behind this instead of NETCOREAPP. This allows us to turn these tests on since our mono supports default interface methods now. * `TestRunCharacteristics.SupportsStaticInterfaceMethods` was added and static interface methods were placed behind this. This is consistent with `SupportsDefaultInterfaceMethods` and leaves the door open to us turning these on if we ever support this.
1bb5cee to
a288cfa
Compare
|
@marek-safar should be good to go. |
We are updating our
Unity.Linker.Testsproject to target net5. This means our NUnit tests will run on net5. The catch is, we will still be running our linker on assemblies compiled against mono based profiles. This is the first time there has been a difference between the target framework of the unit tests and the test cases.This presents us with a problem. The
TestCaseCollectoris running inMono.Linker.Tests(which will be targeting net5 for us) this means that it's reference toMono.Linker.Tests.Casesis also on net5. This leads toTestCaseMetadataProvidergiving back attribute information from a NETCOREAPP compiled assembly. Causing our tests to run with the NETCOREAPP behavior and that's not what we want.This PR does a few things to make the test framework more flexible to this new need.
Move compilation related methods from
TestCaseMetadataProvidertoTestCaseCompilationMetadataProvider.TestCaseCompilationMetadataProviderprovides metadata from the solution compiled test case assembly. This is the only build available to bootstrap the test case building process. This means that attributes related to this metadata should not use #if's to control when they are defined.TestCaseMetadataProvider- Will contain linker related metadata and test framework asserting metadata. These attributes can continue to use #if's. This metadata provider will now obtain it's information from the expectations version of the test case assembly after it has been compiled in the sandbox.A new
[TestCaseRequirements]attribute has been added. This allows a test case to declare the requirements that must be met by the driving test framework in order for the test to run.[IgnoreTestCase]usages inside #if's have been changed to use[TestCaseRequirements]TestRunCharacteristics.SupportsDefaultInterfaceMethodswas added and default interface methods were placed behind this instead of NETCOREAPP. This allows us to turn these tests on since our mono supports default interface methods now.TestRunCharacteristics.SupportsStaticInterfaceMethodswas added and static interface methods were placed behind this. This is consistent withSupportsDefaultInterfaceMethodsand leaves the door open to us turning these on if we ever support this.