-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-smoke.ps1
More file actions
168 lines (133 loc) · 5 KB
/
Copy pathtest-smoke.ps1
File metadata and controls
168 lines (133 loc) · 5 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#Requires -Version 7.0
<#
.SYNOPSIS
Quick smoke test to verify the SDK works correctly.
.DESCRIPTION
Tests the SDK by building the local test project and verifying
that the PowerShell scripts are executed with correct environment variables.
.EXAMPLE
./test-smoke.ps1
#>
[CmdletBinding()]
param()
$ErrorActionPreference = 'Stop'
$scriptDir = $PSScriptRoot
Write-Host ""
Write-Host "========================================"
Write-Host "Smoke Test: DevPossible.PwshProject.Sdk"
Write-Host "========================================"
Write-Host ""
# ============================================================================
# Test Local SDK Import
# ============================================================================
Write-Host "Testing local SDK import..." -ForegroundColor Cyan
$testProjectPath = Join-Path $scriptDir 'tests\DevPossible.PwshProject.Tests\TestProject.Local.psproj'
if (-not (Test-Path $testProjectPath)) {
throw "Test project not found: $testProjectPath"
}
# ============================================================================
# Test Build
# ============================================================================
Write-Host ""
Write-Host "Testing Build target..." -ForegroundColor Cyan
Write-Host "-" * 60
Push-Location (Split-Path $testProjectPath -Parent)
try {
& dotnet msbuild TestProject.Local.psproj /t:Build /p:Configuration=Debug /v:minimal
if ($LASTEXITCODE -ne 0) {
throw "Build failed with exit code $LASTEXITCODE"
}
# Verify output was created (output is relative to test project directory)
$testDir = Split-Path $testProjectPath -Parent
$outDir = Join-Path $testDir 'bin\Debug\'
$markerFile = Join-Path $outDir 'test-build-output.json'
if (-not (Test-Path $markerFile)) {
throw "Build output not found: $markerFile"
}
Write-Host ""
Write-Host "Build output verified: $markerFile" -ForegroundColor Green
}
finally {
Pop-Location
}
# ============================================================================
# Test Clean
# ============================================================================
Write-Host ""
Write-Host "Testing Clean target..." -ForegroundColor Cyan
Write-Host "-" * 60
Push-Location (Split-Path $testProjectPath -Parent)
try {
& dotnet msbuild TestProject.Local.psproj /t:Clean /p:Configuration=Debug /v:minimal
if ($LASTEXITCODE -ne 0) {
throw "Clean failed with exit code $LASTEXITCODE"
}
# Verify output was removed
$testDir = Split-Path $testProjectPath -Parent
$outDir = Join-Path $testDir 'bin\Debug\'
if (Test-Path $outDir) {
throw "Clean did not remove output directory: $outDir"
}
Write-Host ""
Write-Host "Clean verified - output directory removed" -ForegroundColor Green
}
finally {
Pop-Location
}
# ============================================================================
# Test Rebuild
# ============================================================================
Write-Host ""
Write-Host "Testing Rebuild target..." -ForegroundColor Cyan
Write-Host "-" * 60
Push-Location (Split-Path $testProjectPath -Parent)
try {
& dotnet msbuild TestProject.Local.psproj /t:Rebuild /p:Configuration=Debug /v:minimal
if ($LASTEXITCODE -ne 0) {
throw "Rebuild failed with exit code $LASTEXITCODE"
}
Write-Host ""
Write-Host "Rebuild completed successfully" -ForegroundColor Green
}
finally {
Pop-Location
}
# ============================================================================
# Test Publish
# ============================================================================
Write-Host ""
Write-Host "Testing Publish target..." -ForegroundColor Cyan
Write-Host "-" * 60
Push-Location (Split-Path $testProjectPath -Parent)
try {
& dotnet msbuild TestProject.Local.psproj /t:Publish /p:Configuration=Release /v:minimal
if ($LASTEXITCODE -ne 0) {
throw "Publish failed with exit code $LASTEXITCODE"
}
# Verify publish output (publish is relative to test project directory)
$testDir = Split-Path $testProjectPath -Parent
$publishDir = Join-Path $testDir 'bin\publish\Release\'
$manifestFile = Join-Path $publishDir 'publish-manifest.json'
if (-not (Test-Path $manifestFile)) {
throw "Publish output not found: $manifestFile"
}
Write-Host ""
Write-Host "Publish output verified: $manifestFile" -ForegroundColor Green
}
finally {
Pop-Location
}
# ============================================================================
# Summary
# ============================================================================
Write-Host ""
Write-Host "========================================"
Write-Host "All Smoke Tests Passed!" -ForegroundColor Green
Write-Host "========================================"
Write-Host ""
Write-Host "Tested targets:"
Write-Host " [PASS] Build" -ForegroundColor Green
Write-Host " [PASS] Clean" -ForegroundColor Green
Write-Host " [PASS] Rebuild" -ForegroundColor Green
Write-Host " [PASS] Publish" -ForegroundColor Green
Write-Host ""