-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add support for unit testing via Unix OS #309
Add support for unit testing via Unix OS #309
Conversation
…thin spec context
…r unit testing on unix os
…stead of `;` set via Windows os context in rspec
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #309 +/- ##
==========================================
+ Coverage 91.98% 92.01% +0.03%
==========================================
Files 6 6
Lines 711 714 +3
==========================================
+ Hits 654 657 +3
Misses 57 57 ☔ View full report in Codecov by Sentry. |
8dd7630
to
4db604a
Compare
4db604a
to
56a4b81
Compare
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.
@chambersmp This is amazing work. I've left what is really just a small suggestion rather than anything else. Other than that this LGTM
Summary
Adds cross-platform unit testing support for resources implemented by the
dsc_base_provider.pwshon non-Windows.Additional Context
Root Cause
dsc_base_provideris hardcoded to use Windows PowerShell paths instead of the platform agnosticpwshwhich forces unit testing on non-Windows OS to fail waiting for a PowerShell process to respond.After Fix:
dsc_base_provideris configured to usepwshwhenPwsh::Utils.on_windows?returnsfalse, compilation completes successfully on Unix.pwshmust be installed locally on the OS running the spec test.Thought process behind the implementation.
pwshmust be installed on the Unix OS running the spec test as this is a dependency for compilation.canonicalizefeature during catalog compilation (Depends on pwsh)canonicalizeis implemented entirely within the Ruby without external process calls. Thedsc_base_providerhas been configured to make external process calls to PowerShell which currently fail on Unix OS.canonicalizeaims to prevent corrective changes for case-mismatch by comparing user supplied values (manifest) and machine current state (invoke-dscresource -method Get) during catalog compilation.canonicalizeimplementation fordsc_base_provideruses an external PowerShell process via a named pipe to query the dsc resources on the target node (i.e agent or local OS executing unit test).compile.with_all_dependenciestest is run, the PowerShell process attempts to query the local hosts state (i.e. start PowerShell process on Unix OS looking to get current state of Windows DSC resources declared within the rspec context).pwshinstead ofPowerShell.pwshprocess and runinvoke-dscresouce -method Getfor each resource defined in the manifest.nilfor current state.pwshincorrectly uses ';' instead of ':'.pwshbeforeblock to mock Pwsh::Util.on_windows? =>falseto force the spec tests tof follow the non-Windows conditional logic similar to the updated spec tests for the ruby-pwsh.Pwsh::Util.on_windows?mock does not persist forcompile.with_all_depsand therefore cannot force Unix hosts to take this path. It is overwritten on compilation resulting => true.pwshoverPowerShellon UnixRelated Issues (if any)
Resolves #308
Checklist