-
Notifications
You must be signed in to change notification settings - Fork 136
Implement unit-tests for UpdateNuGetConfigPackageSourcesMappings
task
#4706
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
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
1 similar comment
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
IMO the current sequence point (the Test target) is appropriate and I wouldn't change that. Our repo official builds usually don't run tests (there are a few outliers, i.e. vstest). We decided on that few years back for improved reliability and build times. If we need a place to do unit testing then I would recommend adding a new test project under /test.
Sounds good. |
The current source-build tests are a mixture of unit tests and scenario tests. #4384 tracks removing the scenario tests now that we have a shared set of tests in the scenarios-tests repo. Source-build does not and should not run the current unified-build tests. The current unified build tests are transient only for the purposes of comparing the unified build leg output to the current Microsoft builds as a means to identify differences in the unified build.
I like the idea of three separate projects for this. |
The only remaining question is about unit-test location and the time they get built. While trying to build them as part of unified-build tests in It should be possible to introduce some new '.proj` file to build the tasks project again, during testing to publish to a different location, and have it consume new dependencies. However, I believe a better option might be to build unit-tests project along with tasks project, at the same time, using the same dependencies. That way we'd be building the tests using the same toolset and dependencies. Tasks are used during build, and consume old dependencies, unit-tests should consume those same dependencies. This allows unit-tests to test the actual tasks experience. In this scenario, we'd need to ensure we have the dependencies available during testing. |
I don't think that's the right approach. We want to build the unit test projects independently and also not part of the main build. That's why we have tests.proj as a separate unit.
IMO the location should be a separate project under test/.
We want to test the tasks that are executed as part of the VMR build, hence they shouldn't get rebuilt with a different set of inputs.
Would you mind elaborating on that? How is that enforced today? |
I might have phrased some of my previous comments tersely. When we build tests we have all the newly produced packages in NuGet store, which can lead to issues with package mismatch. However, the issue I have seen in my initial attempt to add unit-tests is somewhat different. Test project directly depends on When I added the unit-test source file to this project and a necessary reference to Tasks project, I got the following build errors (just one here, for brevity):
This was caused by direct references to NuGet assemblies in .NET SDK, from the Tasks project, and other projects under tools: https://github.com/dotnet/sdk/blob/8584c262d4d2e1a0af388271ae0715db3c53a2b6/src/SourceBuild/content/eng/tools/Directory.Build.props#L9-L19
While, I can solve this by creating a new project for unit-tests, that would not have a dependency on any NuGet.* packages (as I don't need them), there might be other unit-tests in the future, that would need NuGet.* packages and will hit this issue. So, I think that we should have the right solution in place, to avoid such issues down the road. |
Yes, that makes sense. It's a mismatch between a direct assembly reference (the NuGet assemblies from the .NET SDK) and a package reference. That is a general problem and RAR (ResolveAssemblyReference) warns about these to make sure that dependencies are compatible and can be unified. Here, either all tasks need to use a package reference or if that isn't possible (i.e. because of prebuilts), the projects that reference task projects need to use the same mechanism to reference the NuGet assemblies from the SDK. Note that this only affects NuGet assemblies and Newtonsoft.Json. We have a tracking issue to remove the latter eventually. Hope that helps. |
Source-build tasks do not have any unit-tests. As tasks get complex tests are even more important, as was experienced with this task. There were developer-centric tests, which need to be converted into unit-tests.
This is related to #4666
As part of this work, it is important to improve organization of unified build and source-build tests. Currently we have two projects in VMR, under
test
, both of them are product tests. Source-build tests should run both source-build and unified-build tests, as those are common - today. In the future there will likely be some tests that are specific to unified build and not applicable to source-build. Common, source-build and unified-build (or Microsoft) tests are 3 natural classes of tests. Perhaps unified-build tests can be marked appropriately, so that common tests are included in source-build testing.Unit-tests are usually built and run as part of the same build so they consume the same dependencies. Product tests are intentionally removed from main build, to enable these test projects to consume artifacts (including packages) that are produced by unified- (or source-) build.
Open question: should unit-tests for unified-build and source-build tasks be built/executed together with product tests or earlier in the build when tasks are built.
The text was updated successfully, but these errors were encountered: