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

Migrate Pester version detection into an InovkePester stub script #1776

Merged
merged 6 commits into from
Mar 5, 2019

Conversation

rkeithhill
Copy link
Contributor

PR Summary

Alternate implementation of invoking pester tests by line number. See PR #1713

This PR requires the changes that @bergmeister is working on in the PSES PR 856 That PR can now be simplified since it does not need to determine the Pester version number. It just always returns the line number.

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • [] This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@bergmeister
Copy link
Contributor

Hmm, interesting idea and solves the startup problem and I guess the additional overhead of always running the check is negligible since PowerShell itself does some of the caching. The only thing that I do not like is that I cannot just press the up key in the console any more to see and modify the executed command, which I sometimes like to do. What did you think about my recent idea of changing my PR to query PSES for the Pester version before Invoking the command to separate the construction of the codelens and the determination/decision of the Pester version?

@rjmholt
Copy link
Contributor

rjmholt commented Mar 2, 2019

What did you think about my recent idea of changing my PR to query PSES for the Pester version before Invoking the command to separate the construction of the codelens and the determination/decision of the Pester version?

The thing that occurred to me is that the Integrated Console can override any cached value at any time. It's unlikely, but a user might unload the higher version of Pester and load in the older version, and now the CodeLens doesn't work. Imagine removing all modules in the Integrated Console and then calling a command that loads a module that pulls in a lower Pester version. It's a pain because it means we're forced to check every time we execute.

@bergmeister
Copy link
Contributor

Ok, let's go for Keith's approach then

@rkeithhill
Copy link
Contributor Author

@bergmeister Just to be clear, you can press the up key and get the script invocation command if you want to re-execute it. But yeah, the parameters to Invoke-Pester are hidden. If you think that is important we can Write-Host the Invoke-Pester command that is executed?

If we go with this approach, can you revert your PSES PR back to just adding the lineNumber to the info returned by the code lens request? Then we can call this enhancement done. Yay! :-)

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Mar 2, 2019

@TylerLeonhardt or @rjmholt Can one of you double check that the stub script runs on Linux and macOS?

@bergmeister
Copy link
Contributor

@rkeithhill Hmm, looking at your script again, a user would still see and be able to modify the parameters, so although one cannot see the actual command, this would make me most people like me happy enough :-)
I think your idea./approach is probably better and involves less complexity and I'm happy to admit that. I guess it's easier to just create a new PSES PR with adding this 1 line in PSES to send the line back

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 3, 2019

I like this approach! So, if we have the PowerShell script handling the check, the PSES change is simply returning CodeLens's if there's a Describe block?

p.s. works on macOS

@rkeithhill
Copy link
Contributor Author

InvokePesterStub.ps1 Show resolved Hide resolved
InvokePesterStub.ps1 Outdated Show resolved Hide resolved
@rkeithhill rkeithhill merged commit 723433b into master Mar 5, 2019
@rkeithhill rkeithhill deleted the rkeithhill/add-invoke-pester-stub branch March 5, 2019 21:28
TylerLeonhardt pushed a commit to TylerLeonhardt/vscode-powershell that referenced this pull request Mar 18, 2019
…werShell#1776)

* Migrate Pester version detection into an InovkePester stub script

* Move TestName warning into script

* Improve stub script, move module loaded check to beginning

* Address Codacy issue

* Address PR feedback

* Move TestName check before LineNumber in case of multiple blocks/line
TylerLeonhardt pushed a commit that referenced this pull request Mar 20, 2019
)

* Migrate Pester version detection into an InovkePester stub script

* Move TestName warning into script

* Improve stub script, move module loaded check to beginning

* Address Codacy issue

* Address PR feedback

* Move TestName check before LineNumber in case of multiple blocks/line
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.

4 participants