forked from exercism/csharp-test-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ps1
65 lines (52 loc) · 1.77 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<#
.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).
.PARAMETER UseDocker
Run the tests using Docker (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
The example below will run all tests using Docker
PS C:\> ./test.ps1 -UseDocker
.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 = Join-Path "test" (Join-Path "Exercism.TestRunner.CSharp.IntegrationTests" "Solutions")
Get-ChildItem $solutionsDir -Directory | ForEach-Object {
Run-Test-Runner $_.FullName
Move-Generated-Test-Results-To-Expected $_.FullName
}
}
function Build-Docker-Image {
docker build -t exercism/csharp-test-runner .
}
if ($UpdateExpected.IsPresent) {
Update-Expected
}
if ($UseDocker.IsPresent) {
Build-Docker-Image
}
$Env:USE_DOCKER = $UseDocker.IsPresent
dotnet test