-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
tools: expose skip output to test runner #2130
tools: expose skip output to test runner #2130
Conversation
In the TAP protocol, skips are flagged as ok. Expose more information so we can understand if the test was skipped or not.
@@ -471,6 +474,10 @@ def UnexpectedOutput(self): | |||
outcome = PASS | |||
return not outcome in self.test.outcomes | |||
|
|||
def HasSkipped(self): | |||
s = '1..0 # Skipped:' |
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.
This should probably be a regex if there's any concern about actual TAP compliance. The Skipped
only needs to match skip
, and it shouldn't be case sensitive.
Yeah. String matching is questionable but since we're at least establishing a standard for this, I chose to go with the cheaper operation. The "right thing" to do here is creating a function that formats into tap input in Anyway, if more people agree that I should go regex I'll make it so. |
I wouldn't worry about performance until it's a problem. An anchored regex is normally just as fast or faster than a string comparison because it gets compiled to a dfa (though that generally only matters for longer strings). The case insensitively would be the biggest cost regardless of the method used. |
⬆️ fixed |
`re` only matches on the first line unless told to do multiline.
@@ -255,6 +255,10 @@ def HasRun(self, output): | |||
logger.info('#' + l) | |||
for l in output.output.stdout.splitlines(): | |||
logger.info('#' + l) | |||
elif output.HasSkipped(): | |||
skip = re.findall('# SKIP\S+ (.+)', output.output.stdout, |
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.
It is better to use raw strings for RegEx. Also, we can precompile and store the RegEx with re.compile
@@ -471,6 +475,10 @@ def UnexpectedOutput(self): | |||
outcome = PASS | |||
return not outcome in self.test.outcomes | |||
|
|||
def HasSkipped(self): | |||
skip = is_skipped.search(self.output.stdout) |
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.
Just a question, since I am about to touch this code too, where is the "# SKIP" output generated? Is it logged to stdout by the tests themselves?
There is also support in the test runner to do this with status files.
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.
@orangemocha PTAL at #2109
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.
Yes, the tests print '0..1 # Skipped: <reason>'
.
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.
Got it, thanks!
Updated based on all feedback disregarding code style -- will update if we don't care about current conventions. |
The regex appears to be fed a multiline blob of text.. does anything need to be done about only capturing the the end of the line? I would expect not but it has been a while since I used Python so I just wanted to point it out. |
@rmg as far as I know, |
Here's two skip's in output: https://jenkins-iojs.nodesource.com/job/iojs+pr+win/nodes=win2008r2/113/console (test 133, 134)
Edit: Works as intended, I was just a bit early to call it. |
@@ -255,6 +256,9 @@ def HasRun(self, output): | |||
logger.info('#' + l) | |||
for l in output.output.stdout.splitlines(): | |||
logger.info('#' + l) | |||
elif output.HasSkipped(): | |||
skip = skip_regex.search(output.output.stdout).group(1) |
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.
Hmmm, its better not to search twice. Why not use @bnoordhuis's suggestion #2130 (comment)?
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.
Because code conventions. I'll make it happen.
Depends on whether you use
|
6725cba
to
3749544
Compare
^ PTAL |
The original version had |
@thefourtheye yeah, represents whether the test suite should catch body output or not. I don't think too many people would turn that off. Reckon the regex is cheap enough or do we want to squeeze that extra cpu cycle? |
@jbergstroem Cool then. The RegEx looks fine and overall the code is readable to me. LGTM 👍 |
CI: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/149/ Edit: Skip here. |
@bnoordhuis went ahead and did a similar suggestion to yours. Looking better? |
Is this good to land then? |
LGTM 👍, if the CI run is green. |
skip = skip_regex.search(output.output.stdout) | ||
if skip: | ||
logger.info('ok %i - %s # skip %s' % | ||
(self._done, command, skip.group(1))) |
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.
Style nit: if it doesn't fit on a single line, maybe write it as:
logger.info(
'ok %i - %s # skip %s' % (self._done, command, skip.group(1)))
LGTM with nit and sorry for the delay. |
In the TAP protocol, skips are flagged as ok. Expose more information so we can understand if the test was skipped or not. PR-URL: #2130 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Merged in 3cbb587. Thanks for the review. |
In the TAP protocol, skips are flagged as ok. Expose more information so we can understand if the test was skipped or not. Refs #2109.
(see http://testanything.org/tap-specification.html -> directives -> skipping tests)
/R=@nodejs/build, @bnoordhuis (keeps my python on track)