Skip to content

Commit

Permalink
Merge pull request #10965 from MSP-Greg/00-windows
Browse files Browse the repository at this point in the history
Windows specs - remove references to File objects before unlinking
  • Loading branch information
koic committed Aug 26, 2022
2 parents bd42ff6 + 5b1bb60 commit b4d8a1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/linting.yml
@@ -1,6 +1,7 @@
name: Linting
on:
- pull_request
- workflow_dispatch
jobs:
yamllint:
name: Yamllint
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rubocop.yml
Expand Up @@ -7,6 +7,7 @@ on:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
main:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@ doc
.bundle
Gemfile.lock
Gemfile.local
vendor/

# rbenv
.ruby-version
Expand Down
12 changes: 9 additions & 3 deletions spec/rubocop/formatter/formatter_set_spec.rb
Expand Up @@ -3,6 +3,11 @@
RSpec.describe RuboCop::Formatter::FormatterSet do
subject(:formatter_set) { described_class.new }

win_close = lambda do |fset|
fset.close_output_files
fset.each { |f| f.instance_variable_set :@output, nil }
end

it 'responds to all formatter API methods' do
%i[started file_started file_finished finished].each do |method|
expect(formatter_set).to respond_to(method)
Expand Down Expand Up @@ -52,6 +57,7 @@
formatter_set.add_formatter('simple', output_path)
expect(formatter_set.first.output.class).to eq(File)
expect(formatter_set.first.output.path).to eq(output_path)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end

context "when parent directories don't exist" do
Expand All @@ -60,13 +66,11 @@
after { FileUtils.rm_rf(tmpdir) }

it 'creates them' do
# FIXME: Skips this spec to prevent `Errno::EACCES` error in mingw CI matrix.
skip if ENV['GITHUB_JOB'] == 'main' && ENV['MSYSTEM'] == 'MINGW64'

output_path = File.join(tmpdir, 'path/does/not/exist')
formatter_set.add_formatter('simple', output_path)
expect(formatter_set.first.output.class).to eq(File)
expect(formatter_set.first.output.path).to eq(output_path)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end
end
end
Expand All @@ -91,10 +95,12 @@
it 'closes all output files' do
formatter_set.close_output_files
formatter_set[0..1].each { |formatter| expect(formatter.output.closed?).to be(true) }
win_close.call(formatter_set) if RuboCop::Platform.windows?
end

it 'does not close non file output' do
expect(formatter_set[2].output.closed?).to be(false)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end
end

Expand Down

0 comments on commit b4d8a1e

Please sign in to comment.