-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add descriptive error when attempting to list tests before building #8046
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
Add descriptive error when attempting to list tests before building #8046
Conversation
Typically a build is performed before a `swift test list` command, but by passing the `--skip-build` flag it is possible to get a cryptic, unhelpful erorr message if the test artifacts haven't already been built. Add a descriptive error for this case, only checking for test artifact existence in the failure case to avoid any performance impact on the happy path.
try await self.runCommand(swiftCommandState) | ||
} catch let error as FileSystemError { | ||
if sharedOptions.shouldSkipBuilding { | ||
throw ErrorWithContext(error, "Test build artifacts were not found in the build folder. Found the --skip-build flag; build the tests first or rerun the command without --skip-build") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the error message be more detailed? Which build folder at what path? Can it provide a list of artifacts that were expected to be found? Otherwise it may not be fully actionable for a user if they're willing to investigate what exactly went wrong. Also, "build the tests first" should provide an example command or an exact command for building tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapped error contains the detailed information about what file wasn't found. Here is the error message as it stands right now:
error: Test build artifacts were not found in the build folder.
The `--skip-build` flag was provided; either build the tests first with `swift build --build tests` or rerun the `swift test list` command without `--skip-build`
/Users/plemarquand/work/testapps/TestApp/.build/arm64-apple-macosx/debug/TestAppPackageTests.xctest doesn't exist in file system
Because the xctest codepath throws a FileSystemError as soon as it encounters a missing file we'd need to rework the architecture a bit to keep iterating and collect up all the errors in order to show a list of all the files that aren't found. I can go that route if need be but its going to make the code more complex for a small gain I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@swift-ci test |
@swift-ci test |
Motivation:
Typically a build is performed before a
swift test list
command, but by passing the--skip-build
flag it is possible to get a cryptic, unhelpful error message if the test artifacts haven't already been built.Modifications:
Add a descriptive error for this case, only checking for test artifact existence in the failure case to avoid any performance impact on the happy path.