-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ps1
executable file
·39 lines (32 loc) · 1.52 KB
/
test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env pwsh
# This little script runs Sigourney's test project many times to ensure it works repeatedly.
# It also keeps binary logs of each test run (which are kept as artifacts by CI).
function Remove-Directory-Checked {
param ([string]$Directory)
if (Test-Path $Directory -PathType Container) {
Remove-Item $Directory -Recurse -Force
}
}
$ErrorActionPreference = 'Stop'
$TestLogs = './test-logs/'
$TestProject = './tests/test.proj'
$LocalPackagePath = './tests/packages'
$LocalPackages = Get-ChildItem './tests' -Filter 'testweaver-*.csproj' -Recurse | ForEach-Object { $_.FullName }
Remove-Directory-Checked $LocalPackagePath
Remove-Directory-Checked $TestLogs
# dotnet clean might fail the first time.
Remove-Item tests\**\obj\* -Recurse -Force
function Invoke-MSBuild-Test {
param ([string]$MSBuildCommand, [string]$CommandPrefix)
dotnet clean /v:m /nodereuse:false $TestProject
for ($i = 1; ($i -le 3) -and ($LASTEXITCODE -eq 0); $i++) {
$target = if ($i -eq 1) { "Clean;Test" } else { "Test" }
$testArgs = @($CommandPrefix, $TestProject, "/v:m", "/t:$target", "/nodereuse:false", "/bl:$TestLogs$MSBuildCommand-$i.binlog")
if ($i -eq 1) { $testArgs += "/restore" }
& $MSBuildCommand @testArgs
}
}
dotnet pack ./Sigourney.Shipping.slnf -o $LocalPackagePath -p:Version=0.0.0-local
$LocalPackages | ForEach-Object {dotnet pack $_ -o $LocalPackagePath}
Invoke-MSBuild-Test "dotnet" "msbuild"
if ($IsWindows -and ($LASTEXITCODE -eq 0)) {Invoke-MSBuild-Test "msbuild" ""}