Skip to content

Commit 65a7c48

Browse files
author
Erick Banks
committed
(WIN-280) add skip() unless pattern to tests
to facilitate more complete test output from our unit tests.
1 parent a250d39 commit 65a7c48

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

spec/integration/puppet_x/puppetlabs/powershell_manager_spec.rb

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ def close_stream(stream, style = :inprocess)
173173
expect_different_manager_returned_than(manager, first_pid)
174174
end
175175

176-
context "on Windows", :if => Puppet::Util::Platform.windows? do
176+
context "on Windows" do
177177
# On Windows we're using named pipes so these tests only apply on Windows.
178+
before :each do
179+
skip('Not on Windows platform') unless Puppet::Util::Platform.windows?
180+
end
181+
178182
it "should create a new PowerShell manager host if the input stream is closed" do
179183
first_pid = manager.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
180184

@@ -647,12 +651,13 @@ def output_cmdlet(ps_command, ps_args)
647651
expect(result[:errormessage]).to match(/Working directory .+ does not exist/)
648652
end
649653

650-
it "should allow forward slashes in working directory", :if => Puppet::Util::Platform.windows? do
654+
it "should allow forward slashes in working directory" do
655+
skip('Not on Windows platform') unless Puppet::Util::Platform.windows?
651656
# Backslashes only apply on Windows filesystems
652657
work_dir = ENV["WINDIR"]
653658
forward_work_dir = work_dir.gsub('\\','/')
654659

655-
result = manager.execute('(Get-Location).Path',nil,work_dir)[:stdout]
660+
result = manager.execute('(Get-Location).Path',nil,forward_work_dir)[:stdout]
656661

657662
expect(result).to eq("#{work_dir}#{line_end}")
658663
end
@@ -802,18 +807,22 @@ def output_cmdlet(ps_command, ps_args)
802807
end
803808
end
804809

805-
if Puppet::Util::Platform.windows? && PuppetX::PowerShell::PowerShellManager.supported?
806-
describe "On Windows PowerShell" do
807-
it_should_behave_like "a PowerShellManager",
808-
Puppet::Type.type(:exec).provider(:powershell).command(:powershell),
809-
Puppet::Type.type(:exec).provider(:powershell).powershell_args
810+
describe "On Windows PowerShell" do
811+
before :each do
812+
skip unless Puppet::Util::Platform.windows? && PuppetX::PowerShell::PowerShellManager.supported?
810813
end
814+
815+
it_should_behave_like "a PowerShellManager",
816+
Puppet::Type.type(:exec).provider(:powershell).command(:powershell),
817+
Puppet::Type.type(:exec).provider(:powershell).powershell_args
811818
end
812819

813-
if PuppetX::PowerShell::PowerShellManager.supported_on_pwsh? && !Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command.nil?
814-
describe "On PowerShell Core" do
815-
it_should_behave_like "a PowerShellManager",
816-
Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command,
817-
Puppet::Type.type(:exec).provider(:pwsh).new().pwsh_args
820+
describe "On PowerShell Core" do
821+
before :each do
822+
skip unless PuppetX::PowerShell::PowerShellManager.supported_on_pwsh? && !Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command.nil?
818823
end
824+
825+
it_should_behave_like "a PowerShellManager",
826+
Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command,
827+
Puppet::Type.type(:exec).provider(:pwsh).new().pwsh_args
819828
end

spec/unit/provider/exec/powershell_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@
141141
end
142142

143143
describe 'when specifying a working directory' do
144-
describe 'that does not exist on Windows', :if => Puppet.features.microsoft_windows? do
144+
describe 'that does not exist on Windows' do
145+
before :each do
146+
skip('Not on Windows platform') unless Puppet.features.microsoft_windows?
147+
end
148+
145149
# This working directory error is specific to the PowerShell manager on Windows.
146150
let(:work_dir) { "#{ENV['SYSTEMROOT']}\\some\\directory\\that\\does\\not\\exist" }
147151
let(:command) { 'exit 0' }
@@ -154,7 +158,7 @@
154158
end
155159
end
156160

157-
describe 'when applying a catalog', :if => Puppet.features.microsoft_windows? do
161+
describe 'when applying a catalog' do
158162
let(:manifest) { <<-MANIFEST
159163
exec { 'PS':
160164
command => 'exit 0',
@@ -165,6 +169,7 @@
165169
let(:tmpdir) { Dir.mktmpdir('statetmp').encode!(Encoding::UTF_8) }
166170

167171
before :each do
172+
skip('Not on Windows platform') unless Puppet.features.microsoft_windows?
168173
# a statedir setting must now exist per the new transactionstore code
169174
# introduced in Puppet 4.6 for corrective changes, as a new YAML file
170175
# called transactionstore.yaml will be written under this path

spec/unit/provider/exec/pwsh_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def execute_resource(*_args)
5555
provider.run_spec_override(command)
5656
end
5757

58-
it "should quote the path to the temp file", :if => Puppet.features.microsoft_windows? do
58+
it "should quote the path to the temp file" do
59+
skip('Not on Windows platform') unless Puppet.features.microsoft_windows?
5960
# Path quoting is only required on Windows
6061
path = 'C:\Users\albert\AppData\Local\Temp\puppet-powershell20130715-788-1n66f2j.ps1'
6162

spec/unit/puppet_x/puppetlabs/powershell/compatible_powershell_version_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
require 'puppet_x/puppetlabs/powershell/powershell_version'
55
require 'puppet_x/puppetlabs/powershell/compatible_powershell_version'
66

7-
describe PuppetX::PuppetLabs::PowerShell::CompatiblePowerShellVersion, :if => Puppet::Util::Platform.windows? do
7+
describe PuppetX::PuppetLabs::PowerShell::CompatiblePowerShellVersion do
88
before(:each) do
9+
skip('Not on Windows platform') unless Puppet.features.microsoft_windows?
910
@compat = PuppetX::PuppetLabs::PowerShell::CompatiblePowerShellVersion
1011
end
1112

spec/unit/puppet_x/puppetlabs/powershell/powershell_version_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
require 'puppet/type'
44
require 'puppet_x/puppetlabs/powershell/powershell_version'
55

6-
describe PuppetX::PuppetLabs::PowerShell::PowerShellVersion, :if => Puppet::Util::Platform.windows? do
6+
describe PuppetX::PuppetLabs::PowerShell::PowerShellVersion do
77
before(:each) do
8+
skip('Not on Windows platform') unless Puppet.features.microsoft_windows?
89
@ps = PuppetX::PuppetLabs::PowerShell::PowerShellVersion
910
end
1011

0 commit comments

Comments
 (0)