37 lines
883 B
PowerShell
37 lines
883 B
PowerShell
|
|
param(
|
||
|
|
[string[]]$Packages = @('.', './ntfs/usn'),
|
||
|
|
[switch]$KeepArtifacts
|
||
|
|
)
|
||
|
|
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
|
||
|
|
$repo = Resolve-Path (Join-Path $PSScriptRoot '..')
|
||
|
|
$tmpDir = Join-Path $repo '.tmp_test'
|
||
|
|
New-Item -ItemType Directory -Force -Path $tmpDir | Out-Null
|
||
|
|
|
||
|
|
Set-Location $repo
|
||
|
|
|
||
|
|
foreach ($pkg in $Packages) {
|
||
|
|
$name = ($pkg -replace '[^A-Za-z0-9_.-]', '_').Trim('_')
|
||
|
|
if ([string]::IsNullOrWhiteSpace($name) -or $name -eq '.') {
|
||
|
|
$name = 'root'
|
||
|
|
}
|
||
|
|
$exe = Join-Path $tmpDir ("$name.test.exe")
|
||
|
|
|
||
|
|
Write-Host "[build] $pkg -> $exe"
|
||
|
|
go test $pkg -c -o $exe
|
||
|
|
if ($LASTEXITCODE -ne 0) {
|
||
|
|
throw "go test -c failed for package $pkg"
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host "[run] $pkg"
|
||
|
|
& $exe --% -test.v
|
||
|
|
if ($LASTEXITCODE -ne 0) {
|
||
|
|
throw "test executable failed for package $pkg"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (-not $KeepArtifacts) {
|
||
|
|
Remove-Item $tmpDir -Recurse -Force -ErrorAction SilentlyContinue
|
||
|
|
}
|