-
Notifications
You must be signed in to change notification settings - Fork 393
Changes to allow tests to be run outside of CI #882
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
Changes to allow tests to be run outside of CI #882
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work but maybe the upgrade to Pester v4 should be a separate PR?
@@ -97,19 +97,16 @@ Describe "Test importing correct customized rules" { | |||
$customizedRulePath.Count | Should Be 1 | |||
} | |||
|
|||
It "will show the custom rule when given a rule folder path with trailing backslash" { | |||
It "will show the custom rule when given a rule folder path with trailing backslash" -skip:(!$IsWindows){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are planning to introduce a Travis
build for Linux/Mac as well? I think it would be good if you open an issue with a brief description of the high level plan of PR's to come so that we can see the big picture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, that's the plan, I'll work on that issue
the start is here: #886
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Looks good to me.
} | ||
|
||
It "will show the custom rules when given a glob" { | ||
# needs fixing for Linux | ||
$expectedNumRules = 4 | ||
if (Test-PSEditionCoreCLRLinux) | ||
if ( ! $IsWindows ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor but here and in other changes the spacing inside the parenthesis is inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure - will fix
$initialTestScript = Get-Content $directory\TestScriptWithFixableWarnings.ps1 -Raw | ||
BeforeAll { | ||
$scriptName = "TestScriptWithFixableWarnings.ps1" | ||
$testSource = join-path $PSScriptRoot ${scriptName} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ${scriptName}
can be simplified to $scriptName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "${< name >}" is the formal identifier of the variable. I should have done it to the first variable too. You'll start to see more of these in my PRs. I should note that this is much different than "$($variable)"
which is definitely unneeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree that braces make sense inside a string for string interpolation and is better than "$($variable)"
but can you briefly explain please why one would use curly braces for variables outside of strings (the only use case that I found here is when the variable name itself contains special characters) or is this just a question of style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case above it's inconsistent (since it's not used with $PSScriptRoot
so it's a bit confusing. My preference is to use braces all the time (sort of like full commands vs aliases), and it's mostly habit. When I'm in a hurry, I sometimes omit them.
Since most don't have them, I removed them here to avoid the confusion
@@ -63,7 +63,7 @@ Param | |||
$RequiredVersion | |||
) | |||
|
|||
# #Requires -Module @{ModuleName = 'Pester'; ModuleVersion = '3.4.0'} | |||
# #Requires -Module @{ModuleName = 'Pester'; ModuleVersion = '4.1.1'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a technical reason to upgrade to v4 as part of this PR? I think it might be better to do this as a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test fixes are sort of entwined, by doing them all at once I won't need to change the tests again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see. Then we also need to update the documented version number of Pester in the test section here of the developer guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite right - fixed
@@ -106,7 +106,7 @@ function SuppressPwdParam() | |||
} | |||
|
|||
Context "Rule suppression within DSC Configuration definition" { | |||
It "Suppresses rule" -skip:((Test-PSEditionCoreCLRLinux) -or ($PSVersionTable.PSVersion -lt [Version]'5.0.0')) { | |||
It "Suppresses rule" -skip:((!$IsWindows) -or ($PSVersionTable.PSVersion -lt [Version]'5.0.0')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$PSVersionTable.PSVersion.Major -lt 5
looks more elegant to me but this might be just a question of style and therefore opinionated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fine - I have no preference
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a change of the file's encoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't look like it. it looks like there was previously no newline at the end of the file.
@@ -66,7 +66,7 @@ $x = @{ } | |||
} | |||
|
|||
Context "When assignment statements are in DSC Configuration" { | |||
It "Should find violations when assignment statements are not aligned" { | |||
It "Should find violations when assignment statements are not aligned" -skip:($IsLinux -or $IsMacOS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simply !$isWindows
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah
@@ -29,7 +29,7 @@ Describe "UseIdenticalMandatoryParametersForDSC" { | |||
} | |||
|
|||
# todo add a test to check one violation per function | |||
It "Should find a violations" { | |||
It "Should find a violations" -pending { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pending?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test is marked as TODO, and the comment seems like it is a test in potentio rather than something useful since it would only be checking a file that is known to be good.
416c805
to
1dc2cf1
Compare
Mark some tests as pending that weren't actually doing anything Skip DSC tests on Mac/Linux
1dc2cf1
to
07075e5
Compare
Update to use Pester version 4.1.1 Change logic in appveyor to invoke pester only once
07075e5
to
ad17fe8
Compare
@bergmeister I think this is ready now - what do you think? |
@JamesWTruher Overall most changes look OK (although I cannot verify some technical details why some stuff does not work on Windows but I think it is OK to trust to you on that).
|
I'm actually not sure why there are differences between the platforms either, my changes were more mechanical (removing the broken check for linux, which didn't include mac, etc). I will continue to investigate that. As for the update to Pester 4 syntax, that's tracked in #890. |
PR Summary
Test and build changes to enable test execution outside of CI environment
Reduce verbosity of buildCore script
Simplify test execution to a single command with a single result file
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 PRNA
.WIP:
to the beginning of the title and remove the prefix when the PR is ready