-
Notifications
You must be signed in to change notification settings - Fork 25
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
.pwsh
on non-Windows.Additional Context
Root Cause
dsc_base_provider
is hardcoded to use Windows PowerShell paths instead of the platform agnosticpwsh
which forces unit testing on non-Windows OS to fail waiting for a PowerShell process to respond.After Fix:
dsc_base_provider
is configured to usepwsh
whenPwsh::Utils.on_windows?
returnsfalse
, compilation completes successfully on Unix.pwsh
must be installed locally on the OS running the spec test.Thought process behind the implementation.
pwsh
must be installed on the Unix OS running the spec test as this is a dependency for compilation.canonicalize
feature during catalog compilation (Depends on pwsh)canonicalize
is implemented entirely within the Ruby without external process calls. Thedsc_base_provider
has been configured to make external process calls to PowerShell which currently fail on Unix OS.canonicalize
aims to prevent corrective changes for case-mismatch by comparing user supplied values (manifest) and machine current state (invoke-dscresource -method Get) during catalog compilation.canonicalize
implementation fordsc_base_provider
uses 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_dependencies
test 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).pwsh
instead ofPowerShell
.pwsh
process and runinvoke-dscresouce -method Get
for each resource defined in the manifest.nil
for current state.pwsh
incorrectly uses ';' instead of ':'.pwsh
before
block to mock Pwsh::Util.on_windows? =>false
to 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_deps
and therefore cannot force Unix hosts to take this path. It is overwritten on compilation resulting => true.pwsh
overPowerShell
on UnixRelated Issues (if any)
Resolves #308
Checklist