Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/Test.ps1 @ 18231

Last change on this file since 18231 was 18226, checked in by jkarder, 3 years ago

#3017: updated build and test scripts to support VS 2022

File size: 11.3 KB
Line 
1# find ms build
2$programFilesDirs = @($Env:ProgramFiles, ${Env:ProgramFiles(x86)})
3$years = @("2022", "2019", "2017")
4$editions = @("Enterprise", "Professional", "Community", "BuildTools")
5$versions = @("Current", "15.0")
6
7$msBuildPath = $undefined
8$vstestPath = $undefined
9:search Foreach ($dir in $programFilesDirs) {
10  $vsDir = [System.IO.Path]::Combine($dir, "Microsoft Visual Studio")
11  Foreach ($year in $years) {
12    $loc = [System.IO.Path]::Combine($vsDir, $year)
13    Foreach ($edition in $editions) {
14      $edLoc = [System.IO.Path]::Combine($loc, $edition, "MSBuild")
15      Foreach ($version in $versions) {
16        $binLoc = [System.IO.Path]::Combine($edLoc, $version, "Bin")
17        $loc64 = [System.IO.Path]::Combine($binLoc, "amd64", "MSBuild.exe")
18        $loc32 = [System.IO.Path]::Combine($binLoc, "MSBuild.exe")
19
20        If ([System.IO.File]::Exists($loc64)) {
21          $msBuildPath = $loc64
22          $vstestPath = [System.IO.Path]::Combine($loc, $edition, "Common7", "IDE", "CommonExtensions", "Microsoft", "TestWindow", "vstest.console.exe")
23          Break search;
24        }
25        If ([System.IO.File]::Exists($loc32)) {
26          $msBuildPath = $loc32
27          $vstestPath = [System.IO.Path]::Combine($loc, $edition, "Common7", "IDE", "CommonExtensions", "Microsoft", "TestWindow", "vstest.console.exe")
28          Break search;
29        }
30      }
31    }
32  }
33}
34
35If ($vstestPath -eq $undefined) {
36  "Could not locate vstest.console.exe, ABORTING ..."
37  Return
38}
39
40If(-not [System.IO.File]::Exists($vstestPath)) {
41  "vstest.console.exe is not found at $vstestPath, ABORTING ..."
42  Return
43}
44
45$testcontainer = "HeuristicLab.Tests.dll"
46$input = Read-Host "Which container to test? [$($testcontainer)]"
47$testcontainer = ($testcontainer, $input)[[bool]$input]
48
49$testplatform = "x64"
50$input = Read-Host "Which platform to run the tests? [$($testplatform)]"
51$testplatform = ($testplatform, $input)[[bool]$input]
52
53$testcategory = "Essential"
54$input = Read-Host "Which category do you want to run? [$($testcategory)]"
55$testcategory = ($testcategory, $input)[[bool]$input]
56
57# query whether to build
58$input = Read-Host "Should the tests be rebuilt y/N?"
59$input = ([string]("n", $input)[[bool]$input]).ToLowerInvariant()
60$dobuild = $input -eq "y"
61
62If($dobuild) {
63  $curPath = $MyInvocation.MyCommand.Path
64  $curDir = Split-Path $curPath
65
66  $slnFiles = Get-ChildItem $curDir -Filter *Tests.sln
67
68  If ($slnFiles.Count -le 0) {
69    "No solutions found, ABORTING ..."
70    Return
71  }
72
73  $slnIndices = @()
74
75  If ($slnFiles.Count -eq 1) {
76    "Selecting the only solution found: `"{0}`"" -f $slnFiles[0].Name
77    $slnIndices += 0
78  } Else {
79    "Found the following solutions:"
80
81    ""
82
83    $slnFiles | % { $i = 0 } { ("  {0}. `"{1}`"" -f ($i + 1), $_.Name); $i++ }
84
85    ""
86
87    $success = $false
88
89    # query solution to build
90    $slnIndex = -1
91    Do {
92        $input = Read-Host "Which solution(s) to build? (e.g.: 1 2 3) { 1..$($slnFiles.Count) }"
93        $inputParts = $input -Split " "
94
95        Foreach ($part in $inputParts) {
96          If ($part -eq "") { Continue }
97
98          $success = [int]::TryParse($part, [ref]$slnIndex) -and ($slnIndex -gt 0) -and ($slnIndex -le $slnFiles.Count)
99
100          If ($success) {
101            $slnIndices += $slnIndex - 1
102          } Else {
103            $slnIndices = @()
104            Break
105          }
106        }
107    } While (-Not $success)
108
109    $slnIndices = $slnIndices | Select-Object -Unique
110  }
111
112
113  # query configuration to build
114  $config = "Release"
115  $input = Read-Host "Which configuration to build? [$($config)]"
116  $config = ($config, $input)[[bool]$input]
117
118  # query platform to build
119  $platform = "Any CPU"
120  $input = Read-Host "Which platform to build? [$($platform)]"
121  $platform = ($platform, $input)[[bool]$input]
122
123  # query clean desire
124  $clean = $false
125  Do {
126      $input = Read-Host "Would you like to clean before building? [y/N]"
127      $input = ([string]("n", $input)[[bool]$input]).ToLowerInvariant()
128      $success = $input -eq "n" -or ($clean = $input -eq "y")
129  } While (-Not $success)
130
131  ""
132
133  If ($clean) {
134    Foreach ($slnIndex in $slnIndices) {
135      $solution = $slnFiles[$slnIndex]
136      "Cleaning `"$($solution.Name)`" ..."
137      $args = @(
138        $solution.FullName,
139        "/t:Clean",
140        "/p:Configuration=`"$config`",Platform=`"$platform`"",
141        "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
142      )
143      & $msBuildPath $args
144      "===== CLEAN FINISHED ====="
145    }
146  }
147
148  Foreach ($slnIndex in $slnIndices) {
149    $solution = $slnFiles[$slnIndex]
150    "Building `"$($solution.Name)`" ($config|$platform) ..."
151    $args = @(
152      $solution.FullName,
153      "/t:Restore,Build",
154      "/p:Configuration=`"$config`",Platform=`"$platform`"",
155      "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
156    )
157    & $msBuildPath $args
158    "===== BUILD FINISHED ====="
159  }
160}
161
162& $vstestPath "bin\$testcontainer" /Framework:framework40 /Platform:$testplatform /TestCaseFilter:"TestCategory=$testcategory"
163
164""
165
166Write-Host -NoNewline "Press any key to continue ... "
167
168[void][System.Console]::ReadKey($true)
169
170# SIG # Begin signature block
171# MIIRPwYJKoZIhvcNAQcCoIIRMDCCESwCAQExDzANBglghkgBZQMEAgEFADB5Bgor
172# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
173# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBtCktnwnVbhfUW
174# rrODW7qXn4ckTNXv9s/As4v50Ft51aCCDo4wggbaMIIEwqADAgECAhNoAAE6ILAh
175# JeBjaP8pAAEAATogMA0GCSqGSIb3DQEBCwUAMD4xEjAQBgoJkiaJk/IsZAEZFgJh
176# dDEVMBMGCgmSJomT8ixkARkWBWZob29lMREwD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auzdO4jPbxsSFCse10xO/2TW1C/ugraXv1fSU
209# HlYpUtt+wGhFV75QspOgUgWGc3KBMYm1XwjTWRwBZUd3l7S3UP6IqHaRu3I7eBsF
210# OUArTCtXSK+szMW+1G1gIoT61ZyxemUjg9GuF7qIRwlt+Bax4Jy1aZ1TsmV0z1SS
211# nBxuiKeBO1MwggesMIIFlKADAgECAhMeAAAABpSzaQpcq/lwAAEAAAAGMA0GCSqG
212# SIb3DQEBCwUAMBcxFTATBgNVBAMTDEZIT09lUm9vdENBMTAeFw0xNTA1MDcxMjIy
213# MzFaFw0yNzA1MDcxMjMyMzFaMD4xEjAQBgoJkiaJk/IsZAEZFgJhdDEVMBMGCgmS
214# JomT8ixkARkWBWZob29lMREwDwYDVQQDEwhGSE9PZUNBMTCCAiIwDQYJKoZIhvcN
215# AQEBBQADggIPADCCAgoCggIBAMA7PbbPxLUYOLUThQt0UWtwpT5rT1ZIRinD/wXG
216# asjsvxTEsWDG6kf0tLyLlf64zNOhtXG5pbidu+rcmdnlut58h9So8QuZELdb8xbS
217# 9rM3oTC9wKGW57oRydxIo7WkQwX/IZHefQf2X8AVp0Sb+kCvedUee1/GLIpfef1Y
218# SvIxYURxI5xM7wcnRPPrWDWF+qvKe5miC8DiJ4+xAWqwbXwUUdIq9DUk9JL+2waq
219# GfRodEpMZu/2KlYb6X4z9ZHFgq5OmW+g/WsvyZVQmuXuW0049yP6y79upgFitSrA
220# VeJhEumheU58NC6VBAFvhyCwiR0R1brkpW5s5UP4A3nv1KsVTP12uU7kdWkqwhSa
221# 6OMrga5H4ixHYLIpVqQ4j3K1qHNZfxBtVs5x6VhBhPOxT4uFTzFXiX1VZZK1bH2k
222# K6jV0Hvyr/DzUNlwED2mZ8K7PwPbiDJyemvyvSeEvV/Nk12q8rSM308fVXy2Pkm5
223# LuAxgNejOBNSmH828IR3Zd2TGgRYfGFklfNpAEOBNgz287/saMkNr/BqTrWFkuD8
224# sevpa93bCo7OhWUgVNiVWjSdL/J3aj9cX3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DQEJBDEiBCDDzy6RhRdWhlEvoZ9lSBH8
257# 1bgdAp3kSHSn3I9JzPC1gzANBgkqhkiG9w0BAQEFAASCAQCKOmizxpz/TOCEhRPY
258# f1KVbo9UBYP3YT7g/TNdUCcI0ITkyQkXI2dowJACBzAyb50EqARONPobf81koPhh
259# /AW0jvak1bXrLRHE6DwitNCBLwTLNkZ2Zn3yUBjB4OwIGyUoX+4af9hC9+G6eoTt
260# aE5vbVnZOZBsultoeKpso5QgL5CPEnqkMXsV1p3MCF2ryD5lHKLEHXvF4A3bfRkz
261# y8sVKscEuRjOMhvCx2qjNLpRFGf5Ppd6hzCIw/e67c/nGUCh6GflK9UfZanW4Gn7
262# NQ9KUd9NZXJ8Bo3bEU9Co51zGXQY18atrTX0AaYizZ/MBCtYOU7x15BtQzraFAiL
263# PHJ6
264# SIG # End signature block
Note: See TracBrowser for help on using the repository browser.