Skip to content

Commit 67f919a

Browse files
Move test execution before installer build (#774)
* Also increase test run timeout (to help slower dev boxes)
1 parent 2fd0af8 commit 67f919a

2 files changed

Lines changed: 34 additions & 31 deletions

File tree

Test.runsettings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Framework version - net48 -->
2424
<TargetFrameworkVersion>net48</TargetFrameworkVersion>
2525
<!-- Test timeout in milliseconds (10 minutes default for long-running tests) -->
26-
<TestSessionTimeout>600000</TestSessionTimeout>
26+
<TestSessionTimeout>900000</TestSessionTimeout>
2727
<!--
2828
InIsolation: Run tests in a separate process.
2929
This prevents native COM cleanup crashes from affecting VSTest's exit code.

build.ps1

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,39 @@ try {
525525
Write-Host "Output: Output\$Configuration" -ForegroundColor Cyan
526526
}
527527

528+
# =============================================================================
529+
# Test Execution (Optional)
530+
# =============================================================================
531+
# Run tests BEFORE the installer build because the installer's CleanAll target
532+
# (enabled on CI via InstallerCleanProductOutputs=true) wipes Output/ and
533+
# rebuilds without /p:BuildTests=true, removing all *Tests.dll assemblies.
534+
535+
if ($RunTests) {
536+
Write-Host ""
537+
Write-Host "Running tests..." -ForegroundColor Cyan
538+
539+
$testArgs = @{
540+
Configuration = $Configuration
541+
NoBuild = $true
542+
}
543+
if ($TestFilter) {
544+
$testArgs["TestFilter"] = $TestFilter
545+
}
546+
547+
Stop-ConflictingProcesses @cleanupArgs
548+
& "$PSScriptRoot\test.ps1" @testArgs
549+
$script:testExitCode = $LASTEXITCODE
550+
if ($script:testExitCode -eq 1) {
551+
# VSTest exit code 1 means tests were skipped (or skipped+failed). test.ps1 prints a
552+
# FAIL summary when there are actual failures, so treat exit code 1 as a warning only
553+
# to avoid failing the build when the only non-passing tests were skipped.
554+
Write-Warning "Test run exited with code 1 (skipped tests or failures). Check test output above for details."
555+
$script:testExitCode = 0
556+
} elseif ($script:testExitCode -ne 0) {
557+
Write-Warning "Some tests failed (exit code: $($script:testExitCode)). Check output above for details."
558+
}
559+
}
560+
528561
if ($BuildInstaller -or $BuildPatch) {
529562
if ($BuildPatch) {
530563
$BaseOrPatch = "Patch"
@@ -575,36 +608,6 @@ try {
575608
Write-Host "[OK] $BaseOrPatch build complete!" -ForegroundColor Green
576609
}
577610
}
578-
579-
# =============================================================================
580-
# Test Execution (Optional)
581-
# =============================================================================
582-
583-
if ($RunTests) {
584-
Write-Host ""
585-
Write-Host "Running tests..." -ForegroundColor Cyan
586-
587-
$testArgs = @{
588-
Configuration = $Configuration
589-
NoBuild = $true
590-
}
591-
if ($TestFilter) {
592-
$testArgs["TestFilter"] = $TestFilter
593-
}
594-
595-
Stop-ConflictingProcesses @cleanupArgs
596-
& "$PSScriptRoot\test.ps1" @testArgs
597-
$script:testExitCode = $LASTEXITCODE
598-
if ($script:testExitCode -eq 1) {
599-
# VSTest exit code 1 means tests were skipped (or skipped+failed). test.ps1 prints a
600-
# FAIL summary when there are actual failures, so treat exit code 1 as a warning only
601-
# to avoid failing the build when the only non-passing tests were skipped.
602-
Write-Warning "Test run exited with code 1 (skipped tests or failures). Check test output above for details."
603-
$script:testExitCode = 0
604-
} elseif ($script:testExitCode -ne 0) {
605-
Write-Warning "Some tests failed (exit code: $($script:testExitCode)). Check output above for details."
606-
}
607-
}
608611
}
609612
finally {
610613
# Kill any lingering build processes that might hold file locks

0 commit comments

Comments
 (0)