forked from exercism/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-tests.ps1
43 lines (37 loc) · 1.13 KB
/
generate-tests.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
<#
.SYNOPSIS
Generate tests.
.DESCRIPTION
Generate tests based on the latest canonical data.
.PARAMETER Exercise
The slug of the exercise to be analyzed (optional).
.EXAMPLE
The example below will regenerate all tests
PS C:\> ./generate-tests.ps1
.EXAMPLE
The example below will regenerate the tests for the "acronym" exercise
PS C:\> ./generate-tests.ps1 acronym
#>
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$Exercise
)
# Import shared functionality
. ./shared.ps1
. ./update-canonical-data.ps1
function Update-TestFilesForTrack {
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$Exercise
)
$generatorsProject = "./generators"
$generatorsArgs = if ($Exercise) { @("--exercise", $Exercise) } else { @() }
if ($PSCmdlet.ShouldProcess($generatorsProject, "execute")) {
Write-Output "Updating tests"
Invoke-CallScriptExitOnError { dotnet run --project $generatorsProject $generatorsArgs }
}
}
Update-CanonicalData
Update-TestFilesForTrack $Exercise