Skip to content

Add Help Printing to XCTest executables #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2019

Conversation

gmittert
Copy link
Contributor

  • Provides usage and examples on --help, -h, or and invalid option
  • Examples are customized based on the tests contained in the executable
    and the executable name

For example, for Foundation's TestFoundation:

> TestFoundation --invalid

Error: Invalid option "--invalid"

Usage: TestFoundation.exe [OPTION]
       TestFoundation.exe [TESTCASE]
Run and report results of test cases.

With no OPTION or TESTCASE, runs all test cases.

  -h, --help                   Print this help message
  -l, --list-test              List tests line by line to standard output
      --dump-tests-json        List tests in JSON to standard output

Examples:
  Run a single test

       > TestFoundation.exe TestFoundation.TestAffineTransform/test_BasicConstruction

  Run all the tests in TestFoundation.TestAffineTransform

       > TestFoundation.exe TestFoundation.TestAffineTransform

@gmittert
Copy link
Contributor Author

@swift-ci please test

@gmittert
Copy link
Contributor Author

cc @compnerd @stmontgomery

Copy link
Contributor

@stmontgomery stmontgomery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement! I have just a few small suggestions below. CC @briancroom

@@ -87,6 +87,33 @@ public func XCTMain(_ testCases: [XCTestCaseEntry]) -> Never {
case .list(type: .json):
TestListing(testSuite: rootTestSuite).printTestJSON()
exit(0)
case let .help(invalidOption):
if let invalid = invalidOption {
print("Error: Invalid option \"\(invalid)\"\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this print be output to stderr instead of stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me... but is there an easier way to print to stderr than what I could figure out?

- Provides usage and examples on --help, -h, or and invalid option
- Examples are customized based on the tests contained in the executable
  and the executable name

For example, for Foundation's TestFoundation:

```
> TestFoundation --invalid

Error: Invalid option "--invalid"

Usage: TestFoundation.exe [OPTION]
       TestFoundation.exe [TESTCASE]
Run and report results of test cases.

With no OPTION or TESTCASE, runs all test cases.

  -h, --help                   Print this help message
  -l, --list-test              List tests line by line to standard output
      --dump-tests-json        List tests in JSON to standard output

Examples:
  Run a single test

       > TestFoundation.exe TestFoundation.TestAffineTransform/test_BasicConstruction

  Run all the tests in TestFoundation.TestAffineTransform

       > TestFoundation.exe TestFoundation.TestAffineTransform
```
@gmittert
Copy link
Contributor Author

gmittert commented Oct 8, 2019

@swift-ci please test

@gmittert
Copy link
Contributor Author

Two week reminder ping :) cc @stmontgomery

@briancroom briancroom self-requested a review October 26, 2019 03:55
Copy link
Contributor

@briancroom briancroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay here @gmittert. This looks great to me! Thanks for this contribution.

@briancroom
Copy link
Contributor

@swift-ci please test

Copy link
Contributor

@stmontgomery stmontgomery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks @gmittert!

@briancroom briancroom merged commit b5a8093 into swiftlang:master Oct 26, 2019
@gmittert gmittert deleted the OHGODHELP branch October 28, 2019 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants