Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.Testing.Extensions.AzureDevOpsReport;

internal sealed class AzureDevOpsSummaryReporter : IDataConsumer, ITestSessionLifetimeHandler, IOutputDeviceDataProducer
{
private const string DefaultSummaryFileNameFormat = "azdo-summary-{0}.md";
private const string DefaultSummaryFileNameFormat = "azdo-summary-{0}-{1}-{2}.md";
private const string FullyQualifiedNamePropertyKey = "vstest.TestCase.FullyQualifiedName";
private const int MaxSlowestTests = 10;
private const int MaxTopFailingClasses = 5;
Expand Down Expand Up @@ -266,7 +266,23 @@ public async Task OnTestSessionFinishingAsync(ITestSessionContext testSessionCon
return null;
}

string fileName = string.Format(CultureInfo.InvariantCulture, DefaultSummaryFileNameFormat, _targetFrameworkMoniker.Value);
// Include the assembly name and process architecture in the default file name (matching the
// <asm>_<tfm>_<arch> shape used by the TRX/HTML/JUnit reports) so that multiple test assemblies
// that share the same target framework and TestResults directory (a common CI setup) don't all
// resolve to the same path and race to write it, which surfaced as
// "The process cannot access the file ... because it is being used by another process".
string assemblyName = _testApplicationModuleInfo.TryGetAssemblyName() ?? "unknown";
string architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();

// Sanitize the whole file name (matching TRX/HTML/JUnit) so that unexpected characters in any segment
// - including the target framework moniker or architecture, not just the assembly name - cannot produce
// an invalid file name.
string fileName = ReportFileNameSanitizer.ReplaceInvalidFileNameChars(string.Format(
CultureInfo.InvariantCulture,
DefaultSummaryFileNameFormat,
assemblyName,
_targetFrameworkMoniker.Value,
architecture));
return Path.GetFullPath(Path.Combine(configuredTestResultsDirectory!, fileName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Compile Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\Helpers\RoslynString.cs" Link="Helpers\RoslynString.cs" />
<Compile Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\OutputDevice\TargetFrameworkParser.cs" Link="Helpers\TargetFrameworkParser.cs" />
<Compile Include="$(RepoRoot)src\Platform\SharedExtensionHelpers\TargetFrameworkMonikerHelper.cs" Link="Helpers\TargetFrameworkMonikerHelper.cs" />
<Compile Include="$(RepoRoot)src\Platform\SharedExtensionHelpers\ReportFileNameSanitizer.cs" Link="Helpers\ReportFileNameSanitizer.cs" />
</ItemGroup>

<!-- NuGet properties -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@
<comment>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</comment>
</data>
<data name="SummaryOptionDescription" xml:space="preserve">
<value>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</value>
<comment>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</comment>
<value>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</value>
<comment>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</comment>
</data>
<data name="SummaryRequiresTfBuildWarning" xml:space="preserve">
<value>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Na konci testovacího běhu napište souhrn úlohy v Markdownu a nahrajte ho přes ##vso[task.uploadsummary]. Volitelný argument cesty k souboru přepíše výchozí umístění ({testResultsDir}/azdo-summary-{tfm}.md). Vyžaduje --report-azdo.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Na konci testovacího běhu napište souhrn úlohy v Markdownu a nahrajte ho přes ##vso[task.uploadsummary]. Volitelný argument cesty k souboru přepíše výchozí umístění ({testResultsDir}/azdo-summary-{tfm}.md). Vyžaduje --report-azdo.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Schreiben Sie am Ende des Testlaufs eine Markdownauftragszusammenfassung, und laden Sie sie über „##vso[task.uploadsummary]“ hoch. Ein optionales Dateipfadargument überschreibt den Standardspeicherort („{testResultsDir}/azdo-summary-{tfm}.md“). Erfordert „--report-azdo“.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Schreiben Sie am Ende des Testlaufs eine Markdownauftragszusammenfassung, und laden Sie sie über „##vso[task.uploadsummary]“ hoch. Ein optionales Dateipfadargument überschreibt den Standardspeicherort („{testResultsDir}/azdo-summary-{tfm}.md“). Erfordert „--report-azdo“.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Escriba un resumen del trabajo de Markdown al final de la serie de pruebas y cárguelo a través de "##vso[task.uploadsummary]". Un argumento de ruta de acceso de archivo opcional invalida la ubicación predeterminada ("{testResultsDir}/azdo-summary-{tfm}.md"). Requiere "--report-azdo".</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Escriba un resumen del trabajo de Markdown al final de la serie de pruebas y cárguelo a través de "##vso[task.uploadsummary]". Un argumento de ruta de acceso de archivo opcional invalida la ubicación predeterminada ("{testResultsDir}/azdo-summary-{tfm}.md"). Requiere "--report-azdo".</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Rédigez un résumé de travail Markdown à la fin de l’exécution du test et chargez-le via « ##vso[task.uploadsummary] ». Un argument facultatif de chemin de fichier remplace l’emplacement par défaut (« {testResultsDir}/azdo-summary-{tfm}.md »). Nécessite « --report-azdo ».</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Rédigez un résumé de travail Markdown à la fin de l’exécution du test et chargez-le via « ##vso[task.uploadsummary] ». Un argument facultatif de chemin de fichier remplace l’emplacement par défaut (« {testResultsDir}/azdo-summary-{tfm}.md »). Nécessite « --report-azdo ».</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Scrive un riepilogo Markdown del processo alla fine dell'esecuzione dei test e lo carica tramite "##vso[task.uploadsummary]". Un argomento facoltativo per il percorso del file sostituisce il percorso predefinito ("{testResultsDir}/azdo-summary-{tfm}.md"). Richiede "--report-azdo".</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Scrive un riepilogo Markdown del processo alla fine dell'esecuzione dei test e lo carica tramite "##vso[task.uploadsummary]". Un argomento facoltativo per il percorso del file sostituisce il percorso predefinito ("{testResultsDir}/azdo-summary-{tfm}.md"). Richiede "--report-azdo".</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">テスト実行の最後に Markdown のジョブ サマリーを作成し、'##vso[task.uploadsummary]' 経由でアップロードします。省略可能なファイル パス引数で、既定の場所 ('{testResultsDir}/azdo-summary-{tfm}.md') をオーバーライドできます。'--report-azdo' が必要です。</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">テスト実行の最後に Markdown のジョブ サマリーを作成し、'##vso[task.uploadsummary]' 経由でアップロードします。省略可能なファイル パス引数で、既定の場所 ('{testResultsDir}/azdo-summary-{tfm}.md') をオーバーライドできます。'--report-azdo' が必要です。</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">테스트 실행이 끝날 때 Markdown 작업 요약을 작성하고 '##vso[task.uploadsummary]'를 통해 업로드합니다. 선택적 파일 경로 인수는 기본 위치('{testResultsDir}/azdo-summary-{tfm}.md')를 재정의합니다. '--report-azdo'가 필요합니다.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">테스트 실행이 끝날 때 Markdown 작업 요약을 작성하고 '##vso[task.uploadsummary]'를 통해 업로드합니다. 선택적 파일 경로 인수는 기본 위치('{testResultsDir}/azdo-summary-{tfm}.md')를 재정의합니다. '--report-azdo'가 필요합니다.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@
<note>{0} is the maximum pattern count. {Locked="--report-azdo-stackframe-filter"}</note>
</trans-unit>
<trans-unit id="SummaryOptionDescription">
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{tfm}.md'). Requires '--report-azdo'.</source>
<target state="translated">Zapisz podsumowanie zadania w formacie Markdown na końcu przebiegu testu i prześlij je za pomocą „##vso[task.uploadsummary]”. Opcjonalny argument ścieżki pliku zastępuje lokalizację domyślną („{testResultsDir}/azdo-summary-{tfm}.md”). Wymaga polecenia „--report-azdo”.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{tfm}.md"}{Locked="--report-azdo"}</note>
<source>Write a Markdown job summary at the end of the test run and upload it via '##vso[task.uploadsummary]'. An optional file path argument overrides the default location ('{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md'). Requires '--report-azdo'.</source>
<target state="needs-review-translation">Zapisz podsumowanie zadania w formacie Markdown na końcu przebiegu testu i prześlij je za pomocą „##vso[task.uploadsummary]”. Opcjonalny argument ścieżki pliku zastępuje lokalizację domyślną („{testResultsDir}/azdo-summary-{tfm}.md”). Wymaga polecenia „--report-azdo”.</target>
<note>{Locked="Markdown"}{Locked="##vso[task.uploadsummary]"}{Locked="{testResultsDir}/azdo-summary-{assembly}-{tfm}-{arch}.md"}{Locked="--report-azdo"}</note>
</trans-unit>
<trans-unit id="SummaryRequiresTfBuildWarning">
<source>Azure DevOps job summary was requested, but TF_BUILD is not set to 'true'; skipping summary emission.</source>
Expand Down
Loading
Loading