Move xunit test harness to its own directory under core_root (#44921)
authorSimon Nattress <nattress@gmail.com>
Thu, 19 Nov 2020 23:16:41 +0000 (15:16 -0800)
committerGitHub <noreply@github.com>
Thu, 19 Nov 2020 23:16:41 +0000 (15:16 -0800)
Running `xunit.console` from within the CoreRoot directory is problematic. It is executed by the shared runtime but has a full copy of the runtime and framework libraries next to it from which assemblies are getting loaded despite being for a pre-release test runtime.

Place the xunit assemblies under `<core_root>/xunit` and update the places that invoke it in local and Helix test runs.

The loaded tests do reference the xunit assemblies so they need to also be available in core_root for when the tests run (with the exception of the harness specific assemblies like xunit.console).

src/tests/Common/Directory.Build.targets
src/tests/Common/helixpublishwitharcade.proj
src/tests/Common/tests.targets
src/tests/Directory.Build.targets
src/tests/run.py

index 46ce59e..d8a6dc3 100644 (file)
@@ -41,6 +41,7 @@
       <RunTimeDependencyCopyLocalFile Include="@(AllResolvedRuntimeDependencies)"  Exclude="@(RunTimeDependencyExcludeFiles)"/>
       <RunTimeDependencyCopyLocal Include="@(RunTimeDependencyCopyLocalFile -> '%(File)')"  />
       <RunTimeDependencyCopyLocal Include="$(TargetingPackPath)/*" />
+      <RunTimeDependencyCopyLocal Include="$(TargetingPackPath)/xunit.*" TargetDir="xunit/" />
     </ItemGroup>
 
     <ItemGroup>
@@ -84,6 +85,9 @@
       <RunTimeArtifactsIncludeFolders Include="R2RTest/">
         <IncludeSubFolders>True</IncludeSubFolders>
       </RunTimeArtifactsIncludeFolders>
+
+      <!-- XUnit runner harness assemblies that we don't want to mix in with the framework in Core_Root -->
+      <RunTimeArtifactsIncludeFolders Include="xunit/" />
     </ItemGroup>
 
     <ItemGroup>
index cdebbe1..ad82766 100644 (file)
       <_XUnitConsoleRunnerFiles Include="$(NuGetPackageRoot)$(MicrosoftDotNetXUnitConsoleRunnerPackage)\$(MicrosoftDotNetXUnitConsoleRunnerVersion)\**\xunit.console.*" />
     </ItemGroup>
 
-    <Copy SourceFiles="@(_XUnitConsoleRunnerFiles)" DestinationFolder="$(CoreRootDirectory)" />
+    <Copy SourceFiles="@(_XUnitConsoleRunnerFiles)" DestinationFolder="$(CoreRootDirectory)\xunit" />
     <Copy SourceFiles="$(MSBuildThisFileDirectory)scripts\runincontext.cmd" DestinationFolder="$(CoreRootDirectory)" Condition=" '$(TargetsWindows)' == 'true' and '$(_RunInUnloadableContext)' == 'true'" />
     <Copy SourceFiles="$(MSBuildThisFileDirectory)scripts/runincontext.sh" DestinationFolder="$(CoreRootDirectory)" Condition=" '$(TargetsWindows)' != 'true' and '$(_RunInUnloadableContext)' == 'true'" />
   </Target>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(TargetsWindows)' == 'true' ">
-    <XUnitRunnerDll>%CORE_ROOT%\xunit.console.dll</XUnitRunnerDll>
+    <XUnitRunnerDll>%CORE_ROOT%\xunit\xunit.console.dll</XUnitRunnerDll>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(TargetsWindows)' != 'true' ">
-    <XUnitRunnerDll>$CORE_ROOT/xunit.console.dll</XUnitRunnerDll>
+    <XUnitRunnerDll>$CORE_ROOT/xunit/xunit.console.dll</XUnitRunnerDll>
   </PropertyGroup>
 
   <ItemGroup Condition=" '$(UsesHelixSdk)' == 'true' ">
index 606775a..639d08a 100644 (file)
@@ -41,7 +41,7 @@
 
     <Error Condition="'$(CORE_ROOT)' == ''" Text="CORE_ROOT is not set." />
     <PropertyGroup>
-      <XunitConsoleRunner>$(CORE_ROOT)\xunit.console.dll</XunitConsoleRunner>
+      <XunitConsoleRunner>$(CORE_ROOT)\xunit\xunit.console.dll</XunitConsoleRunner>
 
       <XunitArgs Condition="'$(TargetOS)' == 'Android'">-parallel none</XunitArgs>
       <XunitArgs Condition="'$(TargetOS)' != 'Android'">-parallel $(ParallelRun)</XunitArgs>
index a6a8d2d..802b7d4 100644 (file)
       <RunTimeDependencyCopyLocalFile Include="@(AllResolvedRuntimeDependencies)"  Exclude="@(RunTimeDependencyExcludeFiles)"/>
       <RunTimeDependencyCopyLocal Include="@(RunTimeDependencyCopyLocalFile -> '%(File)')"  />
       <RunTimeDependencyCopyLocal Include="$(TargetingPackPath)/*" />
+      <RunTimeDependencyCopyLocal Include="$(TargetingPackPath)/xunit.*" TargetDir="xunit/" />
     </ItemGroup>
 
     <ItemGroup>
       <RunTimeArtifactsIncludeFolders Include="R2RTest/">
         <IncludeSubFolders>True</IncludeSubFolders>
       </RunTimeArtifactsIncludeFolders>
+
+      <!-- XUnit runner harness assemblies that we don't want to mix in with the framework in Core_Root -->
+      <RunTimeArtifactsIncludeFolders Include="xunit/" />
     </ItemGroup>
 
     <ItemGroup>
index 6c12a84..f710345 100755 (executable)
@@ -984,7 +984,7 @@ def run_tests(args,
     urlretrieve(url, zipfilename)
 
     with zipfile.ZipFile(zipfilename,"r") as ziparch:
-        ziparch.extractall(args.core_root)
+        ziparch.extractall(os.path.join(args.core_root, "xunit"))
 
     os.remove(zipfilename)
     assert not os.path.isfile(zipfilename)