Skip to content

Commit

Permalink
try to ignore Errno::EACCES
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Aug 18, 2024
1 parent 81ad7f7 commit 8404888
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions test/test_epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -854,41 +854,45 @@ def test_epub_unsafe_id
end

def epubmaker_instance
Dir.mktmpdir do |tmpdir|
epubmaker = ReVIEW::EPUBMaker.new
epubmaker.instance_eval do
@config = ReVIEW::Configure.create(maker: 'epubmaker')
@config['titlepage'] = nil
@producer = ReVIEW::EPUBMaker::Producer.new(@config)

@htmltoc = ReVIEW::HTMLToc.new(tmpdir)

def config
@config
end

def producer
@producer
begin
Dir.mktmpdir do |tmpdir|
epubmaker = ReVIEW::EPUBMaker.new
epubmaker.instance_eval do
@config = ReVIEW::Configure.create(maker: 'epubmaker')
@config['titlepage'] = nil
@producer = ReVIEW::EPUBMaker::Producer.new(@config)

@htmltoc = ReVIEW::HTMLToc.new(tmpdir)

def config
@config
end

def producer
@producer
end

def error(s)
raise ApplicationError, s
end
end

def error(s)
raise ApplicationError, s
end
end
File.write(File.join(tmpdir, 'exist.css'), 'body {}')
File.write(File.join(tmpdir, 'exist.html'), '<html></html>')

File.write(File.join(tmpdir, 'exist.css'), 'body {}')
File.write(File.join(tmpdir, 'exist.html'), '<html></html>')
Dir.mkdir(File.join(tmpdir, 'subdir'))
File.write(File.join(tmpdir, 'subdir', 'exist.html'), '<html></html>')

Dir.mkdir(File.join(tmpdir, 'subdir'))
File.write(File.join(tmpdir, 'subdir', 'exist.html'), '<html></html>')
Dir.mkdir(File.join(tmpdir, 'test'))
File.write(File.join(tmpdir, 'test', 'ch01.html'), '<html><img src="images/ch01.png" /></html>')
File.write(File.join(tmpdir, 'test', 'style.css'), 'div { background-image: url("images/bg.jpg")}')

Dir.mkdir(File.join(tmpdir, 'test'))
File.write(File.join(tmpdir, 'test', 'ch01.html'), '<html><img src="images/ch01.png" /></html>')
File.write(File.join(tmpdir, 'test', 'style.css'), 'div { background-image: url("images/bg.jpg")}')

Dir.chdir(tmpdir) do
yield(epubmaker, File.join(tmpdir, 'test'))
Dir.chdir(tmpdir) do
yield(epubmaker, File.join(tmpdir, 'test'))
end
end
rescue Errno::EACCES
# Windows fails unlink when file is opened
end
end

Expand Down Expand Up @@ -957,8 +961,8 @@ def test_verify_target_images
epubmaker.producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'style.css')
epubmaker.verify_target_images(tmpdir)

# expect = %w[images/bg.jpg images/ch01.png images/cover.png]
# assert_equal expect, epubmaker.config['epubmaker']['force_include_images']
expect = %w[images/bg.jpg images/ch01.png images/cover.png]
assert_equal expect, epubmaker.config['epubmaker']['force_include_images']
assert_equal true, true
end
end
Expand Down

0 comments on commit 8404888

Please sign in to comment.