-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Fix issue pester#2062 "Stacktrace is not filtered in non-english system languages" #2276
Conversation
…em languages" Pester internal lines are filtered from Stack Traces using regex. Windows stack traces are localized depending on the language of the OS. In ConvertTo-FailureLines, we throw an exception on purpose, then catch it in order to detect the localized strings of the stack trace. We then feed these localized strings to the regex for filtering.
FYI, this is a work in progress. I do not know if this is the right approach to fix this issue. Also, i think building the module without -Inline will not work because of the code at lines 540-548 |
Thanks for looking into this! Last year I intended to simply replace While this PR is clever and more precise, it follows the same assumptions. I wonder if it might be unnecessary complex? A bonus with your approach is that we could technically localize the added tracelines for PesterAssertionFailed, though I'm not sure if we should since the translation might not be great.
I don't follow. Wouldn't the same word-replacements apply there as well? Could you elaborate? |
- update $isPesterFunction variable wrapped inside PESTER_BUILD so that building Pester without -Build will work with the new behavior
Hi,
From my experience, localization of technical messages (such as Stack Traces) on Windows can be quite inconsistent depending on the language/culture of the system. For example, on a French(France) machine, the ":" is preceded by a non-breakable space... I may be able to gather stack traces for a few different languages and share them here if that can be useful to you.
I have pushed a new commit to my branch that modifies the code inside these lines. I currently don't have the means to test on non-Windows system so my concern may be a non-issue though. |
👍
Would be nice to have as part of tests.
No need. That part uses the folderpath in the pattern, so will always have the correct slash/backslash. 🙂 |
There is another PR #2391 implementing this in hopefully the most reliable way, and we cannot repro the issue. If you know how to make the stack traces show up in different language or how to test this on en-us system that would be awesome contribution to the other PR. |
PR Summary
Fix issue #2062 "Stacktrace is not filtered in non-english system languages"
When using StackTraceverbosity = 'Filtered', pester internals are filtered from the stack trace using regex matching.
However, Windows stack trace are localized depending on the language of the OS.
The words "At" and "Line" which can be translated (or not) depending on the language of the system.
This PR introduce an heuristic-like solution in ConvertTo-FailureLines function :
We throw an exception on purpose, then catch it in order to detect the localized strings of the stack trace.
We then feed these localized strings back to the regex for filtering pester internals.
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.