From f6116a5263f1d23c4b4501524ec82176e96740b1 Mon Sep 17 00:00:00 2001 From: wtgodbe Date: Mon, 18 Jul 2016 15:25:04 -0700 Subject: [PATCH] Enable automatic updating of package versions in test project.json files --- UpdateDependencies.ps1 | 56 ++++++++++++++++++++++++++++++++++++++++---------- tests/buildtest.cmd | 46 ++++++++++++++++++++++++----------------- tests/dir.props | 20 ++++++++++++------ tests/runtest.proj | 4 ++-- 4 files changed, 88 insertions(+), 38 deletions(-) diff --git a/UpdateDependencies.ps1 b/UpdateDependencies.ps1 index 102dd4e..8fee1b9 100644 --- a/UpdateDependencies.ps1 +++ b/UpdateDependencies.ps1 @@ -22,6 +22,16 @@ param( $LatestVersion = Invoke-WebRequest $VersionFileUrl -UseBasicParsing $LatestVersion = $LatestVersion.ToString().Trim() +if ($DirPropsVersionElements -contains 'CoreClrExpectedPrerelease') +{ + # Also get list of all package versions, relative to the given prerelease version url. + $LatestPackagesListUrl = $VersionFileUrl -Replace 'Latest.txt', 'Latest_Packages.txt' + $LatestPackagesList = Invoke-WebRequest $LatestPackagesListUrl -UseBasicParsing + $LatestCoreCLRPackage = $LatestPackagesList -split "`n" | ?{ $_.StartsWith('Microsoft.NETCore.Runtime.CoreCLR') } + $LatestCoreCLRVersion = ($LatestCoreCLRPackage -split ' ')[1].Trim() +} + + # Make a nicely formatted string of the dir props version elements. Short names, joined by commas. $DirPropsVersionNames = ($DirPropsVersionElements | %{ $_ -replace 'ExpectedPrerelease', '' }) -join ', ' @@ -34,22 +44,41 @@ function UpdateValidDependencyVersionsFile return $false } - $DirPropsPath = "$PSScriptRoot\dir.props" - - $DirPropsContent = Get-Content $DirPropsPath | % { - $line = $_ - $DirPropsVersionElements | % { - $line = $line -replace ` - "<$_>.*", ` - "<$_>$LatestVersion" - } - $line + $DirPropsPaths = @("$PSScriptRoot\dir.props", "$PSScriptRoot\tests\dir.props") + + $DirPropsPaths | %{ + $DirPropsContent = Get-Content $_ | %{ + $line = $_ + + $DirPropsVersionElements | %{ + $line = $line -replace ` + "<$_>.*", ` + "<$_>$LatestVersion" + } + + if ($LatestCoreCLRVersion) + { + $line = $line -replace ` + ".*<", ` + "$LatestCoreCLRVersion<" + } + + $line + } + Set-Content $_ $DirPropsContent } - Set-Content $DirPropsPath $DirPropsContent return $true } +# Updates all the project.json files with out of date version numbers +function RunUpdatePackageDependencyVersions +{ + cmd /c $PSScriptRoot\tests\buildtest.cmd updateinvalidpackages | Out-Host + + return $LASTEXITCODE -eq 0 +} + # Creates a Pull Request for the updated version numbers function CreatePullRequest { @@ -113,6 +142,11 @@ if (!(UpdateValidDependencyVersionsFile)) Exit -1 } +if (!(RunUpdatePackageDependencyVersions)) +{ + Exit -1 +} + if (!(CreatePullRequest)) { Exit -1 diff --git a/tests/buildtest.cmd b/tests/buildtest.cmd index 6fcb3e7..d5f8935 100644 --- a/tests/buildtest.cmd +++ b/tests/buildtest.cmd @@ -33,6 +33,7 @@ set __BuildSequential= set __TestPriority= set __msbuildCleanBuildArgs= set __verbosity=normal +set __UpdateInvalidPackagesArg= REM unprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64) set "__args= %*" @@ -49,32 +50,34 @@ if /i "%1" == "-h" goto Usage if /i "%1" == "/help" goto Usage if /i "%1" == "-help" goto Usage -if /i "%1" == "x64" (set __BuildArch=x64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "x86" (set __BuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "arm" (set __BuildArch=arm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "arm64" (set __BuildArch=arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "x64" (set __BuildArch=x64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "x86" (set __BuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "arm" (set __BuildArch=arm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "arm64" (set __BuildArch=arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if /i "%1" == "debug" (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "release" (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "checked" (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "debug" (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "release" (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "checked" (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "clean" (set __CleanBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "clean" (set __CleanBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "vs2013" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "vs2015" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "vs2013" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "vs2015" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "crossgen" (set __crossgen=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "ilasmroundtrip" (set __ILAsmRoundtrip=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "sequential" (set __BuildSequential=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "priority" (set __TestPriority=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) -if /i "%1" == "crossgen" (set __crossgen=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "ilasmroundtrip" (set __ILAsmRoundtrip=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "sequential" (set __BuildSequential=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "priority" (set __TestPriority=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +if /i "%1" == "verbose" (set __verbosity=detailed&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "verbose" (set __verbosity=detailed&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "updateinvalidpackages" (set __UpdateInvalidPackagesArg=/t:UpdateInvalidPackageVersions&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @REM It was initially /toolset_dir. Not sure why, since it doesn't match the other usage. -if /i "%1" == "/toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) -if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +if /i "%1" == "/toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) if [!processedArgs!]==[] ( call set unprocessedBuildArgs=!__args! @@ -183,6 +186,8 @@ REM === REM ========================================================================================= call %__TestDir%\setup-runtime-dependencies.cmd /arch %__BuildArch% /outputdir %__BinDir% +if NOT "%__UpdateInvalidPackagesArg%" == "" goto skipnative + REM ========================================================================================= REM === REM === Native test build section @@ -237,6 +242,8 @@ if errorlevel 1 exit /b 1 REM endlocal to rid us of environment changes from vcvarsall.bat endlocal +:skipnative + if defined __SkipManaged exit /b 0 REM ========================================================================================= @@ -272,7 +279,7 @@ if defined __TestPriority ( ) set __BuildLogRootName=Tests_Managed -call :msbuild "%__ProjectFilesDir%\build.proj" %__msbuildManagedBuildArgs% +call :msbuild "%__ProjectFilesDir%\build.proj" %__msbuildManagedBuildArgs% %__UpdateInvalidPackagesArg% if errorlevel 1 exit /b 1 set CORE_ROOT=%__TestBinDir%\Tests\Core_Root @@ -359,6 +366,7 @@ echo 666: Build all tests with priority 0, 1 ... 666 echo sequential: force a non-parallel build ^(default is to build in parallel echo using all processors^). echo IlasmRoundTrip: enables ilasm round trip build and run of the tests before executing them. +echo updateinvalidpackages: enables updating package versions in all test project.json files echo verbose: enables detailed file logging for the msbuild tasks into the msbuild log file. exit /b 1 diff --git a/tests/dir.props b/tests/dir.props index 870d4e3..cf03387 100644 --- a/tests/dir.props +++ b/tests/dir.props @@ -42,20 +42,28 @@ true true + + rc3-24117-00 + beta-24314-02 + + ^(?i)((System\..*)|(Microsoft\.CSharp)|(Microsoft\.NETCore.*)|(Microsoft\.Win32\..*)|(Microsoft\.VisualBasic))(?<!TestData)$ - - rc3-24117-00 + + $(CoreFxVersionsIdentityRegex) + $(CoreFxExpectedPrerelease) - + + ^(?i)(xunit(\.assert|\.core|\.runner\.(utility|msbuild))?)$ $(XunitPackageVersion) - - + + ^(?i)(xunit\.console\.netcore)$ 1.0.2-prerelease-00101 - + + ^(?i)Microsoft\.DotNet\.xunit\.performance.*$ 1.0.0-alpha-build0035 diff --git a/tests/runtest.proj b/tests/runtest.proj index ecca866..aafa025 100644 --- a/tests/runtest.proj +++ b/tests/runtest.proj @@ -362,12 +362,12 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). %(CoreclrPackage.Filename) - $([System.String]::Copy('$(CoreclrPackageFileName)').Replace('Microsoft.NETCore.Runtime.CoreCLR.','')) + $([System.String]::Copy('$(CoreclrPackageFileName)').Replace('Microsoft.NETCore.Runtime.CoreCLR.',''))