Skip to content

Commit 9325458

Browse files
authored
Merge pull request #1486 from nunit/issue-1359
Add info about @file to help options; refactor ShowHelp()
2 parents b6196ab + 64fb375 commit 9325458

File tree

3 files changed

+104
-83
lines changed

3 files changed

+104
-83
lines changed

src/NUnitConsole/nunit3-console/ColorConsole.cs

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public static ConsoleColor GetColor(ColorStyle style)
3939
return color;
4040
}
4141

42+
public static void SetForeground(ColorStyle style)
43+
{
44+
Console.ForegroundColor = GetColorForStyle(style);
45+
}
46+
4247
private static ConsoleColor GetColorForStyle(ColorStyle style)
4348
{
4449
switch (Console.BackgroundColor)

src/NUnitConsole/nunit3-console/Options/Options.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1352,8 +1352,9 @@ public void WriteOptionDescriptions(TextWriter o)
13521352
o.Write(new string(' ', OptionWidth));
13531353
}
13541354

1355-
WriteDescription(o, p.Description, new string(' ', OptionWidth + 2),
1355+
WriteDescription(o, p.Description, new string(' ', OptionWidth),
13561356
Description_FirstWidth, Description_RemWidth);
1357+
o.WriteLine();
13571358
}
13581359

13591360
foreach (ArgumentSource s in sources)
@@ -1406,7 +1407,7 @@ void WriteDescription(TextWriter o, string value, string prefix, int firstWidth,
14061407
{
14071408
if (indent)
14081409
o.Write(prefix);
1409-
o.WriteLine(line);
1410+
o.WriteLine(line.Trim());
14101411
indent = true;
14111412
}
14121413
}

src/NUnitConsole/nunit3-console/Program.cs

+96-81
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
using System;
44
using System.Diagnostics;
5+
using System.Drawing;
56
using System.Globalization;
67
using System.IO;
78
using System.Linq;
9+
using System.Linq.Expressions;
810
using System.Reflection;
911
using System.Text;
1012

@@ -189,102 +191,115 @@ private static void WriteHelpText()
189191
OutWriter.WriteLine(ColorStyle.Header, "NUNIT3-CONSOLE [inputfiles] [options]");
190192
OutWriter.WriteLine();
191193
OutWriter.WriteLine(ColorStyle.SectionHeader, "Description:");
192-
using (new ColorConsole(ColorStyle.Default))
193-
{
194194
#if NETFRAMEWORK
195-
OutWriter.WriteLine(" The standard NUnit Console Runner runs a set of NUnit tests from the");
196-
OutWriter.WriteLine(" console command-line. By default, all tests are run using separate agents");
197-
OutWriter.WriteLine(" for each test assembly. This allows each assembly to run independently");
198-
OutWriter.WriteLine(" and allows each assembly to run under the appropriate target runtime.");
195+
OutWriter.WriteLine(ColorStyle.Default, """
196+
The standard NUnit Console Runner runs a set of NUnit tests from the
197+
console command-line. By default, all tests are run using separate agents
198+
for each test assembly. This allows each assembly to run independently
199+
and allows each assembly to run under the appropriate target runtime.
200+
201+
""");
199202
#else
200-
OutWriter.WriteLine(" The NetCore Console Runner runs a set of NUnit tests from the console");
201-
OutWriter.WriteLine(" command-line. All tests are run in-process and therefore execute under");
202-
OutWriter.WriteLine(" the same runtime as the runner itself. A number of options supported by");
203-
OutWriter.WriteLine(" the standard console runner are not available using the NetCore runner.");
204-
OutWriter.WriteLine(" See \"Limitations\" below for more information.");
203+
OutWriter.WriteLine(ColorStyle.Default, """
204+
The NetCore Console Runner runs a set of NUnit tests from the console
205+
command-line. All tests are run in-process and therefore execute under
206+
the same runtime as the runner itself. A number of options supported by
207+
the standard console runner are not available using the NetCore runner.
208+
See \"Limitations\" below for more information.
209+
210+
""");
205211
#endif
206-
}
207-
OutWriter.WriteLine();
208212
OutWriter.WriteLine(ColorStyle.SectionHeader, "InputFiles:");
209213
OutWriter.WriteLine(ColorStyle.Default, " One or more assemblies or test projects of a recognized type.");
210214
OutWriter.WriteLine();
211215
OutWriter.WriteLine(ColorStyle.SectionHeader, "Options:");
212216
using (new ColorConsole(ColorStyle.Default))
213217
{
218+
OutWriter.WriteLine("""
219+
@FILE Specifies the name(or path) of a FILE containing
220+
additional command-line arguments to be inserted
221+
at the point where the @FILE expression appears.
222+
Each line in the file represents one argument
223+
to the console runner. If an option takes a value,
224+
that value must appear on the same line.
225+
226+
""");
227+
214228
Options.WriteOptionDescriptions(Console.Out);
215229
}
216230
OutWriter.WriteLine();
217231
OutWriter.WriteLine(ColorStyle.SectionHeader, "Operation:");
218-
using (new ColorConsole(ColorStyle.Default))
219-
{
220-
OutWriter.WriteLine(" By default, this command runs the tests contained in the");
221-
OutWriter.WriteLine(" assemblies and projects specified. If the --explore option");
222-
OutWriter.WriteLine(" is used, no tests are executed but a description of the tests");
223-
OutWriter.WriteLine(" is saved in the specified or default format.");
224-
OutWriter.WriteLine();
225-
OutWriter.WriteLine(" The --where option is intended to extend or replace the earlier");
226-
OutWriter.WriteLine(" --test, --include and --exclude options by use of a selection expression");
227-
OutWriter.WriteLine(" describing exactly which tests to use. Examples of usage are:");
228-
OutWriter.WriteLine(" --where:cat==Data");
229-
OutWriter.WriteLine(" --where \"method =~ /DataTest*/ && cat = Slow\"");
230-
OutWriter.WriteLine();
231-
OutWriter.WriteLine(" Care should be taken in combining --where with --test or --testlist.");
232-
OutWriter.WriteLine(" The test and where specifications are implicitly joined using &&, so");
233-
OutWriter.WriteLine(" that BOTH sets of criteria must be satisfied in order for a test to run.");
234-
OutWriter.WriteLine(" See the docs for more information and a full description of the syntax");
235-
OutWriter.WriteLine(" information and a full description of the syntax.");
236-
OutWriter.WriteLine();
237-
OutWriter.WriteLine(" Several options that specify processing of XML output take");
238-
OutWriter.WriteLine(" an output specification as a value. A SPEC may take one of");
239-
OutWriter.WriteLine(" the following forms:");
240-
OutWriter.WriteLine(" --OPTION:filename");
241-
OutWriter.WriteLine(" --OPTION:filename;format=formatname");
242-
OutWriter.WriteLine(" --OPTION:filename;transform=xsltfile");
243-
OutWriter.WriteLine();
244-
OutWriter.WriteLine(" The --result option may use any of the following formats:");
245-
OutWriter.WriteLine(" nunit3 - the native XML format for NUnit 3");
246-
OutWriter.WriteLine(" nunit2 - legacy XML format used by earlier releases of NUnit");
247-
OutWriter.WriteLine(" Requires the engine extension NUnitV2ResultWriter.");
248-
OutWriter.WriteLine();
249-
OutWriter.WriteLine(" The --explore option may use any of the following formats:");
250-
OutWriter.WriteLine(" nunit3 - the native XML format for NUnit 3");
251-
OutWriter.WriteLine(" cases - a text file listing the full names of all test cases.");
252-
OutWriter.WriteLine(" If --explore is used without any specification following, a list of");
253-
OutWriter.WriteLine(" test cases is output to the writer.");
254-
OutWriter.WriteLine();
255-
OutWriter.WriteLine(" If none of the options {--result, --explore, --noresult} is used,");
256-
OutWriter.WriteLine(" NUnit saves the results to TestResult.xml in nunit3 format.");
257-
OutWriter.WriteLine();
258-
OutWriter.WriteLine(" Any transforms provided must handle input in the native nunit3 format.");
259-
OutWriter.WriteLine();
260-
OutWriter.WriteLine(" To be able to load NUnit projects, file type .nunit, the engine");
261-
OutWriter.WriteLine(" extension NUnitProjectLoader is required. For Visual Studio projects");
262-
OutWriter.WriteLine(" and solutions the engine extension VSProjectLoader is required.");
232+
OutWriter.WriteLine(ColorStyle.Default, """
233+
By default, this command runs the tests contained in the");
234+
assemblies and projects specified. If the --explore option");
235+
is used, no tests are executed but a description of the tests");
236+
is saved in the specified or default format.
237+
238+
The --where option is intended to extend or replace the earlier
239+
--test, --include and --exclude options by use of a selection expression
240+
describing exactly which tests to use. Examples of usage are:
241+
--where:cat==Data
242+
--where \"method =~ /DataTest*/ && cat = Slow\"
243+
244+
Care should be taken in combining --where with --test or --testlist.
245+
The test and where specifications are implicitly joined using &&, so
246+
that BOTH sets of criteria must be satisfied in order for a test to run.
247+
See the docs for more information and a full description of the syntax
248+
information and a full description of the syntax.
249+
250+
Several options that specify processing of XML output take
251+
an output specification as a value. A SPEC may take one of
252+
the following forms:
253+
--OPTION:filename
254+
--OPTION:filename;format=formatname
255+
--OPTION:filename;transform=xsltfile
256+
257+
The --result option may use any of the following formats
258+
nunit3 - the native XML format for NUnit 3
259+
nunit2 - legacy XML format used by earlier releases of NUnit
260+
Requires the engine extension NUnitV2ResultWriter.
261+
262+
The --explore option may use any of the following formats:
263+
nunit3 - the native XML format for NUnit 3
264+
cases - a text file listing the full names of all test cases.
265+
If --explore is used without any specification following, a list of
266+
test cases is output to the writer.
267+
268+
If none of the options {--result, --explore, --noresult} is used,
269+
NUnit saves the results to TestResult.xml in nunit3 format.
270+
271+
Any transforms provided must handle input in the native nunit3 format.
272+
273+
To be able to load NUnit projects, file type .nunit, the engine
274+
extension NUnitProjectLoader is required. For Visual Studio projects
275+
and solutions the engine extension VSProjectLoader is required.
276+
""");
263277
#if NETCOREAPP
264-
OutWriter.WriteLine();
265-
OutWriter.WriteLine(ColorStyle.SectionHeader, "Limitations:");
266-
OutWriter.WriteLine(" The NetCore Runner is primarily intended for use as a dotnet tool.");
267-
OutWriter.WriteLine(" When used in this way, a single assembly is usually being tested and");
268-
OutWriter.WriteLine(" the assembly must be compatible with execution under the same runtime");
269-
OutWriter.WriteLine(" as the runner itself, normally .NET 6.0.");
270-
OutWriter.WriteLine();
271-
OutWriter.WriteLine(" Using this runner, the following options are not available. A brief");
272-
OutWriter.WriteLine(" rationale is given for each option excluded.");
273-
OutWriter.WriteLine(" --configFile Config of the runner itself is used.");
274-
OutWriter.WriteLine(" --process Not designed to run out of process.");
275-
OutWriter.WriteLine(" --inprocess Redundant. We always run in process.");
276-
OutWriter.WriteLine(" --domain Not applicable to .NET Core.");
277-
OutWriter.WriteLine(" --framework Runtime of the runner is used.");
278-
OutWriter.WriteLine(" --x86 Bitness of the runner is used.");
279-
OutWriter.WriteLine(" --shadowcopy Not available.");
280-
OutWriter.WriteLine(" --loaduserprofile Not available.");
281-
OutWriter.WriteLine(" --agents No agents are used.");
282-
OutWriter.WriteLine(" --debug Debug in process directly.");
283-
OutWriter.WriteLine(" --pause Used for debugging agents.");
284-
OutWriter.WriteLine(" --set-principal-policy Not available.");
285-
OutWriter.WriteLine(" --debug-agent No agents are used.");
278+
OutWriter.WriteLine();
279+
OutWriter.WriteLine(ColorStyle.SectionHeader, "Limitations:");
280+
OutWriter.WriteLine(ColorStyle.Default, """
281+
The NetCore Runner is primarily intended for use as a dotnet tool.
282+
When used in this way, a single assembly is usually being tested and
283+
the assembly must be compatible with execution under the same runtime
284+
as the runner itself, normally .NET 6.0.
285+
286+
Using this runner, the following options are not available. A brief
287+
rationale is given for each option excluded.
288+
--configFile Config of the runner itself is used.
289+
--process Not designed to run out of process.
290+
--inprocess Redundant. We always run in process.
291+
--domain Not applicable to .NET Core.
292+
--framework Runtime of the runner is used.
293+
--x86 Bitness of the runner is used.
294+
--shadowcopy Not available.
295+
--loaduserprofile Not available.
296+
--agents No agents are used.
297+
--debug Debug in process directly.
298+
--pause Used for debugging agents.
299+
--set-principal-policy Not available.
300+
--debug-agent No agents are used.
301+
""");
286302
#endif
287-
}
288303
}
289304

290305
private static void CancelHandler(object sender, ConsoleCancelEventArgs args)

0 commit comments

Comments
 (0)