Skip to content

Invoke-Formatter has knock on effect on subsequent call to Invoke-ScriptAnalyzer #1116

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

Closed
bergmeister opened this issue Dec 21, 2018 · 0 comments · Fixed by #1121
Closed

Comments

@bergmeister
Copy link
Collaborator

bergmeister commented Dec 21, 2018

Steps to reproduce

Using the latest state of the development branch (but also applies to RTM version of 1.17.1 and 1.16.1, therefore the bug has been present even before I joined the project).
I believe this bug is the main culprit of PSSA's tests sometimes becoming flaky and starting to fail sometimes when the test order changes.
cc @JamesWTruher

Describe "PSSA bug" {
	It "Invoke-ScriptAnalyzer works fine" {
		Invoke-ScriptAnalyzer -ScriptDefinition 'gci' | Should -Not -BeNullOrEmpty
	}

	It "Invoke-Formatter has knock on effect on Invoke-ScriptAnalyzer" {
		Invoke-Formatter 'foo'
		Invoke-ScriptAnalyzer -ScriptDefinition 'gci' | Should -Not -BeNullOrEmpty
	}

	It "Invoke-Formatter has knock on effect on Invoke-ScriptAnalyzer but it works the 2nd time" {
		Invoke-Formatter 'foo'
		Invoke-ScriptAnalyzer -ScriptDefinition 'gci'
		Invoke-ScriptAnalyzer -ScriptDefinition 'gci' | Should -Not -BeNullOrEmpty
	}
}

The 2nd test will fail, which is exposing the problem

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17763.134
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.134
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.1
@bergmeister bergmeister changed the title Invoke-Formatter has knock on effect on susequent call to Invoke-ScriptAnalyzer Invoke-Formatter has knock on effect on subsequent call to Invoke-ScriptAnalyzer Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant