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

Enables strict mode testing of module, fix git restore --source= tab bug #783

Merged
merged 2 commits into from
Aug 3, 2020

Conversation

rkeithhill
Copy link
Collaborator

Also fixes bug in git flow feature tab completion.

Also fixes bug in git flow feature tab completion.
@rkeithhill rkeithhill requested a review from dahlbyk July 26, 2020 21:35
@rkeithhill rkeithhill force-pushed the rkeithhill/cleanup-pssa-warnings-strictmode-errs branch from b189581 to 0d2f471 Compare July 26, 2020 22:41
@rkeithhill rkeithhill merged commit 66b46b4 into master Aug 3, 2020
@rkeithhill rkeithhill deleted the rkeithhill/cleanup-pssa-warnings-strictmode-errs branch August 3, 2020 22:10
Comment on lines +3 to +6
if (Test-Path Env:\POSHGIT_ENABLE_STRICTMODE) {
# Set strict mode to latest to help catch scripting errors in the module. This is done by the Pester tests.
Set-StrictMode -Version Latest
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume Set-StrictMode is best done here rather than in test/Shared.ps1 to scope strictness to the module, rather than all tests too?

Hi, hello, yes it's me I still exist. Barely. 👋

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I found when I set it in Shared.ps1 that A) it complained about some of our "lose" scripting in the tests and B) it wasn't finding issues in the module. That goes counter to the claim in #758 but it makes sense that enabling set-strictmode in the module just for testing is the way to go - IMO.

BTW I don't think we want to leave strict mode on for ship because it will gen errors with user injected code like this:

$global:GitPromptSettings.DefaultPromptSuffix.Text = ' $((Get-History -Count 1).id + 1)$(">" * ($nestedPromptLevel + 1)) '

For example, when you first start PowerShell there is no history so Get-HIstory returns $null and strict-mode doesn't like the null de-ref to get the id. But for my prompt string it works out - $null + 1 is 1.

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.

2 participants