-
Notifications
You must be signed in to change notification settings - Fork 169
/
Copy pathTest-Packages.ps1
66 lines (58 loc) · 2.25 KB
/
Test-Packages.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Requires -Version 7.0
param(
[switch] $UnitTests,
[switch] $GenerationChecks,
[string] $Filter = "."
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 3.0
$root = (Resolve-Path "$PSScriptRoot/../..").Path.Replace('\', '/')
. "$root/eng/scripts/CommandInvocation-Helpers.ps1"
Set-ConsoleEncoding
Push-Location $root
try {
if ($UnitTests) {
# check if shared code is up to date
& "$root/eng/scripts/Download-SharedSource.ps1"
try {
Write-Host 'Checking for changes in shared source...'
& "$root/eng/scripts/Check-GitChanges.ps1"
Write-Host 'Done. No shared source differences detected.'
}
catch {
Write-Error 'Shared source files are updated. Please run eng/scripts/Download-SharedSource.ps1'
}
# test the generator
Invoke-LoggedCommand "dotnet test AutoRest.CSharp.sln /bl:artifacts/logs/debug.binlog --logger `"trx;LogFileName=$root/artifacts/test-results/debug.trx`"" -GroupOutput
Invoke-LoggedCommand "dotnet test AutoRest.CSharp.sln -c Release /bl:artifacts/logs/release.binlog --logger `"trx;LogFileName=$root/artifacts/test-results/release.trx`"" -GroupOutput
# test the emitter
Push-Location "$root/src/TypeSpec.Extension/Emitter.Csharp"
try {
Invoke-LoggedCommand "npm run prettier" -GroupOutput
Invoke-LoggedCommand "npm run lint" -GroupOutput
Invoke-LoggedCommand "npm run build" -GroupOutput
Invoke-LoggedCommand "npm run test -- --passWithNoTests" -GroupOutput
}
finally {
Pop-Location
}
}
if ($GenerationChecks) {
Set-StrictMode -Version 1
# run E2E Test for TypeSpec emitter
Write-Host "Generating test projects ..."
& "$root/eng/Generate.ps1" -Filter $Filter -Reset
Write-Host 'Code generation is completed.'
try {
Write-Host 'Checking for differences in generated code...'
& "$root/eng/scripts/Check-GitChanges.ps1"
Write-Host 'Done. No code generation differences detected.'
}
catch {
Write-Error 'Generated code is not up to date. Please run: eng/Generate.ps1'
}
}
}
finally {
Pop-Location
}