Skip to content

Updated Pester Problem Matcher #1362

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 3 commits into from
Jun 12, 2018
Merged

Updated Pester Problem Matcher #1362

merged 3 commits into from
Jun 12, 2018

Conversation

awickham10
Copy link
Contributor

@awickham10 awickham10 commented Jun 12, 2018

PR Summary

Updated the Pester problem matcher. Resolves #1291.

  • Remove "[-] " from beginning of message
  • Match on tests that take longer than 1 second
  • Change matching group to be a non-capturing group since it isn't used
  • Tested by using creating the updated problem matcher in tasks.json instead of using $pester.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • This PR is ready to merge and is not work in progress

@awickham10
Copy link
Contributor Author

This resolves #1291.

@awickham10
Copy link
Contributor Author

Here are a few screen shots of this working.

Pester Output
test output

Problem Matcher
problem matcher

@rkeithhill
Copy link
Contributor

Nice catch! Thanks.

package.json Outdated
@@ -176,7 +176,7 @@
"severity": "error",
"pattern": [
{
"regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
"regexp": "^\\s*(?:\\[-\\]\\s)(\\s*.*?)(?:\\s\\d*\\.?\\d*s|\\s\\d*\\.?\\d*ms)\\s*$",
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could simplify this a bit to:

"^\\s*(?:\\[-\\]\\s+)(.*?)(?:\\s+\\d+\\.?\\d*\\s*m?s)\\s*$"

I don't think we want to include any spaces at the beginning of the message (capture group 1), best to have the first non-capture group scoop up all the spaces after the [-]. Ditto with the second non-capture group - let's have it scoop up all the space at the end of the message.

Also, shouldn't we expect at least one digit (\d+) before the required s or ms? Finally, how about we add a \s* between the time and the units in case they ever decide that the display looks better with a space in there. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it. Great feedback. I'm not great with regular expressions (said everyone on the internet), so your write up was a great learning experience for me. I'll get it updated.

…2, made at least one digit required for time elapsed, and put an optional space after the time elapsed and units.
@rkeithhill
Copy link
Contributor

One last request - did you test the updated regex against Pester? Also, what version of Pester are you using? I did some basic testing against faked output strings. :-)

@awickham10
Copy link
Contributor Author

I threw the same regular expression in my project's tasks.json and it works properly in there for both milliseconds and seconds. I'm running with Pester 4.3.1. See attached screen shots.

pester

problems

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM

@rkeithhill rkeithhill merged commit 4159c37 into PowerShell:master Jun 12, 2018
@rkeithhill
Copy link
Contributor

@awickham10 Merged. Thanks for your contribution!

@awickham10
Copy link
Contributor Author

No problem - glad to help!

@derbium
Copy link

derbium commented Jul 11, 2018

Nice work awickham10, I rarely read release notes but just happen to see your user name attached to this!

@awickham10
Copy link
Contributor Author

Thanks @derbium! Need to catch up soon.

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