-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ps1
More file actions
44 lines (37 loc) · 1.38 KB
/
test.ps1
File metadata and controls
44 lines (37 loc) · 1.38 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
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$framework = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
$outputDirectory = Join-Path $repoRoot "build"
$testOutput = Join-Path $outputDirectory "MiniSnip.Tests.exe"
$references = @(
(Join-Path $framework "System.dll"),
(Join-Path $framework "System.Drawing.dll"),
(Join-Path $framework "System.Windows.Forms.dll")
)
$referenceArguments = $references | ForEach-Object { "/reference:$_" }
$sourceFiles = Get-ChildItem -LiteralPath (Join-Path $repoRoot "src") -Filter "*.cs" |
Select-Object -ExpandProperty FullName
$testFiles = Get-ChildItem -LiteralPath (Join-Path $repoRoot "tests") -Filter "*.cs" |
Select-Object -ExpandProperty FullName
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
try {
& (Join-Path $framework "csc.exe") `
/nologo `
/target:exe `
/optimize+ `
/main:MiniSnip.Tests.TestProgram `
"/out:$testOutput" `
$referenceArguments `
$sourceFiles `
$testFiles
if ($LASTEXITCODE -ne 0) {
throw "MiniSnip test build failed with exit code $LASTEXITCODE."
}
& $testOutput
if ($LASTEXITCODE -ne 0) {
throw "MiniSnip tests failed with exit code $LASTEXITCODE."
}
}
finally {
Remove-Item -LiteralPath $testOutput -Force -ErrorAction SilentlyContinue
}