-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest.ps1
More file actions
52 lines (42 loc) · 1.39 KB
/
test.ps1
File metadata and controls
52 lines (42 loc) · 1.39 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
<#
.SYNOPSIS
Run all tests.
.DESCRIPTION
Run all tests, verifying the behavior of the test runner.
.PARAMETER UpdateExpected
Update the expected test result files to the current output (optional).
.EXAMPLE
The example below will run all tests
PS C:\> ./test.ps1
The example below will run all tests and update the expected test result files
PS C:\> ./test.ps1 -UpdateExpected
.NOTES
The UpdateExpected switch should only be used if a bulk update of the expected test result files is needed.
#>
param (
[Parameter(Mandatory = $false)]
[Switch]$UpdateExpected,
[Parameter(Mandatory = $false)]
[Switch]$UseDocker
)
function Run-Test-Runner ([string] $SolutionDir) {
$slug = (Get-ChildItem -Path $SolutionDir -Filter *.csproj).BaseName
./run.ps1 $slug $SolutionDir $SolutionDir
}
function Move-Generated-Test-Results-To-Expected ([string] $SolutionsDir) {
$resultsFile = Join-Path $SolutionsDir "results.json"
$expectedResultsFile = Join-Path $SolutionsDir "expected_results.json"
Move-Item -Force $resultsFile $expectedResultsFile
}
function Update-Expected {
$solutionsDir = "tests"
Get-ChildItem $solutionsDir -Directory | ForEach-Object {
Run-Test-Runner $_.FullName
Move-Generated-Test-Results-To-Expected $_.FullName
}
}
if ($UpdateExpected.IsPresent) {
Update-Expected
}
dotnet test
exit $LastExitCode