Skip to content

Check scope of Set-Variable to resolve #1107#1109

Merged
nohwnd merged 5 commits intomasterfrom
unknown repository
Dec 12, 2018
Merged

Check scope of Set-Variable to resolve #1107#1109
nohwnd merged 5 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 3, 2018

1. General summary of the pull request

Very small change to Invoke-Mock. Added a change to Set-Variable mocking to include a scope parameter of Global. This is intended to resolve #1107

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Oct 4, 2018

Thanks for the PR, but this is not the solution I described to you on Twitter. You need to add parameter -Scope 2 if there is none. Ignore the parameters if it is already Script or Global, which are non-relative scopes, or add 2 to the -Scope parameter if it is present and numeric.

Setting all the mocked variables to Global scope might fix the one symptom, but it does not fix it in a clean way.

Also we need some tests for this. The two that are in the original issue should be a good start.

(you can simply fixup the solution and push to the same branch, the PR will update)

@ghost ghost changed the title Check scope of Set-Variable to resolve #1107 WIP: Check scope of Set-Variable to resolve #1107 Oct 10, 2018
@ghost
Copy link
Copy Markdown
Author

ghost commented Oct 10, 2018

So, I'm not sure if I am even close with resolving this issue. Your last comment leads me to believe I have missed the boat entirely.

Attempting to write some tests for this condition, I am not able to get Assert-MockCalled to return true.

What am I looking for is, am I on the right track or should I start over?

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Oct 11, 2018

@BrandonLundt seems to be quite close.

@ghost ghost changed the title WIP: Check scope of Set-Variable to resolve #1107 Check scope of Set-Variable to resolve #1107 Oct 24, 2018
@ghost
Copy link
Copy Markdown
Author

ghost commented Oct 24, 2018

Looking at the TeamCity build failures I see:

[Pester] Invoke-Pester swallows pipeline output from system-under-test.Should swallow test output without -PassThru [07:14:49][Invoke-Pester swallows pipeline output from system-under-test.Should swallow test output without -PassThru] Exception calling "Create" with "1" argument(s): "The process cannot access the file 'C:\TeamCity\BuildAgent\work\93ac3fcead2a62ac\Test.v2.xml' because it is being used by another process." [07:14:49][Invoke-Pester swallows pipeline output from system-under-test.Should swallow test output without -PassThru] at <ScriptBlock>, C:\TeamCity\BuildAgent\work\93ac3fcead2a62ac\Functions\TestResults.ps1: line 70 70: $xmlFile = [IO.File]::Create($Path)

Which I do not believe to be an issue with my pull request but rather with multiple items running in TeamCity at the same time.

Any ideas how I rerun these build tasks?

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Oct 25, 2018

@BrandonLundt yeah, I can re-run it, or you can push some change to the repository. But this already happened with some other build, so it might be a problem connected to migrating the builds to a different infrastructure. @dlwyatt you were doing some kind of upgrade recently, right? Have you observed this problem somewhere else?

@dlwyatt
Copy link
Copy Markdown
Member

dlwyatt commented Nov 5, 2018

Not that I've noticed. The agents are only supposed to be used for a single build and then discarded. Will check.

@nohwnd nohwnd merged commit 5674ba7 into pester:master Dec 12, 2018
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.

Mocks Set-Variable, works only for the first occurrence

2 participants