-
Notifications
You must be signed in to change notification settings - Fork 263
Allow differing leading/trailing whitespace when checking test output #71
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
Allow differing leading/trailing whitespace when checking test output #71
Conversation
I agree with your first point! I also think that My two cents on (2): personally I think the better solution is to put a |
If Xcode's XCTest is outputting extra space at the end of some lines, I wouldn't mind seeing that addressed. Does it? Any specifics as to when it does this would be appreciated, and I can file a radar for the behavior. I think this particular change would be fine. Especially if it has precedent in FileCheck. |
The following test case: import XCTest
class TestBar: XCTestCase {
func testBar() {
XCTAssert(false)
}
} produces the following (partial) output:
Note that the line indicating the failure does contain a trailing space after the hyphen. |
Regarding FileCheck's behavior, this bit of documentation seems to confirm what @modocache indicated. (Note that our default matching style appears to be basically equivalent to FileCheck with the |
81d6bb4
to
87b39d2
Compare
87b39d2
to
2b32c53
Compare
Besides rebasing, I've also taken advantage of a comment on the aforementioned FileCheck docs and updated this behavior such that it now fully respects I've also updated a few tests to take advantage of the enhanced checker. Note that there are still a couple of tests like this one which explicit check for a trailing space. These will serve us well when we want to get rid of that trailing space (in a separate PR!) |
|
||
def _add_whitespace_leniency(original_regex): | ||
return "^ *" + original_regex + " *$" |
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.
Will the spaces here only match spaces, or will they match tabs as well? Perhaps use \s
?
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.
Yeah, that's a good point. \s
is probably more appropriate here considering the way that I've been referencing whitespace
generally in the docs for this PR.
OTOH, considering that it's not actually necessary at this moment, and CI has gone green already with the existing code (on Linux at least), how about we make that adjustment separately?
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.
Works for me! 👍
Wow!! Can't argue with that. Sorry to make you jump through so many hoops. I think this is a great solution. Thanks, @briancroom! 💯 Personally I'd prefer to keep a trailing @mike-ferris-apple could you kick off the tests so we can merge this? |
@swift-ci please test |
Allow differing leading/trailing whitespace when checking test output
Not at all! This is exactly the sort of discussion I was hoping would come out of this PR. We all learned a thing or two, got some clarity on a (minor!) bug in |
There are two situations lately where I've been finding myself fighting the testing framework's current strictness with respect to whitespace at the beginning and end of lines:
// CHECK-ALL:
prefix, in order to also be able to keep things nicely lined up on lines like this.As I see it, we don't have any tests right now for which precise matching of leading/trailing whitespace is important, and I don't foresee any such tests coming up either, so it seems that this change will make the test checker a little easier to work with. On the other hand if there are concerns about this, we could also add a flag for turning this behavior off and on.