From 653115215e08e5bc78873d53c03fe33f64a30bd3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 24 Oct 2025 15:07:10 -0700 Subject: [PATCH 1/2] Add some help text to the merged runner. --- .../XUnitWrapperGenerator.cs | 7 +++ src/tests/Common/XUnitWrapperLibrary/Help.cs | 44 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/tests/Common/XUnitWrapperLibrary/Help.cs diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index 9ab1ab1ae83dda..64c11a17bc7c20 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -334,6 +334,13 @@ private static string GenerateFullTestRunner(ImmutableArray testInfos } builder.AppendLine(); + builder.AppendLine(@"if (args is [""--help"" or ""-h"" or ""/?"" or ""-?""])"); + using (builder.NewBracesScope()) + { + builder.AppendLine("XUnitWrapperLibrary.Help.WriteHelpText();"); + builder.AppendLine("return 0;"); + } + builder.AppendLine("Initialize();"); // Open the stream writer for the temp log. diff --git a/src/tests/Common/XUnitWrapperLibrary/Help.cs b/src/tests/Common/XUnitWrapperLibrary/Help.cs new file mode 100644 index 00000000000000..9ea6df35ac225f --- /dev/null +++ b/src/tests/Common/XUnitWrapperLibrary/Help.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace XUnitWrapperLibrary; + +public static class Help +{ + public static void WriteHelpText() + { + string help = """ + Usage: XUnitWrapper [filter] [options] + + filter can be one of the following: + * Fully qualified method name: Namespace.ClassName.MethodName + * Substring of fully qualified method name: ClassName.MethodName or MethodName + * Display Name full string: DisplayName=ArrayMarshalling/SafeArray/SafeArrayTest/SafeArrayTest.dll + * Display Name substring: DisplayName~SafeArrayTest.dll + * NOTE: This is a subset of the dotnet test filter syntax, documented at https://learn.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests?pivots=xunit + + Display Names: + * For a given test, the display name can be one of the following: + - For tests where the only [Fact] method in the assembly is this test, the display name is the assembly name. + - For [Theory] tests, the display name is the fully qualified method name with the parameters for the test case. + - If the parameters are computed at runtime, the display name will be the fully qualified method name. + - For other tests, the display name is the fully qualified method name. + + Options: + --help, -h, /?, -? Display this help text. + --exclusion-list=FILE + Path to a file containing a list of tests to exclude. + Each line in the file should be in the following format: + displayName, reason + Intended to be generated from src/tests/issues.targets. + """; + + Console.WriteLine(help); + } +} From a813d2f048abb0ce2e7eb01c5079b02d9665ebdd Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 24 Oct 2025 15:18:23 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/tests/Common/XUnitWrapperLibrary/Help.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/Common/XUnitWrapperLibrary/Help.cs b/src/tests/Common/XUnitWrapperLibrary/Help.cs index 9ea6df35ac225f..a395c8b8f534d5 100644 --- a/src/tests/Common/XUnitWrapperLibrary/Help.cs +++ b/src/tests/Common/XUnitWrapperLibrary/Help.cs @@ -25,7 +25,7 @@ public static void WriteHelpText() Display Names: * For a given test, the display name can be one of the following: - - For tests where the only [Fact] method in the assembly is this test, the display name is the assembly name. + - For assemblies containing a single [Fact] test method, the display name is the assembly name. - For [Theory] tests, the display name is the fully qualified method name with the parameters for the test case. - If the parameters are computed at runtime, the display name will be the fully qualified method name. - For other tests, the display name is the fully qualified method name. @@ -36,7 +36,8 @@ public static void WriteHelpText() Path to a file containing a list of tests to exclude. Each line in the file should be in the following format: displayName, reason - Intended to be generated from src/tests/issues.targets. + (In the dotnet/runtime repository, this file is typically generated as part of the build process as 'src/tests/issues.targets'.) + If you are running tests outside the repository context, you may need to create your own exclusion list file in the format shown above. """; Console.WriteLine(help);