Skip to content

Build & run tests for test templates via a pipeline to support CG #49147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions build/RunTestTemplateTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<#
.SYNOPSIS
Runs Microsoft.TestTemplates.Acceptance.Tests.dll in the dogfood environment.
.DESCRIPTION
This script enters the dogfood environment and runs the RunTestTemplateTests tests.
#>
[CmdletBinding(PositionalBinding=$false)]
Param(
[string] $configuration = "Release"
)

function Run-TestTemplateTests {
$ErrorActionPreference = 'Stop'
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
$classNameFilter = "--filter"
$filterValue = "FullyQualifiedName~Microsoft.DotNet.Cli.New.IntegrationTests.DotnetNewTestTemplatesTests"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing tabs and spaces

$TestDll = Join-Path $RepoRoot "artifacts\bin\dotnet-new.IntegrationTests\$configuration\dotnet-new.IntegrationTests.dll"

# Check if the test DLL exists
if (-not (Test-Path $TestDll)) {
Write-Error "Test DLL not found at: $TestDll"
return 1
}

Write-Host "Running tests for test templates in the dogfood environment..." -ForegroundColor Cyan

# Call dogfood.ps1 directly instead of through dogfood.cmd to avoid the -NoExit parameter
$dogfoodPs1 = Join-Path $RepoRoot "eng\dogfood.ps1"

Write-Host "Executing: dotnet test $TestDll via dogfood environment" -ForegroundColor Gray
# Pass the command directly to the dogfood.ps1 script
& $dogfoodPs1 -configuration $configuration -command @("dotnet", "test", $TestDll, $classNameFilter, $filterValue)

$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
Write-Error "Tests failed with exit code: $exitCode"
} else {
Write-Host "Tests completed successfully!" -ForegroundColor Green
}

return $exitCode
}

# Execute the function using Invoke-Command
$exitCode = Invoke-Command -ScriptBlock ${function:Run-TestTemplateTests}
exit $exitCode
4 changes: 4 additions & 0 deletions eng/pipelines/templates/jobs/sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ jobs:
env:
BuildConfig: $(buildConfiguration)
TestFullMSBuild: ${{ parameters.testFullMSBuild }}

- powershell: build/RunTestTemplateTests.ps1
displayName: 🟣 Run Test Templates Tests

- ${{ else }}:
- script: |
source $(Build.SourcesDirectory)/eng/common/native/init-os-and-arch.sh
Expand Down
7 changes: 3 additions & 4 deletions sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ VisualStudioVersion = 17.1.31903.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{50A89C27-BA35-44B2-AC57-E54551791C64}"
ProjectSection(SolutionItems) = preProject
eng\cgmanifest.json = eng\cgmanifest.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it requested to drop the manifest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building and running those test projects is the other way to report our used packages to CG.

eng\dogfood.cmd = eng\dogfood.cmd
eng\dogfood.sh = eng\dogfood.sh
eng\Versions.props = eng\Versions.props
Expand Down Expand Up @@ -1208,6 +1207,9 @@ Global
{D7495CE7-64E5-4715-9304-799A41EC1D71} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
{8D6A9984-118D-4415-A8FA-AB1F26CF5C44} = {71C279BD-E850-4A8D-9775-11CA26B8E5BA}
{0CBA5FB8-71A3-457A-89F3-E52B9602164A} = {71C279BD-E850-4A8D-9775-11CA26B8E5BA}
{3C688B3B-7919-6C9E-93A3-A3F6B3E684A9} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
{48A69DF9-9233-2548-C614-202D5780014D} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
{0D36F844-0A1C-469F-93A1-C0E5AD141B07} = {48A69DF9-9233-2548-C614-202D5780014D}
{21C21975-84C1-4A24-8E21-F7EC790A4584} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{94C8526E-DCC2-442F-9868-3DD0BA2688BE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
Expand All @@ -1222,9 +1224,6 @@ Global
{FA3C7F91-42A2-45AD-897C-F646B081016C} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{3DF5A9B8-6F90-4CFB-4518-0E97982B6748} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{0762B436-F4B0-4008-9097-BB5FF6BD84AF} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
{3C688B3B-7919-6C9E-93A3-A3F6B3E684A9} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
{48A69DF9-9233-2548-C614-202D5780014D} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
{0D36F844-0A1C-469F-93A1-C0E5AD141B07} = {48A69DF9-9233-2548-C614-202D5780014D}
{8D2921DD-ED7E-68AB-522C-54E23AAAFFCC} = {3C688B3B-7919-6C9E-93A3-A3F6B3E684A9}
{485FC8E4-6776-43E4-AD87-C583BC6136FE} = {8D2921DD-ED7E-68AB-522C-54E23AAAFFCC}
{27BBE29B-CE6F-401F-B3CF-B07DC556FAD1} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
Expand Down