Skip to content
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

Stacktrace is not filtered in non-english system languages #2062

Closed
sergey-s-betke opened this issue Aug 21, 2021 · 6 comments
Closed

Stacktrace is not filtered in non-english system languages #2062

sergey-s-betke opened this issue Aug 21, 2021 · 6 comments

Comments

@sergey-s-betke
Copy link

sergey-s-betke commented Aug 21, 2021

General summary of the issue

Please, disable verbosity exception output (execution stack trace) for failed tests (pester/vscode-adapter#51).

Describe your environment

Pester version : 5.3.0 C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1
PowerShell version : 5.1.15063.674
OS version : Microsoft Windows NT 10.0.15063.0

Steps to reproduce

Test file:

#Requires -Version 5.0
#Requires -Modules @{ ModuleName='Pester'; ModuleVersion='5.2.0' }

param(
	# путь к папке с генерируемыми файлами
	[System.String]
	$DestinationPath = ( Join-Path -Path ( ( Get-Location ).Path ) -ChildPath 'output' ),

	# путь к папке с .odt файлами
	[System.String]
	$DestinationDocumentsPath = ( Join-Path -Path $DestinationPath -ChildPath 'doc' ),

	# имя .odt шаблона
	[System.String]
	$DocumentsFilter = '*.odt',

	# пути к .odt файлам
	[System.String[]]
	$DestinationDocFile = @(
		$DestinationDocumentsPath | Where-Object { Test-Path -Path $_ } |
		Get-ChildItem -Filter $DocumentsFilter | Select-Object -ExpandProperty FullName
	),

	# путь к папке с инструментами для сборки
	[System.String]
	$ToolsPath = ( ( Resolve-Path -Path '.\tools' ).Path ),

	# путь к папке с инструментами для документов
	[System.String]
	$DocsToolsPath = ( Join-Path -Path $ToolsPath -ChildPath 'docs' ),

	[System.String]
	$ODFValidatorPath = ( Join-Path -Path $DocsToolsPath -ChildPath 'ODFValidator' ),

	# путь к ODF validator JAR файлу
	[System.String]
	$ODFValidatorJarPath = ( Join-Path -Path $ODFValidatorPath -ChildPath 'ODFValidator.jar' )
)

chcp 65001 > $null;

Describe 'Open Documents' {
	Describe '<Name>' -ForEach @(
		$DestinationDocFile | Get-Item |
		ForEach-Object { @{ Name = $_.Name; FullName = $_.FullName } }
	) {
		It 'is valid (by ODFValidator)' -Tag 'ODFValidator' {
			# chcp 866 > $null;
			try
			{
				java -D"file.encoding=UTF-8" -jar $ODFValidatorJarPath -e -w $FullName
			}
			finally
			{
				# chcp 65001 > $null;
			}
			$LASTEXITCODE | Should -Be 0;
		}
	}
}

Expected Behavior

Desired output:

> Executing task: Invoke-Pester -Configuration ( Import-PowerShellDataFile -LiteralPath '.\tests\pester-config.psd1' ) <

Pester v5.3.0

Starting discovery in 2 files.
Discovery found 14 tests in 1.19s.
Running tests.

Running tests from 'Documents.Tests.ps1'
Describing Open Documents
 Describing Доверенность.odt
   [+] is valid (by ODFValidator) 2.46s (2.35s|106ms)
 Describing Должностная инструкция.odt
   [+] is valid (by ODFValidator) 2s (2s|4ms)
 Describing Письмо о коммерческом предложении на работы (ОЕИ).odt
C:\Users\sergei.s.betke\Documents\DocTemplates\output\doc\Письмо о коммерческом предложении на работы (ОЕИ).odt/content.xml[3,54]:  Error: element "text:a" is missing "type" attribute
xt:a xlink:href="tel:+7-8162-60-77-47"><!-- http://tools.ietf.org/html/rfc3966
                                 ----^
   [-] is valid (by ODFValidator) 2.21s (2.2s|14ms)
    at $LASTEXITCODE | Should -Be 0;, C:\Users\sergei.s.betke\Documents\DocTemplates\tests\doc\Documents.Tests.ps1:57
    Expected 0, but got 1.
 Describing Письмо сопроводительное к актам сверки.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|5ms)
 Describing Письмо сопроводительное.odt
   [+] is valid (by ODFValidator) 1.97s (1.96s|11ms)
 Describing Письмо.odt
   [+] is valid (by ODFValidator) 2.1s (2.09s|7ms)
 Describing Положение о подразделении.odt
   [+] is valid (by ODFValidator) 2.07s (2.06s|9ms)
 Describing Приказ.odt
   [+] is valid (by ODFValidator) 1.95s (1.95s|6ms)
 Describing Профессиональная инструкция.odt
   [+] is valid (by ODFValidator) 1.93s (1.93s|3ms)
 Describing Распоряжение (приказ) о введении в действие документа СМ.odt
   [+] is valid (by ODFValidator) 1.98s (1.97s|5ms)
 Describing Распоряжение.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|3ms)
 Describing Служебная записка.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|4ms)
 Describing Справка.odt
   [+] is valid (by ODFValidator) 1.95s (1.94s|3ms)

Running tests from 'Templates.Tests.ps1'
Describing Open Document templates
 Describing ОРД ФБУ Тест-С.-Петербург v2.ott
   [+] is valid (by ODFValidator) 2.14s (2.13s|17ms)
Tests completed in 32.01s
Tests Passed: 13, Failed: 1, Skipped: 0 NotRun: 0
Процесс терминала "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command Invoke-Pester -Configuration ( Import-PowerShellDataFile -LiteralPath '.\tests\pester-config.psd1' )" был завершен с кодом выхода 1.

Current Behavior

Output:

Starting discovery in 2 files.
Discovery found 14 tests in 1.19s.
Running tests.

Running tests from 'Documents.Tests.ps1'
Describing Open Documents
 Describing Доверенность.odt
   [+] is valid (by ODFValidator) 2.46s (2.35s|106ms)
 Describing Должностная инструкция.odt
   [+] is valid (by ODFValidator) 2s (2s|4ms)
 Describing Письмо о коммерческом предложении на работы (ОЕИ).odt
C:\Users\sergei.s.betke\Documents\DocTemplates\output\doc\Письмо о коммерческом предложении на работы (ОЕИ).odt/content.xml[3,54]:  Error: element "text:a" is missing "type" attribute
xt:a xlink:href="tel:+7-8162-60-77-47"><!-- http://tools.ietf.org/html/rfc3966
                                 ----^
   [-] is valid (by ODFValidator) 2.21s (2.2s|14ms)
    at $LASTEXITCODE | Should -Be 0;, C:\Users\sergei.s.betke\Documents\DocTemplates\tests\doc\Documents.Tests.ps1:57
    в Invoke-Assertion, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 8078
    в Should<End>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 8016
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\DocTemplates\tests\doc\Documents.Tests.ps1: строка 57
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
    в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2110
    в Invoke-TestItem, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1184
    в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 826
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
    в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
    в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
    в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
    в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
    в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
    в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1662
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.ps1: строка 3
    в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 3154
    в Invoke-InNewScriptScope, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 3161
    в Run-Test, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1665
    в Invoke-Test, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2465
    в Invoke-Pester<End>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 5225
    в <ScriptBlock>, <Нет файла>: строка 1
    Expected 0, but got 1.
 Describing Письмо сопроводительное к актам сверки.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|5ms)
 Describing Письмо сопроводительное.odt
   [+] is valid (by ODFValidator) 1.97s (1.96s|11ms)
 Describing Письмо.odt
   [+] is valid (by ODFValidator) 2.1s (2.09s|7ms)
 Describing Положение о подразделении.odt
   [+] is valid (by ODFValidator) 2.07s (2.06s|9ms)
 Describing Приказ.odt
   [+] is valid (by ODFValidator) 1.95s (1.95s|6ms)
 Describing Профессиональная инструкция.odt
   [+] is valid (by ODFValidator) 1.93s (1.93s|3ms)
 Describing Распоряжение (приказ) о введении в действие документа СМ.odt
   [+] is valid (by ODFValidator) 1.98s (1.97s|5ms)
 Describing Распоряжение.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|3ms)
 Describing Служебная записка.odt
   [+] is valid (by ODFValidator) 1.97s (1.97s|4ms)
 Describing Справка.odt
   [+] is valid (by ODFValidator) 1.95s (1.94s|3ms)

Running tests from 'Templates.Tests.ps1'
Describing Open Document templates
 Describing ОРД ФБУ Тест-С.-Петербург v2.ott
   [+] is valid (by ODFValidator) 2.14s (2.13s|17ms)
Tests completed in 32.01s
Tests Passed: 13, Failed: 1, Skipped: 0 NotRun: 0
Процесс терминала "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command Invoke-Pester -Configuration ( Import-PowerShellDataFile -LiteralPath '.\tests\pester-config.psd1' )" был завершен с кодом выхода 1.
@sergey-s-betke sergey-s-betke changed the title Disable verbosity exception output (stacktrace) for failed tests Disable verbosity exception output for failed tests Aug 21, 2021
@fflaten
Copy link
Collaborator

fflaten commented Aug 21, 2021

AFAIK the stacktrace above showing the internal calls in Pester.psm1 should only be shown when using the configuration options Run.StackTraceVerbosity = 'Full' (new in Pester 5.3.0) or Debug.ShowFullStackTrace = $true.

Is it possible that you have one of these in set in $global:PesterPreference or in the pester-config.psd1 ?

@sergey-s-betke
Copy link
Author

AFAIK the stacktrace above showing the internal calls in Pester.psm1 should only be shown when using the configuration options Run.StackTraceVerbosity = 'Full' (new in Pester 5.3.0) or Debug.ShowFullStackTrace = $true.

Is it possible that you have one of these in set in $global:PesterPreference or in the pester-config.psd1 ?

No, I have not Run.StackTraceVerbosity or Debug.ShowFullStackTrace in config .psd1 file... now I set there options. I need some times for tests...

@sergey-s-betke
Copy link
Author

AFAIK the stacktrace above showing the internal calls in Pester.psm1 should only be shown when using the configuration options Run.StackTraceVerbosity = 'Full' (new in Pester 5.3.0) or Debug.ShowFullStackTrace = $true.

Is it possible that you have one of these in set in $global:PesterPreference or in the pester-config.psd1 ?

This is my config file : https://github.com/test-st-petersburg/DocTemplates/blob/master/tests/pester-config.psd1

@fflaten
Copy link
Collaborator

fflaten commented Aug 22, 2021

Thanks. This issue is caused by your non-english system language. We currently filter the stacktrace using regex-patterns looking for english stacktrace.

[String]$isPesterFunction = '^at .*, .*\\Pester.psm1: line [0-9]*$'
[String]$isShould = '^at (Should<End>|Invoke-Assertion), .*\\Pester.psm1: line [0-9]*$'

@fflaten fflaten changed the title Disable verbosity exception output for failed tests Stacktrace is not filtered in non-english system languages Jul 17, 2022
Nacos added a commit to Nacos/Pester that referenced this issue Dec 14, 2022
…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.
@Akturos Akturos mentioned this issue Sep 20, 2023
5 tasks
@nohwnd
Copy link
Member

nohwnd commented Apr 11, 2024

I cannot repro this on windows 11 CZ installation. Is this still an issue with recent 5.1 powershell?

image

@nohwnd
Copy link
Member

nohwnd commented Jul 2, 2024

I would love to fix, but we don't have a repro for the original problem so it looks like it is not a problem anymore. If someone finds out how to repro, or even better, test this. We can re-open.

@nohwnd nohwnd closed this as completed Jul 2, 2024
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

No branches or pull requests

3 participants