Skip to content

Commit

Permalink
add new actions for windows (#1460)
Browse files Browse the repository at this point in the history
* add actions for windows
* appveyor: use only 32bit
  • Loading branch information
takahashim committed Jan 1, 2020
1 parent cd6b585 commit 50876fb
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 94 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ruby-win.yml
@@ -0,0 +1,39 @@
name: TestWin

on: [push]

jobs:
build:

runs-on: windows-latest
strategy:
fail-fast: false
matrix:
ruby: [ '2.6.x', '2.5.x', '2.4.x' ]

steps:
- uses: actions/checkout@v1
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Build and test with Rake
shell: bash
run: |
gem install bundler --no-document
bundle install --retry 3
bundle exec ruby test/run_test.rb --max-diff-target-string-size=10000 --verbose=v
- name: Test with epubcheck-ruby
shell: bash
run: |
gem install -N epubcheck-ruby
ruby bin/review-init hello
cd hello
ruby ../bin/review-epubmaker config.yml
epubcheck book.epub
cd ..
ruby bin/review-init hello2 --epub-version 2
cd hello2
ruby ../bin/review-epubmaker config.yml
epubcheck book.epub
cd ..
20 changes: 0 additions & 20 deletions appveyor.yml
Expand Up @@ -6,31 +6,11 @@ install:
build_script:
- bundle install
- bundle exec rake test --trace --verbose
- bundle exec rubocop

before_test:
- gem install -N epubcheck-ruby

test_script:
- ruby bin/review-init hello
- cd hello
- ruby ../bin/review-epubmaker config.yml
- epubcheck book.epub
- cd ..
- ruby bin/review-init hello2 --epub-version 2
- cd hello2
- ruby ../bin/review-epubmaker config.yml
- epubcheck book.epub

branches:
only:
- master

environment:
matrix:
- ruby_version: "24"
- ruby_version: "24-x64"
- ruby_version: "25"
- ruby_version: "25-x64"
- ruby_version: "26"
- ruby_version: "26-x64"
8 changes: 8 additions & 0 deletions test/test_book.rb
@@ -1,8 +1,16 @@
require 'book_test_helper'
require 'fileutils'

class BookTest < Test::Unit::TestCase
include BookTestHelper

def setup
if ENV['GITHUB_WORKSPACE']
ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
FileUtils.mkdir_p(ENV['TMPDIR'])
end
end

def assert_same_path(expected, result, *options)
require 'pathname'
ex_path = Pathname(expected).realpath
Expand Down
6 changes: 4 additions & 2 deletions test/test_book_chapter.rb
Expand Up @@ -37,11 +37,13 @@ def test_name

def test_size
ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
assert_equal File.size(__FILE__), ch.size
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
assert_equal filesize, ch.size

File.open(__FILE__, 'r') do |i|
ch = Book::Chapter.new(nil, nil, nil, nil, i)
assert_equal File.size(__FILE__), ch.size
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
assert_equal filesize, ch.size
end
end

Expand Down
122 changes: 52 additions & 70 deletions test/test_image_finder.rb
Expand Up @@ -7,93 +7,75 @@ class ImageFinderTest < Test::Unit::TestCase
include ReVIEW

def setup
if ENV['GITHUB_WORKSPACE']
ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
FileUtils.mkdir_p(ENV['TMPDIR'])
end
@dir = Dir.mktmpdir
end

def test_find_path_pattern1
dir = Dir.mktmpdir
begin
path = File.join(dir, 'builder/ch01/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
def teardown
if @dir
FileUtils.remove_entry_secure(@dir)
end
end

def test_find_path_pattern1
path = File.join(@dir, 'builder/ch01/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])

assert_equal(path, finder.find_path('foo'))
end

def test_find_path_pattern2
dir = Dir.mktmpdir
begin
path = File.join(dir, 'builder/ch01-foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
end
path = File.join(@dir, 'builder/ch01-foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
end

def test_find_path_pattern3
dir = Dir.mktmpdir
begin
path = File.join(dir, 'builder/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
end
path = File.join(@dir, 'builder/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
end

def test_find_path_pattern4
dir = Dir.mktmpdir
begin
path = File.join(dir, 'ch01/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
end
path = File.join(@dir, 'ch01/foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
end

def test_find_path_pattern5
dir = Dir.mktmpdir
begin
path = File.join(dir, 'ch01-foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
end
path = File.join(@dir, 'ch01-foo.jpg')
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path, finder.find_path('foo'))
end

def test_find_path_dir_symlink
dir = Dir.mktmpdir
begin
path_src = File.join(dir, 'src')
path_dst = File.join(dir, 'ch01')
FileUtils.mkdir_p(path_src)
FileUtils.symlink(path_src, path_dst)
path_srcimg = File.join(path_src, 'foo.jpg')
path_dstimg = File.join(path_dst, 'foo.jpg')
FileUtils.touch(path_srcimg)

finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path_dstimg, finder.find_path('foo'))
ensure
FileUtils.remove_entry_secure(dir)
end
path_src = File.join(@dir, 'src')
path_dst = File.join(@dir, 'ch01')
FileUtils.mkdir_p(path_src)
FileUtils.symlink(path_src, path_dst)
path_srcimg = File.join(path_src, 'foo.jpg')
path_dstimg = File.join(path_dst, 'foo.jpg')
FileUtils.touch(path_srcimg)

finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
assert_equal(path_dstimg, finder.find_path('foo'))
end
end
2 changes: 1 addition & 1 deletion test/test_latexbuilder.rb
Expand Up @@ -284,9 +284,9 @@ def test_inline_idx
end

def test_inline_idx_yomi
require 'nkf'
begin
require 'MeCab'
require 'nkf'
rescue LoadError
$stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
return true
Expand Down
2 changes: 1 addition & 1 deletion test/test_latexbuilder_v2.rb
Expand Up @@ -253,9 +253,9 @@ def test_inline_idx
end

def test_inline_idx_yomi
require 'nkf'
begin
require 'MeCab'
require 'nkf'
rescue LoadError
$stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
return true
Expand Down

0 comments on commit 50876fb

Please sign in to comment.