Skip to content

Commit 62ef1a5

Browse files
Merge pull request #251 from ThoughtCrhyme/WIN-280
(WIN-280) add skip() unless pattern to tests
2 parents 87408be + 65a7c48 commit 62ef1a5

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
@@ -178,8 +178,12 @@ def close_stream(stream, style = :inprocess)
178178
expect_different_manager_returned_than(manager, first_pid)
179179
end
180180

181-
context "on Windows", :if => Puppet::Util::Platform.windows? do
181+
context "on Windows" do
182182
# On Windows we're using named pipes so these tests only apply on Windows.
183+
before :each do
184+
skip('Not on Windows platform') unless Puppet::Util::Platform.windows?
185+
end
186+
183187
it "should create a new PowerShell manager host if the input stream is closed" do
184188
first_pid = manager.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
185189

@@ -655,12 +659,13 @@ def output_cmdlet(ps_command, ps_args)
655659
expect(result[:errormessage]).to match(/Working directory .+ does not exist/)
656660
end
657661

658-
it "should allow forward slashes in working directory", :if => Puppet::Util::Platform.windows? do
662+
it "should allow forward slashes in working directory" do
663+
skip('Not on Windows platform') unless Puppet::Util::Platform.windows?
659664
# Backslashes only apply on Windows filesystems
660665
work_dir = ENV["WINDIR"]
661666
forward_work_dir = work_dir.gsub('\\','/')
662667

663-
result = manager.execute('(Get-Location).Path',nil,work_dir)[:stdout]
668+
result = manager.execute('(Get-Location).Path',nil,forward_work_dir)[:stdout]
664669

665670
expect(result).to eq("#{work_dir}#{line_end}")
666671
end
@@ -810,18 +815,22 @@ def output_cmdlet(ps_command, ps_args)
810815
end
811816
end
812817

813-
if Puppet::Util::Platform.windows? && PuppetX::PowerShell::PowerShellManager.supported?
814-
describe "On Windows PowerShell" do
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
818+
describe "On Windows PowerShell" do
819+
before :each do
820+
skip unless Puppet::Util::Platform.windows? && PuppetX::PowerShell::PowerShellManager.supported?
818821
end
822+
823+
it_should_behave_like "a PowerShellManager",
824+
Puppet::Type.type(:exec).provider(:powershell).command(:powershell),
825+
Puppet::Type.type(:exec).provider(:powershell).powershell_args
819826
end
820827

821-
if PuppetX::PowerShell::PowerShellManager.supported_on_pwsh? && !Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command.nil?
822-
describe "On PowerShell Core" do
823-
it_should_behave_like "a PowerShellManager",
824-
Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command,
825-
Puppet::Type.type(:exec).provider(:pwsh).new().pwsh_args
828+
describe "On PowerShell Core" do
829+
before :each do
830+
skip unless PuppetX::PowerShell::PowerShellManager.supported_on_pwsh? && !Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command.nil?
826831
end
832+
833+
it_should_behave_like "a PowerShellManager",
834+
Puppet::Type.type(:exec).provider(:pwsh).new().get_pwsh_command,
835+
Puppet::Type.type(:exec).provider(:pwsh).new().pwsh_args
827836
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)