Răsfoiți Sursa

Fix tests on linux-musl-x64

Nate McMaster 7 ani în urmă
părinte
comite
10dff2410f
5 a modificat fișierele cu 33 adăugiri și 8 ștergeri
  1. 17 2
      build/SharedFx.targets
  2. 2 1
      dockerbuild.sh
  3. 2 2
      korebuild-lock.txt
  4. 6 2
      run.ps1
  5. 6 1
      run.sh

+ 17 - 2
build/SharedFx.targets

@@ -530,19 +530,34 @@
 
   <Target Name="BuildSharedFx" DependsOnTargets="GeneratePropsFiles;ResolveSharedFxFiles;CrossGenAssemblies;CrossGenSymbols;PackSharedFx;TestSharedFx"/>
 
-  <Target Name="TestSharedFx" DependsOnTargets="DefineSharedFxPrerequisites;ResolveCommitHash">
+  <PropertyGroup>
+    <UnitTestFxProject>$(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj</UnitTestFxProject>
+    <UnitTestFxTrxLogFile>$(LogOutputDir)SharedFx-UnitTests.trx</UnitTestFxTrxLogFile>
+    <UnitTestFxTrxPhysicalFilePath>$(UnitTestFxTrxLogFile)</UnitTestFxTrxPhysicalFilePath>
+    <UnitTestFxTrxPhysicalFilePath Condition="'$(HostMachineRepositoryRoot)' != ''">$(HostMachineRepositoryRoot)/artifacts/logs/SharedFx-UnitTests.trx</UnitTestFxTrxPhysicalFilePath>
+  </PropertyGroup>
+
+  <Target Name="TestSharedFx" DependsOnTargets="DefineSharedFxPrerequisites;ResolveCommitHash;InstallDotNet">
     <PropertyGroup>
-      <UnitTestFxProject>$(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj</UnitTestFxProject>
       <UnitTestFxTestProps>
         DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
         DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);
         SharedFxOutputPath=$(SharedFxIntermediateOutputPath);
         RepositoryCommit=$(RepositoryCommit);
+        VSTestLogger=$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
         SharedFxRuntimeIdentifier=$(SharedFXRid)
       </UnitTestFxTestProps>
     </PropertyGroup>
     <MSBuild Projects="$(UnitTestFxProject)" Targets="Restore" Properties="_Dummy=restore;$(UnitTestFxTestProps)" />
     <MSBuild Projects="$(UnitTestFxProject)" Targets="VSTest" Properties="$(UnitTestFxTestProps)" />
+    <CallTarget Targets="ReportTestSharedFxTrx" />
+    <OnError ExecuteTargets="ReportTestSharedFxTrx" />
+  </Target>
+
+  <Target Name="ReportTestSharedFxTrx">
+    <Message Text="##teamcity[importData type='vstest' path='$(UnitTestFxTrxPhysicalFilePath)']"
+      Importance="high"
+      Condition=" '$(TEAMCITY_VERSION)' != '' AND Exists('$(UnitTestFxTrxLogFile)') "/>
   </Target>
 
 </Project>

+ 2 - 1
dockerbuild.sh

@@ -115,4 +115,5 @@ docker run \
     ${docker_args[@]+"${docker_args[@]}"} \
     $tagname \
     ./build.sh \
-    ${build_args[@]+"${build_args[@]}"}
+    ${build_args[@]+"${build_args[@]}"} \
+    "-p:HostMachineRepositoryRoot=$DIR"

+ 2 - 2
korebuild-lock.txt

@@ -1,2 +1,2 @@
-version:2.2.0-preview1-17082
-commithash:13b85a32c7aa9d62f6f3cc211c5c7c566d16b3dd
+version:2.2.0-preview1-17084
+commithash:d7fb2f0a63fbc33e8fe2bdb8f4ef63c1aea6d6ce

+ 6 - 2
run.ps1

@@ -32,6 +32,9 @@ Re-installs KoreBuild
 .PARAMETER ConfigFile
 The path to the configuration file that stores values. Defaults to korebuild.json.
 
+.PARAMETER CI
+Sets up CI specific settings and variables.
+
 .PARAMETER PackageVersionPropsUrl
 (optional) the url of the package versions props path containing dependency versions.
 
@@ -81,7 +84,8 @@ param(
     [Alias('u')]
     [switch]$Update,
     [switch]$Reinstall,
-    [string]$ConfigFile,
+    [string]$ConfigFile = $null,
+    [switch]$CI,
     [string]$PackageVersionPropsUrl = $null,
     [string]$AccessTokenSuffix = $null,
     [string]$RestoreSources = $null,
@@ -235,7 +239,7 @@ $korebuildPath = Get-KoreBuild
 Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1')
 
 try {
-    Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile
+    Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI
     Invoke-KoreBuildCommand $Command @MSBuildArguments
 }
 finally {

+ 6 - 1
run.sh

@@ -18,6 +18,7 @@ reinstall=false
 repo_path="$DIR"
 channel=''
 tools_source=''
+ci=false
 package_version_props_url=''
 asset_root_url=''
 access_token_suffix=''
@@ -48,6 +49,7 @@ __usage() {
     echo "    --product-build-id <ID>                   The product build ID for correlation with orchestrated builds."
     echo "    -u|--update                               Update to the latest KoreBuild even if the lock file is present."
     echo "    --reinstall                               Reinstall KoreBuild."
+    echo "    --ci                                      Apply CI specific settings and environment variables."
     echo ""
     echo "Description:"
     echo "    This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be."
@@ -216,6 +218,9 @@ while [[ $# -gt 0 ]]; do
         --reinstall|-Reinstall)
             reinstall=true
             ;;
+        --ci|-[Cc][Ii])
+            ci=true
+            ;;
         --verbose|-Verbose)
             verbose=true
             ;;
@@ -288,7 +293,7 @@ fi
 [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools'
 
 get_korebuild
-set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file"
+set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci"
 
 # This incantation avoids unbound variable issues if msbuild_args is empty
 # https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u