Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ jobs:
name: logs-${{ matrix.os }}
path: |
msbuild.binlog
test/**/TestResults/*.log
test/**/TestResults/*.trx
test/**/TestResults/*.html
test/**/TestResults/*.ctrf

- uses: actions/upload-artifact@v4
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}
Expand Down
1 change: 1 addition & 0 deletions docfx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{926A0726-B806-4215-82EF-AF8E22D0FACF}"
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
test\xunit.runner.json = test\xunit.runner.json
test\Directory.Packages.props = test\Directory.Packages.props
EndProjectSection
EndProject
Expand Down
33 changes: 31 additions & 2 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,52 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<PropertyGroup>
<!--
.NET 9 preview 2 or later run tests in parallel by default.
.NET 9 run tests in parallel by default.
It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`.
-->
<TestTfmsInParallel>false</TestTfmsInParallel>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<!-- Enable `Microsoft.Testing.Platform` mode for `dotnet test` -->
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
<TestingPlatformCaptureOutput>true</TestingPlatformCaptureOutput>

<!-- Use `Microsoft.Testing.Platform` entrypoint. -->
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>

<!-- Change TestResults output directory. And enable detailed log outputs -->
<TestingPlatformCommandLineArguments>--results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments>

<!-- Ignore exit code 8 (the test session run zero tests) -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<!-- Settings for CI environment -->
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''">
<!-- Disable progress reports -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments>

<!-- Enable trx/html reporters -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments>

<!-- Settings for VSTest. These settings will be removed in future. -->
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
<VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger>
<VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger>
Expand All @@ -28,6 +57,6 @@
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Markdig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OverwriteDocuments\Docfx.Build.OverwriteDocuments.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Build.Tests/Docfx.Build.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TestData\snippets\dataflowdegreeofparallelism.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/ExtractSearchIndexFromHtmlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ This is article title
manifest.Files.Add(manifestItem);

// process the fake manifest, using tempTestFolder as the output folder
_extractor.Process(manifest, tempTestFolder);
_extractor.Process(manifest, tempTestFolder, TestContext.Current.CancellationToken);

var expectedIndexJSON = @"{
""index.html"": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Docfx.Plugins;
using Docfx.Tests.Common;
using Xunit;
using Xunit.Abstractions;
using DocumentType = Docfx.DataContracts.Common.Constants.DocumentType;

namespace Docfx.Build.Engine.Tests;
Expand Down Expand Up @@ -58,7 +57,7 @@ public void TestSitemapGenerator()
var sitemapPath = Path.Combine(outputFolder, "sitemap.xml");

// Act
manifest = sitemapGenerator.Process(manifest, outputFolder);
manifest = sitemapGenerator.Process(manifest, outputFolder, TestContext.Current.CancellationToken);

// Assert
Assert.Equal("https://example.com/", manifest.Sitemap.BaseUrl);
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/RemoveDebugInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestBasicFeature()
new HtmlPostProcessor
{
Handlers = { new RemoveDebugInfo() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);

var actual = File.ReadAllText(Path.Combine(_outputFolder, "a.html"));
Assert.Equal("<p id='b1'>section<a href='http://bing.com#top'>Microsoft Bing</a></p>", actual);
Expand Down
6 changes: 3 additions & 3 deletions test/Docfx.Build.Tests/ValidateBookmarkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void TestBasicFeature()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public void TestNoCheck()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down Expand Up @@ -150,7 +150,7 @@ public void TestLinkThatContainsNonAsciiChars()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/XRefArchiveBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task TestDownload()
// sorted: true
// references: []
// ```
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile));
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile, TestContext.Current.CancellationToken));

using (var xar = XRefArchive.Open(ZipFile, XRefArchiveMode.Read))
{
Expand Down
14 changes: 7 additions & 7 deletions test/Docfx.Build.Tests/XRefMapDownloaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class XRefMapDownloadTest
public async Task BaseUrlIsSet()
{
var downloader = new XRefMapDownloader();
var xrefs = await downloader.DownloadAsync(new Uri("https://dotnet.github.io/docfx/xrefmap.yml")) as XRefMap;
var xrefs = await downloader.DownloadAsync(new Uri("https://dotnet.github.io/docfx/xrefmap.yml"), TestContext.Current.CancellationToken) as XRefMap;
Assert.NotNull(xrefs);
Assert.Equal("https://dotnet.github.io/docfx/", xrefs.BaseUrl);
}
Expand All @@ -27,7 +27,7 @@ public async Task ReadLocalXRefMapWithFallback()

// Get fallback TestData/xrefmap.yml which contains uid: 'str'
var reader = await new XRefCollection(from u in xrefmaps
select new Uri(u, UriKind.RelativeOrAbsolute)).GetReaderAsync(basePath, fallbackFolders);
select new Uri(u, UriKind.RelativeOrAbsolute)).GetReaderAsync(basePath, fallbackFolders, TestContext.Current.CancellationToken);

var xrefSpec = reader.Find("str");
Assert.NotNull(xrefSpec);
Expand All @@ -41,7 +41,7 @@ public async Task ReadLocalXRefMapJsonFileTest()
var path = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "xrefmap.json");

var downloader = new XRefMapDownloader();
var xrefMap = await downloader.DownloadAsync(new Uri(path)) as XRefMap;
var xrefMap = await downloader.DownloadAsync(new Uri(path), TestContext.Current.CancellationToken) as XRefMap;

// Assert
xrefMap.Should().NotBeNull();
Expand All @@ -55,7 +55,7 @@ public async Task ReadLocalXRefMapGZippedJsonFileTest()
var path = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "xrefmap.json.gz");

var downloader = new XRefMapDownloader();
var xrefMap = await downloader.DownloadAsync(new Uri(path)) as XRefMap;
var xrefMap = await downloader.DownloadAsync(new Uri(path), TestContext.Current.CancellationToken) as XRefMap;

// Assert
xrefMap.Should().NotBeNull();
Expand All @@ -69,7 +69,7 @@ public async Task ReadLocalXRefMapGZippedYamlFileTest()
var path = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "xrefmap.yml.gz");

var downloader = new XRefMapDownloader();
var xrefMap = await downloader.DownloadAsync(new Uri(path)) as XRefMap;
var xrefMap = await downloader.DownloadAsync(new Uri(path), TestContext.Current.CancellationToken) as XRefMap;

// Assert
xrefMap.Should().NotBeNull();
Expand All @@ -86,7 +86,7 @@ public async Task ReadRemoteXRefMapYamlFileTest1()
var path = "https://horizongir.github.io/ZedGraph/xrefmap.yml";

var downloader = new XRefMapDownloader();
var xrefMap = await downloader.DownloadAsync(new Uri(path)) as XRefMap;
var xrefMap = await downloader.DownloadAsync(new Uri(path), TestContext.Current.CancellationToken) as XRefMap;

// Assert
xrefMap.Sorted.Should().BeTrue();
Expand Down Expand Up @@ -115,7 +115,7 @@ public async Task ReadRemoteXRefMapJsonFileTest2()
var path = "https://normanderwan.github.io/UnityXrefMaps/xrefmap.yml";

var downloader = new XRefMapDownloader();
var xrefMap = await downloader.DownloadAsync(new Uri(path)) as XRefMap;
var xrefMap = await downloader.DownloadAsync(new Uri(path), TestContext.Current.CancellationToken) as XRefMap;

// Assert
xrefMap.Sorted.Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Common.Tests/Docfx.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.YamlSerialization\Docfx.YamlSerialization.csproj" />
<ProjectReference Include="..\..\src\Docfx.Plugins\Docfx.Plugins.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Dotnet.Tests/Docfx.Dotnet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<None Include="TestDataReferences\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions test/Docfx.Dotnet.Tests/GenerateMetadataFromAssemblyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void TestGenerateMetadataFromAssembly()
{
{
var (compilation, assembly) = CompilationHelper.CreateCompilationFromAssembly("TestData/CatLibrary.dll");
Assert.Empty(compilation.GetDeclarationDiagnostics());
Assert.Empty(compilation.GetDeclarationDiagnostics(TestContext.Current.CancellationToken));

var output = assembly.GenerateMetadataItem(compilation);
var @class = output.Items[0].Items[2];
Expand All @@ -26,7 +26,7 @@ public void TestGenerateMetadataFromAssembly()

{
var (compilation, assembly) = CompilationHelper.CreateCompilationFromAssembly("TestData/CatLibrary2.dll");
Assert.Empty(compilation.GetDeclarationDiagnostics());
Assert.Empty(compilation.GetDeclarationDiagnostics(TestContext.Current.CancellationToken));

var output = assembly.GenerateMetadataItem(compilation);
var @class = output.Items[0].Items[0];
Expand All @@ -40,7 +40,7 @@ public void TestGenerateMetadataFromAssembly()
public void TestGenerateMetadataFromAssemblyWithReferences()
{
var (compilation, assembly) = CompilationHelper.CreateCompilationFromAssembly("TestData/TupleLibrary.dll");
Assert.Empty(compilation.GetDeclarationDiagnostics());
Assert.Empty(compilation.GetDeclarationDiagnostics(TestContext.Current.CancellationToken));

var output = assembly.GenerateMetadataItem(compilation);
var @class = output.Items[0].Items[0];
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Glob.Tests/Docfx.Glob.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Glob\Docfx.Glob.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.MarkdigEngine.Extensions\Docfx.MarkdigEngine.Extensions.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.MarkdigEngine.Extensions\Docfx.MarkdigEngine.Extensions.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Tests.Common/Docfx.Tests.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<IsTestProject>false</IsTestProject>
<IsTestingPlatformApplication>false</IsTestingPlatformApplication>
<UseMicrosoftTestingPlatformRunner>false</UseMicrosoftTestingPlatformRunner>
<TestingPlatformDotnetTestSupport>false</TestingPlatformDotnetTestSupport>
</PropertyGroup>

<!-- Add assembly level ExcludeFromCodeCoverage attribute -->
Expand Down
5 changes: 3 additions & 2 deletions test/docfx.Snapshot.Tests/docfx.Snapshot.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Playwright" />
<PackageReference Include="Verify.DiffPlex" />
<PackageReference Include="Verify.Xunit" />
<PackageReference Include="Verify.XunitV3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion test/docfx.Tests/JsonSchemaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Docfx.Tests.Common;
using FluentAssertions;
using Json.Schema;
using Xunit.Abstractions;
using YamlDotNet.Serialization;

namespace Docfx.Tests;
Expand Down
Loading
Loading