parent
f8640d4ee7
commit
21ab76dbd3
6 changed files with 428 additions and 188 deletions
|
|
@ -23,5 +23,8 @@
|
|||
<None Include="../../common/Common.props" Pack="true" PackagePath="common/Common.props" />
|
||||
<None Include="../../common/Common.targets" Pack="true" PackagePath="common/Common.targets" />
|
||||
<None Include="../../configuration/**/*" Pack="true" PackagePath="configuration/%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<None Include="extensions/TestingPlatformExtensions.props" Pack="true" PackagePath="Sdk/TestingPlatformExtensions.props" />
|
||||
<None Include="extensions/TestingPlatformExtensions.targets" Pack="true" PackagePath="Sdk/TestingPlatformExtensions.targets" />
|
||||
<None Include="extensions/TestingPlatformExtensions.cs" Pack="true" PackagePath="common/source/TestingPlatformExtensions.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -14,4 +14,6 @@
|
|||
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)../configuration/Geekeey.Arcade.NET.Sdk.Test.editorconfig" />
|
||||
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)../configuration/Geekeey.Arcade.NET.FileBasedProgram.editorconfig" Condition="'$(FileBasedProgram)' == 'true'" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)TestingPlatformExtensions.props" />
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
<Project>
|
||||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition="'$(_MustImportMicrosoftNETSdk)' == 'true'" />
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)TestingPlatformExtensions.targets" />
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
// <auto-generated>
|
||||
// This file is generated into the test project by Geekeey.Arcade.NET.Sdk.Test.
|
||||
// </auto-generated>
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable TPEXP
|
||||
|
||||
using Microsoft.Testing.Platform.Builder;
|
||||
using Microsoft.Testing.Platform.CommandLine;
|
||||
using Microsoft.Testing.Platform.Configurations;
|
||||
|
||||
namespace Geekeey.Arcade.NET.Sdk.Test;
|
||||
|
||||
public static class TestingPlatformExtensions
|
||||
{
|
||||
public static void AddExtensions(ITestApplicationBuilder builder, string[] arguments)
|
||||
{
|
||||
builder.Configuration.AddConfigurationSource(() => new ResultDirectoryConfigurationSource());
|
||||
}
|
||||
|
||||
public static class TestingPlatformBuilderHook
|
||||
{
|
||||
public static void AddExtensions(ITestApplicationBuilder builder, string[] arguments)
|
||||
=> TestingPlatformExtensions.AddExtensions(builder, arguments);
|
||||
}
|
||||
|
||||
private sealed class ResultDirectoryConfigurationSource : IConfigurationSource
|
||||
{
|
||||
public string Uid => "Geekeey.Arcade.NET.Sdk.Test.TestingPlatformExtensions";
|
||||
public string Version => "1.0.0";
|
||||
public string DisplayName => "Geekeey Arcade Testing Platform extensions";
|
||||
public string Description => "Uses the artifacts directory for test results by default.";
|
||||
|
||||
public Task<bool> IsEnabledAsync() => Task.FromResult(true);
|
||||
|
||||
public int Order => 4;
|
||||
|
||||
public Task<IConfigurationProvider> BuildAsync(CommandLineParseResult commandLineParseResult)
|
||||
=> Task.FromResult<IConfigurationProvider>(new ResultDirectoryConfigurationProvider());
|
||||
}
|
||||
|
||||
private sealed class ResultDirectoryConfigurationProvider : IConfigurationProvider
|
||||
{
|
||||
public Task LoadAsync() => Task.CompletedTask;
|
||||
|
||||
public bool TryGet(string key, out string? value)
|
||||
{
|
||||
if (string.Equals(key, "platformOptions:resultDirectory", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
value = @"__ARTIFACTS_PATH__";
|
||||
return true;
|
||||
}
|
||||
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<Project>
|
||||
<!-- Register the SDK's Testing Platform extensions with MTP's generated entry point. -->
|
||||
<ItemGroup Condition="'$(IsTestProject)' == 'true' and '$(Language)' == 'C#' and '$(ArtifactsPath)' != ''">
|
||||
<TestingPlatformBuilderHook Include="D7E9E4C8-5F8A-4D0D-9C0E-9C3D0A5B2A11">
|
||||
<DisplayName>Geekeey Arcade Testing Platform extensions</DisplayName>
|
||||
<TypeFullName>Geekeey.Arcade.NET.Sdk.Test.TestingPlatformExtensions.TestingPlatformBuilderHook</TypeFullName>
|
||||
</TestingPlatformBuilderHook>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<_ArcadeTestingPlatformExtensionsSourcePath>$(MSBuildThisFileDirectory)../common/source/TestingPlatformExtensions.cs</_ArcadeTestingPlatformExtensionsSourcePath>
|
||||
<_ArcadeTestingPlatformExtensionsGeneratedPath>$(IntermediateOutputPath)TestingPlatformExtensions.g.cs</_ArcadeTestingPlatformExtensionsGeneratedPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="_GenerateArcadeTestingPlatformExtensions" BeforeTargets="CoreCompile"
|
||||
Inputs="$(_ArcadeTestingPlatformExtensionsSourcePath)" Outputs="$(_ArcadeTestingPlatformExtensionsGeneratedPath)"
|
||||
Condition="'$(Language)' == 'C#' and '$(ArtifactsPath)' != ''">
|
||||
<ReadLinesFromFile File="$(_ArcadeTestingPlatformExtensionsSourcePath)">
|
||||
<Output TaskParameter="Lines" ItemName="_ArcadeTestingPlatformExtensionsSourceLine" />
|
||||
</ReadLinesFromFile>
|
||||
<ItemGroup>
|
||||
<_ArcadeTestingPlatformExtensionsSourceLineWithPath Include="@(_ArcadeTestingPlatformExtensionsSourceLine->Replace('__ARTIFACTS_PATH__', '$(ArtifactsPath)'))" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile
|
||||
File="$(_ArcadeTestingPlatformExtensionsGeneratedPath)"
|
||||
Lines="@(_ArcadeTestingPlatformExtensionsSourceLineWithPath)"
|
||||
Overwrite="true"
|
||||
WriteOnlyWhenDifferent="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_IncludeArcadeTestingPlatformExtensions" BeforeTargets="CoreCompile"
|
||||
DependsOnTargets="_GenerateArcadeTestingPlatformExtensions"
|
||||
Condition="'$(Language)' == 'C#' and '$(ArtifactsPath)' != ''">
|
||||
<ItemGroup>
|
||||
<Compile Remove="**/TestingPlatformExtensions.g.cs" />
|
||||
<FileWrites Include="$(_ArcadeTestingPlatformExtensionsGeneratedPath)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
Loading…
Reference in a new issue