Skip to content

Commit

Permalink
Merge pull request #195 from mattbrictson/future-wait
Browse files Browse the repository at this point in the history
Use Future#wait! to ensure concurrent compile exceptions are re-raised
  • Loading branch information
schneems committed Dec 4, 2015
2 parents eaed749 + 03048cb commit da13ee6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ def compile(*args)
logger.debug "Skipping #{target}.gz, already exists"
else
logger.info "Writing #{target}.gz"
concurrent_compressors << Concurrent::Future.execute { write_file.wait; gzip.compress(target) }
concurrent_compressors << Concurrent::Future.execute { write_file.wait!; gzip.compress(target) }
end

end
concurrent_writers.each(&:wait)
concurrent_compressors.each(&:wait)
Concurrent::Future.execute { self.save }.wait
concurrent_writers.each(&:wait!)
concurrent_compressors.each(&:wait!)
save

filenames
end
Expand Down
7 changes: 7 additions & 0 deletions test/test_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,11 @@ def teardown
refute File.exist?("#{@dir}/#{original_path}.gz"), "Expecting '#{original_path}' to not generate gzipped file: '#{original_path}.gz' but it did"
end
end

test 'raises exception when gzip fails' do
manifest = Sprockets::Manifest.new(@env, @dir)
Zlib::GzipWriter.stub(:new, -> { fail 'kaboom' }) do
assert_raises('kaboom') { manifest.compile('application.js') }
end
end
end

0 comments on commit da13ee6

Please sign in to comment.