Skip to content

Convert Test projects to SDK style projects. #517

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

Merged
merged 2 commits into from
Nov 25, 2019
Merged

Convert Test projects to SDK style projects. #517

merged 2 commits into from
Nov 25, 2019

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Nov 7, 2019

This PR converts all test projects in Java.Interop to "sdk-style" projects.

Some call-outs:

  • Consolidates all test projects under /tests. Previously test projects were spread across /tests, /src, and /tools.
    • Putting test projects inside the source directory doesn't work great by default with sdk-style because of the wildcard <Compile Include="**\*" />, meaning you have to add Excludes for all the test files.
    • Consistency is its own reward!
  • Removes the testing shared projects like Dynamic-Tests.shproj. We no longer use PCL's so the tests are now added directly to the single test project.
  • Added a NuGet.Config specifying packages should get restored to /packages. This is the way things have always worked, but switching to <PackageReference> now restores them to the machine global package cache. Our testing infrastructure expects nunit-console and csc to be downloaded from NuGet and placed in a known location. The global package cache causes problems because it is in different places on different OS's and there's no easy way for MSBuild to know where it is.
  • NuGet packages restored from <PackageReference> instead of packages.config are stored differently so scripts and code were updated to find the packages. ie:
    • packages.config: packages/NUnit.ConsoleRunner.3.9.0
    • <PackageReference>: packages/nunit.consolerunner/3.9.0

Test builds from before and after to ensure no tests were lost:
Before: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3228777&view=ms.vss-test-web.build-test-results-tab
After: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3233260&view=ms.vss-test-web.build-test-results-tab

@jpobst jpobst force-pushed the sdk-tests branch 29 times, most recently from c000573 to 79e391c Compare November 11, 2019 19:59
@jpobst jpobst marked this pull request as ready for review November 22, 2019 19:51
@jpobst jpobst requested a review from jonpryor November 22, 2019 19:51
-->
<configuration>
<config>
<add key="globalPackagesFolder" value="$\..\packages" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is $ in $\..\packages? I can't easily find any mention of this behavior. (Environment variables are supported.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it is "local to this NuGet.Config", since you could have several configs getting inherited.

For the repositoryPath setting, you can specify an absolute path or relative path (recommended) using the $ token. The $ token is based on where the NuGet.Config is located (The $ token is actually relative to one level below the location of the NuGet.Config). So, if I have \Solutions\NuGet.Config and I want \Solutions\Packages I would need to specify $\..\Packages as the value.

https://stackoverflow.com/questions/18376313/setting-up-a-common-nuget-packages-folder-for-all-solutions-when-some-projects-a

@@ -5,7 +5,7 @@
<_TopDir>$(MSBuildThisFileDirectory)..\..</_TopDir>
<_Runtime Condition=" '$(RUNTIME)' != '' ">$(RUNTIME)</_Runtime>
<_Runtime Condition=" '$(RUNTIME)' == '' And '$(OS)' != 'Windows_NT' ">mono --debug</_Runtime>
<_NUnit>$(_Runtime) packages\NUnit.ConsoleRunner.3.9.0\tools\nunit3-console.exe</_NUnit>
<_NUnit>$(_Runtime) packages\nunit.consolerunner\3.9.0\tools\nunit3-console.exe</_NUnit>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@(PackageReference) lowercases all the things? Interesting...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And adds the slash...

@@ -33,7 +33,7 @@
<SetEnvironmentVariable Name="JAVA_INTEROP_LREF_LOG" Value="bin\Test$(Configuration)\l-%(_TestAssembly.Filename).txt" />
<SetEnvironmentVariable Name="JI_JVM_PATH" Value="$(JdkJvmPath)" />
<Exec
Command="$(_NUnit) $(NUNIT_EXTRA) %(_TestAssembly.Identity) $(_Run) --result=&quot;TestResult-%(Filename).xml;format=nunit2&quot; --output=&quot;bin\Test$(Configuration)\TestOutput-%(Filename).txt&quot;"
Command="$(_NUnit) $(NUNIT_EXTRA) %(_TestAssembly.Identity) $(_Run) --result=&quot;TestResult-%(Filename).xml&quot; --output=&quot;bin\Test$(Configuration)\TestOutput-%(Filename).txt&quot;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is format=nunit2 not needed? Does AzDO recognize the default format? Did the default change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but when I left it in there, the CI NUnit choked on it and said it wasn't a valid format. Removing it seems to work, the tests are still picked up for the test tab:

https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3266847&view=ms.vss-test-web.build-test-results-tab

I think now it defaults to nunit3. Given that NUnit 3.0 shipped in 2015, I'm more surprised that AzDO supported nunit2. ;)

@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this file to logcat-parse-Tests.csproj so it matches the directory name?

(How is the output assembly determined, anyway? From enclosing directory name? .csproj base name?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename it. I'm pretty sure it's from the .csproj name.


// One would expect this to be "Object" but it doesn't seem to be
Assert.AreEqual (KotlinClassType.Class, klass_meta.ObjectType);
Assert.AreEqual (KotlinClassType.Object, klass_meta.ObjectType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems weird; how'd it carries from the .csproj migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I had committed a bad .class file previously. It got regenerated from the Kotlin as part of testing this, which now gave me the results I was previously expecting.

@jonpryor jonpryor merged commit dec2e39 into master Nov 25, 2019
@jonpryor jonpryor deleted the sdk-tests branch November 25, 2019 21:47
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants