Skip to content

Commit da13ee6

Browse files
committed
Merge pull request #195 from mattbrictson/future-wait
Use Future#wait! to ensure concurrent compile exceptions are re-raised
2 parents eaed749 + 03048cb commit da13ee6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/sprockets/manifest.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ def compile(*args)
202202
logger.debug "Skipping #{target}.gz, already exists"
203203
else
204204
logger.info "Writing #{target}.gz"
205-
concurrent_compressors << Concurrent::Future.execute { write_file.wait; gzip.compress(target) }
205+
concurrent_compressors << Concurrent::Future.execute { write_file.wait!; gzip.compress(target) }
206206
end
207207

208208
end
209-
concurrent_writers.each(&:wait)
210-
concurrent_compressors.each(&:wait)
211-
Concurrent::Future.execute { self.save }.wait
209+
concurrent_writers.each(&:wait!)
210+
concurrent_compressors.each(&:wait!)
211+
save
212212

213213
filenames
214214
end

test/test_manifest.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,4 +657,11 @@ def teardown
657657
refute File.exist?("#{@dir}/#{original_path}.gz"), "Expecting '#{original_path}' to not generate gzipped file: '#{original_path}.gz' but it did"
658658
end
659659
end
660+
661+
test 'raises exception when gzip fails' do
662+
manifest = Sprockets::Manifest.new(@env, @dir)
663+
Zlib::GzipWriter.stub(:new, -> { fail 'kaboom' }) do
664+
assert_raises('kaboom') { manifest.compile('application.js') }
665+
end
666+
end
660667
end

0 commit comments

Comments
 (0)