Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
71b26d7
Add docs for Microsoft.Testing.Platform integration
sheddy123 Aug 7, 2026
8918420
Add InternalsVisibleTo for TestAdapter.TestingPlatform
sheddy123 Aug 7, 2026
3dd5796
Remove GetUnrandomizedJobDisplayInfo method
sheddy123 Aug 7, 2026
695ee48
Add BenchmarkCaseIdentityExtensions for stable job IDs
sheddy123 Aug 7, 2026
770bd0d
Refactor benchmark extraction into reusable method
sheddy123 Aug 7, 2026
0fa20cd
Integrate BenchmarkDotNet with Microsoft.Testing.Platform
sheddy123 Aug 7, 2026
a97a8f1
Add AsyncWorkQueue for async work item processing
sheddy123 Aug 7, 2026
ff50c12
Add BenchmarkDotNet.TestAdapter.TestingPlatform project
sheddy123 Aug 7, 2026
46e4df0
Add BenchmarkDotNetExtension for platform integration
sheddy123 Aug 7, 2026
2a004cc
Add BenchmarkEventProcessor for test node event handling
sheddy123 Aug 7, 2026
76fd7da
Add BenchmarkTestFramework for test discovery/execution
sheddy123 Aug 7, 2026
aeba977
Add BenchmarkTestNode for test platform integration
sheddy123 Aug 7, 2026
d080886
Add OutputDeviceLogger to forward logs to output device
sheddy123 Aug 7, 2026
d155fac
Add extension methods to register BenchmarkDotNet as test framework
sheddy123 Aug 7, 2026
41e2099
Add TestingPlatformBuilderHook for BenchmarkDotNet integration
sheddy123 Aug 7, 2026
e7fb119
Add test runner config to global.json
sheddy123 Aug 7, 2026
9838f57
Add IntegrationTests.TestingPlatform project for net10.0
sheddy123 Aug 7, 2026
b84f3b8
Add SampleBenchmarks for fast in-process BDN testing
sheddy123 Aug 7, 2026
d5d3c0b
Add TestingPlatform projects and update test build configs
sheddy123 Aug 7, 2026
a14552f
Merge branch 'master' into feature/mtp-test-adapter-2803
sheddy123 Aug 12, 2026
f420e45
Update slnx to exclude two projects from Debug build
sheddy123 Aug 12, 2026
61ce3f1
Update docs, namespaces, and add GetBenchmarkUid method
sheddy123 Aug 15, 2026
4a27390
Remove BenchmarkDotNet.TestAdapter.TestingPlatform project
sheddy123 Aug 15, 2026
e544444
Integrate BenchmarkDotNet with Microsoft.Testing.Platform
sheddy123 Aug 15, 2026
7da9979
Add AsyncWorkQueue for ordered async work processing
sheddy123 Aug 15, 2026
2d945bf
Add BenchmarkDotNet.TestingPlatform integration
sheddy123 Aug 15, 2026
2158052
Update project references to TestingPlatform project
sheddy123 Aug 15, 2026
6777165
Refactor solution file project entries
sheddy123 Aug 15, 2026
8396103
Update props packaging and cSpell dictionary
sheddy123 Aug 15, 2026
cd523d5
Add generic benchmark for closed generic type testing
sheddy123 Aug 16, 2026
9f2cacb
Handle benchmark UID collisions during discovery/run
sheddy123 Aug 16, 2026
539cc5b
Adjust whitespace around [PublicAPI] attribute
sheddy123 Aug 16, 2026
f5af28f
Remove AsyncWorkQueue and related async queue logic
sheddy123 Aug 16, 2026
fc1a8da
Refactor to use ChannelWriter for log task queuing
sheddy123 Aug 16, 2026
52d46c7
Replace AsyncWorkQueue with Channel for event processing
sheddy123 Aug 16, 2026
b975930
Merge branch 'master' into feature/mtp-test-adapter-2803
sheddy123 Aug 16, 2026
8b4492e
Switch to GetUniqueId for benchmark case identification
sheddy123 Aug 16, 2026
9f32980
Move TestingPlatform config to .targets; cleanup props/csproj
sheddy123 Aug 16, 2026
1f73e5b
Update docs for new TestAdapter and MTP integration
sheddy123 Aug 16, 2026
68be1e2
Update namespaces and extension UID for adapter alignment
sheddy123 Aug 16, 2026
9deb942
Manually import TestAdapter build files in sample projects
sheddy123 Aug 16, 2026
9c81559
Update project to use BenchmarkDotNet.TestAdapter
sheddy123 Aug 16, 2026
8b128f5
Update packaging and entry point logic for test adapter
sheddy123 Aug 16, 2026
bd91fe3
Remove BenchmarkDotNet.TestingPlatform project
sheddy123 Aug 16, 2026
fe3143e
Simplify project entry in BenchmarkDotNet.slnx
sheddy123 Aug 22, 2026
857dc66
Update assistant introduction message
sheddy123 Aug 22, 2026
580eb35
Refactor method display name handling in BenchmarkDotNet
sheddy123 Aug 22, 2026
5311e65
Add DescribedProbe benchmark class with custom config
sheddy123 Aug 22, 2026
fdeac60
Add BenchmarkDotNet.IntegrationTests.TestingPlatform to tests
sheddy123 Aug 30, 2026
b6e386d
Format: Re-add InternalsVisibleTo line without changes
sheddy123 Aug 30, 2026
32a3793
Improve MSBuild property logic in TestAdapter.targets
sheddy123 Aug 30, 2026
cbaa04f
Clarify XML doc for --treenode-filter option
sheddy123 Aug 30, 2026
27294a8
Ensure thread-safe build completion in BenchmarkEventProcessor
sheddy123 Aug 30, 2026
6dc7429
Clarify XML doc: correct CLI arg to --treenode-filter
sheddy123 Aug 30, 2026
eb40140
Clarify comment to reference --treenode-filter option
sheddy123 Aug 30, 2026
5ff83aa
Add smoke test step for BenchmarkDotNet.TestAdapter
sheddy123 Aug 31, 2026
7a32578
Add sample consumer project for BenchmarkDotNet.TestAdapter
sheddy123 Aug 31, 2026
f1b10de
Add .csproj for TestingPlatform.Failures integration tests
sheddy123 Aug 31, 2026
5ff52b2
Add SeparatorProbe benchmark with FastConfig setup
sheddy123 Aug 31, 2026
53c3d60
Add BuildFailureProbe for build failure testing
sheddy123 Aug 31, 2026
c30b2ce
Add CollisionProbe test for parameter collision handling
sheddy123 Aug 31, 2026
8b4994e
Add OutOfProcessProbe for out-of-process benchmark test
sheddy123 Aug 31, 2026
09485e9
Add conditional refs for TestingPlatform probe projects
sheddy123 Aug 31, 2026
22759aa
Add TestingPlatformAdapterTests for integration testing
sheddy123 Aug 31, 2026
af7c019
Escape '/' as '%2F' in BenchmarkTestNode parameters
sheddy123 Aug 31, 2026
ba88cc9
Document percent-encoding in filter path
sheddy123 Aug 31, 2026
61fa92e
Add smoke test script for BenchmarkDotNet.TestAdapter
sheddy123 Aug 31, 2026
8745d4a
Enable optimizations in project file for benchmarks
sheddy123 Aug 31, 2026
3ad8984
Document TestingPlatform.Failures project in README
sheddy123 Aug 31, 2026
67c9996
Add Failures test project to BenchmarkDotNet.slnx
sheddy123 Aug 31, 2026
28d34f3
Clarify comment on IsTestingPlatformApplication logic
sheddy123 Sep 5, 2026
8a0c01f
Add CategoryProbe and DisposableProbe benchmark tests
sheddy123 Sep 5, 2026
4c1de8a
Add tests for categories, disposal, and UID collisions
sheddy123 Sep 5, 2026
0f21efe
Add test for benchmark description/name collision
sheddy123 Sep 5, 2026
3d57bdc
Refactor benchmark logic; fix artifact packing
sheddy123 Sep 5, 2026
ee28724
Merge branch 'master' into feature/mtp-test-adapter-2803
sheddy123 Sep 5, 2026
619b92c
Adapt BuildFailureProbe to the abstract Toolchain base
sheddy123 Sep 6, 2026
701d023
Improve restore process and error handling in test adapter
sheddy123 Sep 7, 2026
a9e3474
Refactor generic benchmark type handling and errors
sheddy123 Sep 7, 2026
1f38c14
Add unoptimized test project for parameter disposal checks
sheddy123 Sep 7, 2026
63beac2
Remove obsolete AppDomain remoting wrappers
sheddy123 Sep 7, 2026
35b58a9
Add wrappers for cross-AppDomain VSTest communication
sheddy123 Sep 7, 2026
6d78297
Add unoptimized probe & enhance benchmark discovery tests
sheddy123 Sep 7, 2026
6eb5889
Refactor disposal logic, improve display names & ECMA names
sheddy123 Sep 7, 2026
0280c3f
Add probes for special params, invalid configs, and nesting
sheddy123 Sep 7, 2026
24ecc1f
Remove all contents from LoggerHelper.cs and TestCaseFilter.cs
sheddy123 Sep 7, 2026
424d848
Add VSTest adapter integration for BenchmarkDotNet
sheddy123 Sep 7, 2026
ee4516b
Refactor adapter: improve disposal, remove legacy files
sheddy123 Sep 7, 2026
55f5b6d
Improve test infra: new project, docs, and validation
sheddy123 Sep 7, 2026
4bb808e
Merge remote-tracking branch 'upstream/master' into feature/mtp-test-…
sheddy123 Sep 8, 2026
3b61b93
Add IsUnreadable to GenericBenchmarkType and update builder
sheddy123 Sep 8, 2026
18685fe
Add server mode session class and expand adapter tests
sheddy123 Sep 8, 2026
12a9e36
Add AsyncDisposableProbe and improve Tracked disposal logic
sheddy123 Sep 8, 2026
c9e6359
Improve error handling for unreadable configs in tests
sheddy123 Sep 8, 2026
55bfa5a
Improve error handling in TypeFilter AddRunnable logic
sheddy123 Sep 8, 2026
954717f
Exclude unreadable builds from validation errors
sheddy123 Sep 8, 2026
9a69f40
Add ParameterValueLifetime for safe parameter disposal
sheddy123 Sep 8, 2026
c3addfb
Add async disposal for benchmark parameters
sheddy123 Sep 8, 2026
bcd4e20
Clarify IsUnreadable XML doc comment
sheddy123 Sep 9, 2026
0b2f49d
Refactor benchmark type collection logic in GetTypesWithRunnableBench…
sheddy123 Sep 9, 2026
1e681a2
Improve parameter value lifetime management in BDN runs
sheddy123 Sep 9, 2026
48faefa
Improve test disposal checks, add discoverAgain option
sheddy123 Sep 9, 2026
acb489a
Improve TypeFilterTests for unreadable attribute scenarios
sheddy123 Sep 9, 2026
d1fef31
Report all unsuccessful benchmarks as validation errors
sheddy123 Sep 9, 2026
51e4960
Add FreshValueProbe benchmark for per-read resource tests
sheddy123 Sep 9, 2026
acdbf33
Improve error handling and deduplication in BenchmarkRunner
sheddy123 Sep 10, 2026
44c0597
Add test for validation warnings; extend ServerNode output
sheddy123 Sep 10, 2026
aed3f0b
Refactor parameter value lifetime with RequestScope
sheddy123 Sep 10, 2026
204c68d
Simplify cleanup logic and ensure resource disposal
sheddy123 Sep 10, 2026
69d84f8
Enable internals access for integration test assembly
sheddy123 Sep 12, 2026
9bca8ae
Improve error reporting and resource disposal logic
sheddy123 Sep 12, 2026
928dd0f
Enhance test coverage and internals probe support
sheddy123 Sep 12, 2026
0f83c8e
Add BenchmarkDotNet.IntegrationTests.TestingPlatform.Internals
sheddy123 Sep 12, 2026
fd51095
Add Internals project to BenchmarkDotNet.slnx
sheddy123 Sep 12, 2026
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
4 changes: 4 additions & 0 deletions .github/workflows/run-tests-selected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ on:
- tests/BenchmarkDotNet.IntegrationTests
- tests/BenchmarkDotNet.IntegrationTests.ManualRunning
- tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks
# This one is a Microsoft.Testing.Platform application. It carries the `global.json` which routes
# `dotnet test` to the platform, and that file is resolved from the working directory, which this
# workflow sets to the project.
- tests/BenchmarkDotNet.IntegrationTests.TestingPlatform
- samples/BenchmarkDotNet.Samples
framework:
type: choice
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ jobs:
- uses: actions/checkout@v7
- name: Run task 'pack'
run: ./build.cmd pack
# Nothing in the solution consumes BenchmarkDotNet.TestAdapter as a package, so nothing else exercises the
# order in which NuGet imports its build files relative to Microsoft.Testing.Platform.MSBuild's.
- name: Smoke test the packed BenchmarkDotNet.TestAdapter
shell: pwsh
run: ./build/smoke-tests/test-adapter-consumer.ps1

spellcheck-docs:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Resource.designer.cs
# Tests
TestResults

# The smoke test restores BenchmarkDotNet.TestAdapter into a packages folder of its own, see its .csproj
build/smoke-tests/packages/

## Mac OS

# General
Expand Down
4 changes: 4 additions & 0 deletions BenchmarkDotNet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<Project Path="tests/BenchmarkDotNet.IntegrationTests.WasmBenchmarks/BenchmarkDotNet.IntegrationTests.WasmBenchmarks.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.SharedDiagnosers/BenchmarkDotNet.IntegrationTests.SharedDiagnosers.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.TestingPlatform/BenchmarkDotNet.IntegrationTests.TestingPlatform.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.TestingPlatform.Failures/BenchmarkDotNet.IntegrationTests.TestingPlatform.Failures.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.TestingPlatform.Internals/BenchmarkDotNet.IntegrationTests.TestingPlatform.Internals.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.TestingPlatform.Unoptimized/BenchmarkDotNet.IntegrationTests.TestingPlatform.Unoptimized.csproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj" />
<Project Path="tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj" />
<Project Path="tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj" />
Expand Down
1 change: 1 addition & 0 deletions build/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"vsprofiler",
"vstest",
"Tailcall",
"testadapter",
"toolchains",
"unmanaged"
],
Expand Down
22 changes: 22 additions & 0 deletions build/smoke-tests/TestAdapterConsumer/ConsumedBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.InProcess.Emit;

namespace TestAdapterConsumer;

/// <summary>
/// A single benchmark, enough for the smoke test to check that the packaged adapter turns this project into a
/// Microsoft.Testing.Platform application that can list it.
/// </summary>
[Config(typeof(FastConfig))]
public class ConsumedBenchmark
{
[Benchmark]
public int Add() => 1 + 1;

private class FastConfig : ManualConfig
{
public FastConfig() => AddJob(Job.Dry.WithToolchain(InProcessEmitToolchain.Default));
}
}
43 changes: 43 additions & 0 deletions build/smoke-tests/TestAdapterConsumer/TestAdapterConsumer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
Consumes BenchmarkDotNet.TestAdapter the way a real user does: as a NuGet package. That is the whole point of this
project, so it deliberately references nothing from this repository and is not part of BenchmarkDotNet.slnx - the
package it needs only exists after `build.cmd pack`, and an in-repo <Import> or ProjectReference would bring the
adapter's build files in before Microsoft.Testing.Platform.MSBuild's, which is the reverse of the packaged order.

Driven by build/smoke-tests/test-adapter-consumer.ps1.
-->

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!--
The nupkg is produced into the repository's artifacts folder by `build.cmd pack`. The script passes this as a
global property as well, which wins over this assignment, so that a custom -ArtifactsDirectory is honoured.
-->
<RestoreAdditionalProjectSources>$(MSBuildThisFileDirectory)..\..\..\artifacts</RestoreAdditionalProjectSources>
Comment thread
timcassell marked this conversation as resolved.
<!--
Restore into a folder of this tree's own rather than into the shared global packages folder. The version never
changes between runs - it is `0.16.0-develop`, or `0.16.0-ci` under BDN_CI_BUILD - and NuGet skips extracting a
version it has already extracted, however much newer the .nupkg in artifacts is. A fresh CI agent would never
notice, but anyone iterating on the props and targets this test exists to guard would be testing the first
package they ever packed. Restoring here gives the script a folder it knows the path of, so that it can drop
the packages this repository produces before every run instead of guessing where the global folder is.

It sits next to this project rather than inside it: the SDK globs **\*.cs under the project directory, and the
package carries an entrypoints\EntryPoint.cs which would then be compiled into the consumer - its synchronous
Main wins over the async one Microsoft.Testing.Platform.MSBuild generates (CS8892), and the application turns
back into a plain BenchmarkSwitcher console app.
-->
<RestorePackagesPath>$(MSBuildThisFileDirectory)..\packages\</RestorePackagesPath>
</PropertyGroup>

<ItemGroup>
<!-- The version is passed in by the script, which reads it off the packed file name. -->
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="$(BenchmarkDotNetVersion)" />
</ItemGroup>

</Project>
147 changes: 147 additions & 0 deletions build/smoke-tests/test-adapter-consumer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env pwsh

<#
.SYNOPSIS
Smoke tests the packed BenchmarkDotNet.TestAdapter against a project that consumes it as a NuGet package.

.DESCRIPTION
Everything in this repository that uses the adapter's build files imports them by path from the project file,
which MSBuild evaluates before nuget.g.targets. A package consumer gets the opposite order: NuGet imports
Microsoft.Testing.Platform.MSBuild's targets, which default IsTestingPlatformApplication to true, and only then
the adapter's, which have to overwrite that default for the opt-outs to work. Nothing in the solution can
reproduce that order, so this restores the real package and asserts on how the properties resolve.

Run `build.cmd pack` first, so that the packages exist.

.PARAMETER ArtifactsDirectory
The directory `build.cmd pack` wrote the packages to.

.PARAMETER Configuration
The configuration to build the consuming project in.
#>

[CmdletBinding()]
param(
[string] $ArtifactsDirectory = [System.IO.Path]::Combine($PSScriptRoot, '..', '..', 'artifacts'),
[string] $Configuration = 'Release'
)

$ErrorActionPreference = 'Stop'

# Invoke-Dotnet checks $LASTEXITCODE itself, and prints the log before it throws. Leaving this on would make a failing
# `dotnet` throw at the call itself on PowerShell Core - which is what the workflow runs - so the log would never be
# printed and a broken restore or build would report nothing at all.
$PSNativeCommandUseErrorActionPreference = $false

$project = [System.IO.Path]::Combine($PSScriptRoot, 'TestAdapterConsumer', 'TestAdapterConsumer.csproj')
$targetFramework = 'net10.0'

# $IsWindows only exists on PowerShell Core, where it is the only way to tell; Windows PowerShell is Windows by definition.
$onWindows = ($null -eq $IsWindows) -or $IsWindows

# build.cmd installs the SDK the repository is pinned to into .dotnet, and only puts it on PATH for its own run.
$dotnet = [System.IO.Path]::Combine($PSScriptRoot, '..', '..', '.dotnet', $(if ($onWindows) { 'dotnet.exe' } else { 'dotnet' }))
if (-not (Test-Path $dotnet)) {
$dotnet = 'dotnet'
}

if (-not (Test-Path -LiteralPath $ArtifactsDirectory)) {
throw "The artifacts directory '$ArtifactsDirectory' does not exist. Run 'build.cmd pack' first."
}

# Both the package this reads the version from and the source the restore below resolves it through, so it has to be
# the same absolute path in both: a relative one would otherwise be resolved against the consuming project.
$ArtifactsDirectory = (Resolve-Path -LiteralPath $ArtifactsDirectory).ProviderPath

# `build.cmd pack` never cleans, so the folder can hold several versions. The newest is the one that was just packed,
# which is the one worth smoke testing.
$packages = @(Get-ChildItem -Path $ArtifactsDirectory -Filter 'BenchmarkDotNet.TestAdapter.*.nupkg' |
Where-Object { $_.Name -notlike '*.symbols.nupkg' } |
Sort-Object -Property LastWriteTime -Descending)

if ($packages.Count -eq 0) {
throw "No BenchmarkDotNet.TestAdapter package was found in '$ArtifactsDirectory'. Run 'build.cmd pack' first."
}

$package = $packages[0]

if ($packages.Count -gt 1) {
Write-Output "'$ArtifactsDirectory' holds $($packages.Count) BenchmarkDotNet.TestAdapter packages, taking the most recently written one."
}

$version = $package.BaseName -replace '^BenchmarkDotNet\.TestAdapter\.', ''
Write-Output "Consuming BenchmarkDotNet.TestAdapter $version from $ArtifactsDirectory"

function Invoke-Dotnet {
param([Parameter(ValueFromRemainingArguments = $true)] [string[]] $Arguments)

$output = & $dotnet @Arguments 2>&1 | Out-String

if ($LASTEXITCODE -ne 0) {
Write-Output $output
throw "'dotnet $($Arguments -join ' ')' failed with exit code $LASTEXITCODE."
}

return $output
}

function Assert-Property {
param(
[string] $Name,
[string] $Expected,
[string[]] $With = @()
)

$arguments = @($project, '-nologo', '-tl:off', "-p:BenchmarkDotNetVersion=$version", "-p:Configuration=$Configuration") + $With + @("-getProperty:$Name")
$actual = (Invoke-Dotnet msbuild @arguments).Trim()

$description = if ($With.Count -eq 0) { 'by default' } else { "with $($With -join ' ')" }

if ($actual -ne $Expected) {
throw "Expected $Name to be '$Expected' $description, but it was '$actual'."
}

Write-Output " OK: $Name is '$Expected' $description"
}

# The project restores into this folder rather than into the global one, see its .csproj. NuGet never re-extracts a
# version it already has, and the version does not change between runs, so the packages this repository produces are
# dropped before the restore; everything else in there is an ordinary cache and is left alone.
$packagesDirectory = [System.IO.Path]::Combine($PSScriptRoot, 'packages')
if (Test-Path -LiteralPath $packagesDirectory) {
Get-ChildItem -Path $packagesDirectory -Directory -Filter 'benchmarkdotnet*' | Remove-Item -Recurse -Force
}

Write-Output '##[group]Restoring the consuming project'
# The project assigns RestoreAdditionalProjectSources too, but a global property wins over that assignment, which is
# what makes a custom -ArtifactsDirectory restore from the folder the version was read off. Only the restore needs it:
# nuget.g.props bakes the result in for every later invocation.
Invoke-Dotnet restore $project "-p:BenchmarkDotNetVersion=$version" `
"-p:RestoreAdditionalProjectSources=$ArtifactsDirectory" '-tl:off' | Write-Output
Write-Output '##[endgroup]'

Write-Output 'Checking how the packaged build files resolve the test platform:'

# Microsoft.Testing.Platform is the default, and the adapter leaves the entry point to it.
Assert-Property -Name 'IsTestingPlatformApplication' -Expected 'true'
Assert-Property -Name 'GenerateProgramFile' -Expected 'false'

# The two opt-outs have to win over the default Microsoft.Testing.Platform.MSBuild sets in its own targets, which a
# package consumer imports before the adapter's.
Assert-Property -Name 'IsTestingPlatformApplication' -Expected 'false' -With '-p:BenchmarkDotNetUseVSTest=true'
Assert-Property -Name 'IsTestingPlatformApplication' -Expected 'false' -With '-p:GenerateProgramFile=false'

Write-Output '##[group]Building the consuming project'
Invoke-Dotnet build $project '--no-restore' '-c' $Configuration "-p:BenchmarkDotNetVersion=$version" '-tl:off' | Write-Output
Write-Output '##[endgroup]'

Write-Output 'Listing the benchmarks through the entry point Microsoft.Testing.Platform generated:'
$application = [System.IO.Path]::Combine($PSScriptRoot, 'TestAdapterConsumer', 'bin', $Configuration, $targetFramework, 'TestAdapterConsumer.dll')
$listed = Invoke-Dotnet $application '--list-tests' '--no-ansi'
Write-Output $listed

if ($listed -notmatch 'TestAdapterConsumer\.ConsumedBenchmark\.Add') {
throw 'The packaged adapter did not list the benchmark of the consuming project.'
}

Write-Output 'The packaged BenchmarkDotNet.TestAdapter behaves as expected.'
Loading
Loading