Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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"
$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
Loading