-
Notifications
You must be signed in to change notification settings - Fork 4k
/
vscode-run-tests.ps1
43 lines (33 loc) · 1.49 KB
/
vscode-run-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
param (
[Parameter(Mandatory = $true)][string]$filePath,
[string]$msbuildEngine = "vs",
[string]$framework = $null,
[string]$filter = ""
)
Set-StrictMode -version 3.0
$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "../eng/build-utils.ps1")
# Run a build
. (Join-Path $PSScriptRoot "./vscode-build.ps1") -filePath $filePath -framework $framework -msbuildEngine $msbuildEngine
Write-Output ""
$fileInfo = Get-ItemProperty $filePath
$projectFileInfo = Get-ProjectFile $fileInfo
if ($projectFileInfo) {
$dotnetPath = Resolve-Path (Ensure-DotNetSdk) -Relative
$projectDir = Resolve-Path $projectFileInfo.Directory -Relative
$filterArg = if ($filter) { " --filter $filter" } else { "" }
$logFilePrefix = if ($filter) { $fileInfo.Name } else { $projectFileInfo.Name }
$frameworkArg = if ($framework) { " --framework $framework" } else { "" }
$resultsPath = Join-Path $PSScriptRoot ".." "artifacts/TestResults"
$resultsPath = Resolve-Path (New-Item -ItemType Directory -Force -Path $resultsPath) -Relative
# Remove old run logs with the same prefix
Remove-Item (Join-Path $resultsPath "$logFilePrefix*.html") -ErrorAction SilentlyContinue
$invocation = "& `"$dotnetPath`" test $projectDir" + $filterArg + $frameworkArg + " --logger `"html;LogFilePrefix=$logfilePrefix`" --results-directory $resultsPath --no-build"
Write-Output "> $invocation"
Invoke-Expression $invocation
exit 0
}
else {
Write-Host "Failed to run tests. $fileInfo is not part of a C# project."
exit 1
}