Skip to content

Commit 2310f2b

Browse files
Build tests for test templates via a pipeline to support CG (#49147)
Co-authored-by: Copilot <[email protected]>
1 parent b31c7fc commit 2310f2b

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

build/RunTestTemplateTests.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<#
2+
.SYNOPSIS
3+
Runs Microsoft.TestTemplates.Acceptance.Tests.dll in the dogfood environment.
4+
.DESCRIPTION
5+
This script enters the dogfood environment and runs the RunTestTemplateTests tests.
6+
#>
7+
[CmdletBinding(PositionalBinding=$false)]
8+
Param(
9+
[string] $configuration = "Release"
10+
)
11+
12+
function Run-TestTemplateTests {
13+
$ErrorActionPreference = 'Stop'
14+
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
15+
$classNameFilter = "--filter"
16+
$filterValue = "FullyQualifiedName~Microsoft.DotNet.Cli.New.IntegrationTests.DotnetNewTestTemplatesTests"
17+
$TestDll = Join-Path $RepoRoot "artifacts\bin\dotnet-new.IntegrationTests\$configuration\dotnet-new.IntegrationTests.dll"
18+
19+
# Check if the test DLL exists
20+
if (-not (Test-Path $TestDll)) {
21+
Write-Error "Test DLL not found at: $TestDll"
22+
return 1
23+
}
24+
25+
Write-Host "Running tests for test templates in the dogfood environment..." -ForegroundColor Cyan
26+
27+
# Call dogfood.ps1 directly instead of through dogfood.cmd to avoid the -NoExit parameter
28+
$dogfoodPs1 = Join-Path $RepoRoot "eng\dogfood.ps1"
29+
30+
Write-Host "Executing: dotnet test $TestDll via dogfood environment" -ForegroundColor Gray
31+
# Pass the command directly to the dogfood.ps1 script
32+
& $dogfoodPs1 -configuration $configuration -command @("dotnet", "test", $TestDll, $classNameFilter, $filterValue)
33+
34+
$exitCode = $LASTEXITCODE
35+
if ($exitCode -ne 0) {
36+
Write-Error "Tests failed with exit code: $exitCode"
37+
} else {
38+
Write-Host "Tests completed successfully!" -ForegroundColor Green
39+
}
40+
41+
return $exitCode
42+
}
43+
44+
# Execute the function using Invoke-Command
45+
$exitCode = Invoke-Command -ScriptBlock ${function:Run-TestTemplateTests}
46+
exit $exitCode

eng/pipelines/templates/jobs/sdk-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ jobs:
104104
env:
105105
BuildConfig: $(buildConfiguration)
106106
TestFullMSBuild: ${{ parameters.testFullMSBuild }}
107+
108+
- powershell: build/RunTestTemplateTests.ps1
109+
displayName: 🟣 Run Test Templates Tests
110+
107111
- ${{ else }}:
108112
- script: |
109113
source $(Build.SourcesDirectory)/eng/common/native/init-os-and-arch.sh

sdk.sln

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ VisualStudioVersion = 17.1.31903.286
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{50A89C27-BA35-44B2-AC57-E54551791C64}"
66
ProjectSection(SolutionItems) = preProject
7-
eng\cgmanifest.json = eng\cgmanifest.json
87
eng\dogfood.cmd = eng\dogfood.cmd
98
eng\dogfood.sh = eng\dogfood.sh
109
eng\Versions.props = eng\Versions.props
@@ -1208,6 +1207,9 @@ Global
12081207
{D7495CE7-64E5-4715-9304-799A41EC1D71} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
12091208
{8D6A9984-118D-4415-A8FA-AB1F26CF5C44} = {71C279BD-E850-4A8D-9775-11CA26B8E5BA}
12101209
{0CBA5FB8-71A3-457A-89F3-E52B9602164A} = {71C279BD-E850-4A8D-9775-11CA26B8E5BA}
1210+
{3C688B3B-7919-6C9E-93A3-A3F6B3E684A9} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
1211+
{48A69DF9-9233-2548-C614-202D5780014D} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
1212+
{0D36F844-0A1C-469F-93A1-C0E5AD141B07} = {48A69DF9-9233-2548-C614-202D5780014D}
12111213
{21C21975-84C1-4A24-8E21-F7EC790A4584} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
12121214
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
12131215
{94C8526E-DCC2-442F-9868-3DD0BA2688BE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
@@ -1222,9 +1224,6 @@ Global
12221224
{FA3C7F91-42A2-45AD-897C-F646B081016C} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
12231225
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
12241226
{0762B436-F4B0-4008-9097-BB5FF6BD84AF} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
1225-
{3C688B3B-7919-6C9E-93A3-A3F6B3E684A9} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
1226-
{48A69DF9-9233-2548-C614-202D5780014D} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
1227-
{0D36F844-0A1C-469F-93A1-C0E5AD141B07} = {48A69DF9-9233-2548-C614-202D5780014D}
12281227
{8D2921DD-ED7E-68AB-522C-54E23AAAFFCC} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
12291228
{485FC8E4-6776-43E4-AD87-C583BC6136FE} = {8D2921DD-ED7E-68AB-522C-54E23AAAFFCC}
12301229
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}

0 commit comments

Comments
 (0)