mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 08:25:58 +01:00
Merge pull request #470 from LinoMastro/help_msg
Implement an -h/--help flag for Unity Fixtures and add documentation
This commit is contained in:
@@ -15,3 +15,15 @@ Fixtures, by default, uses the Memory addon as well. This is to make it simple f
|
||||
follow along with James' book. Using them together is completely optional. You may choose to use
|
||||
Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically
|
||||
pulling in extras and leave you to do it as desired.
|
||||
|
||||
# Usage information
|
||||
|
||||
By default the test executables produced by Unity Fixtures run all tests once, but the behavior can
|
||||
be configured with command-line flags. Run the test executable with the `--help` flag for more
|
||||
information.
|
||||
|
||||
It's possible to add a custom line at the end of the help message, typically to point to
|
||||
project-specific or company-specific unit test documentation. Define `UNITY_CUSTOM_HELP_MSG` to
|
||||
provide a custom message, e.g.:
|
||||
|
||||
#define UNITY_CUSTOM_HELP_MSG "If any test fails see https://example.com/troubleshooting"
|
||||
|
||||
@@ -192,7 +192,42 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
|
||||
|
||||
for (i = 1; i < argc; )
|
||||
{
|
||||
if (strcmp(argv[i], "-v") == 0)
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
/* Usage */
|
||||
UnityPrint("Runs a series of unit tests.");
|
||||
UNITY_PRINT_EOL();
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint("When no flag is specified, all tests are run.");
|
||||
UNITY_PRINT_EOL();
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint("Optional flags:");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -v Verbose output: show all tests executed even if they pass");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -s Silent mode: minimal output showing only test failures");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -g NAME Only run tests in groups that contain the string NAME");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -n NAME Only run tests whose name contains the string NAME");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -r NUMBER Repeatedly run all tests NUMBER times");
|
||||
UNITY_PRINT_EOL();
|
||||
UnityPrint(" -h, --help Display this help message");
|
||||
UNITY_PRINT_EOL();
|
||||
UNITY_PRINT_EOL();
|
||||
#ifdef UNITY_CUSTOM_HELP_MSG
|
||||
/* User-defined help message, e.g. to point to project-specific documentation */
|
||||
UnityPrint(UNITY_CUSTOM_HELP_MSG);
|
||||
UNITY_PRINT_EOL();
|
||||
#else
|
||||
/* Default help suffix if a custom one is not defined */
|
||||
UnityPrint("More information about Unity: https://www.throwtheswitch.org/unity");
|
||||
UNITY_PRINT_EOL();
|
||||
#endif
|
||||
return 1; /* Exit without running the tests */
|
||||
}
|
||||
else if (strcmp(argv[i], "-v") == 0)
|
||||
{
|
||||
UnityFixture.Verbose = 1;
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user