Skip to content

Commit 9c9b542

Browse files
sanfrancriskoCiaran McCrisken
authored andcommitted
(maint) Remove interpolate_powershell method
This was added to Litmus so we can remove it here. Also keeps this one from diverging if the Litmus version changes. Use full namespace method call Convert to fully qualified namespace method calls Include 'puppet_litmus/util' Fix interpolate_powershell method ref (maint) Fix typo (maint) Fix another typo!
1 parent cda4c37 commit 9c9b542

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

spec/acceptance/exec_powershell_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@
243243
}
244244

245245
after(:each) do
246-
run_shell(interpolate_powershell("Remove-Item Env:\\superspecial -ErrorAction Ignore;exit 0"))
247-
run_shell(interpolate_powershell("Remove-Item Env:\\outside -ErrorAction Ignore;exit 0"))
246+
run_shell(PuppetLitmus::Util.interpolate_powershell("Remove-Item Env:\\superspecial -ErrorAction Ignore;exit 0"))
247+
run_shell(PuppetLitmus::Util.interpolate_powershell("Remove-Item Env:\\outside -ErrorAction Ignore;exit 0"))
248248
end
249249

250250
it 'should not see environment variable from previous run' do
@@ -258,7 +258,7 @@
258258
it 'should see environment variables set outside of session' do
259259
# Setup the environment variable outside of Puppet
260260

261-
run_shell(interpolate_powershell("$env:outside='1'"))
261+
run_shell(PuppetLitmus::Util.interpolate_powershell("$env:outside='1'"))
262262

263263
# Test to see if initial run sees the environment variable
264264
apply_manifest(envar_leak_test_pp, expect_changes: true)

spec/acceptance/exec_pwsh_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ def platform_string(windows, posix)
280280
after(:each) do
281281
# Due to https://tickets.puppetlabs.com/browse/BKR-1088, need to use different commands
282282
if windows_platform?
283-
run_shell(interpolate_powershell("Remove-Item Env:\\superspecial -ErrorAction Ignore;exit 0"))
284-
run_shell(interpolate_powershell("Remove-Item Env:\\outside -ErrorAction Ignore;exit 0"))
283+
run_shell(PuppetLitmus::Util.interpolate_powershell("Remove-Item Env:\\superspecial -ErrorAction Ignore;exit 0"))
284+
run_shell(PuppetLitmus::Util.interpolate_powershell("Remove-Item Env:\\outside -ErrorAction Ignore;exit 0"))
285285
else
286286
run_shell('unset superspecial')
287287
run_shell('unset outside')
@@ -301,7 +301,7 @@ def platform_string(windows, posix)
301301

302302
# Due to https://tickets.puppetlabs.com/browse/BKR-1088, need to use different commands
303303
if windows_platform?
304-
run_shell(interpolate_powershell("\$env:outside='1'"))
304+
run_shell(PuppetLitmus::Util.interpolate_powershell("\$env:outside='1'"))
305305
else
306306
run_shell('export outside=1')
307307
end

spec/spec_helper_acceptance_local.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'puppet_litmus'
2+
require 'puppet_litmus/util'
23
require 'singleton'
34

45
class Helper
@@ -32,7 +33,7 @@ def uninstall_pwsh
3233
when 'darwin'
3334
'brew cask uninstall powershell'
3435
when 'windows'
35-
interpolate_powershell('Get-Command pwsh | ForEach-Object { Remove-Item -Path (Split-Path -Parent $_.Path) -Recurse -Force }')
36+
PuppetLitmus::Util.interpolate_powershell('Get-Command pwsh | ForEach-Object { Remove-Item -Path (Split-Path -Parent $_.Path) -Recurse -Force }')
3637
end
3738
Helper.instance.run_shell(command)
3839
end
@@ -50,11 +51,6 @@ def cleanup_files
5051
Helper.instance.apply_manifest(absent_files_manifest, catch_failures: true)
5152
end
5253

53-
def interpolate_powershell(command)
54-
encoded_command = Base64.strict_encode64(command.encode('UTF-16LE'))
55-
"powershell.exe -NoProfile -EncodedCommand #{encoded_command}"
56-
end
57-
5854
def relative_folder(relative_path)
5955
expanded_path = File.expand_path(File.join(File.dirname(__FILE__), relative_path))
6056
Dir.open(expanded_path) if File.exist?(expanded_path)

0 commit comments

Comments
 (0)