From 24d44dd4f87268410690b037a106d234bd325720 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Tue, 25 Oct 2016 16:20:47 -0700 Subject: [PATCH] fix tests, better error handling in pixiv ugoira converter --- app/logical/pixiv_ugoira_converter.rb | 14 ++++++++++++-- test/unit/tag_alias_correction_test.rb | 2 +- test/unit/wiki_page_test.rb | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/logical/pixiv_ugoira_converter.rb b/app/logical/pixiv_ugoira_converter.rb index b7d1c899c..07b72ee45 100644 --- a/app/logical/pixiv_ugoira_converter.rb +++ b/app/logical/pixiv_ugoira_converter.rb @@ -38,8 +38,7 @@ class PixivUgoiraConverter end ext = folder.first.name.match(/\.(\w{,4})$/)[1] - ffmpeg_out, status_ = Open3.capture2e("ffmpeg -i #{tmpdir}/images/%06d.#{ext} -codec:v libvpx -crf 4 -b:v 5000k -an #{tmpdir}/tmp.webm") - mkvmerge_out, status = Open3.capture2e("mkvmerge -o #{write_path} --webm --timecodes 0:#{tmpdir}/timecodes.tc #{tmpdir}/tmp.webm") + ffmpeg_out, status = Open3.capture2e("ffmpeg -i #{tmpdir}/images/%06d.#{ext} -codec:v libvpx -crf 4 -b:v 5000k -an #{tmpdir}/tmp.webm") if !status.success? Rails.logger.error "[write_webm] ******************************" @@ -48,10 +47,21 @@ class PixivUgoiraConverter ffmpeg_out.split(/\n/).each do |line| Rails.logger.error "[write_webm][ffmpeg] #{line}" end + Rails.logger.error "[write_webm] ******************************" + return + end + + mkvmerge_out, status = Open3.capture2e("mkvmerge -o #{write_path} --webm --timecodes 0:#{tmpdir}/timecodes.tc #{tmpdir}/tmp.webm") + + if !status.success? + Rails.logger.error "[write_webm] ******************************" + Rails.logger.error "[write_webm] failed write_path=#{write_path}" Rails.logger.error "[write_webm] mkvmerge output:" mkvmerge_out.split(/\n/).each do |line| Rails.logger.error "[write_webm][mkvmerge] #{line}" end + Rails.logger.error "[write_webm] ******************************" + return end end end diff --git a/test/unit/tag_alias_correction_test.rb b/test/unit/tag_alias_correction_test.rb index 6e19211d4..1e2780d12 100644 --- a/test/unit/tag_alias_correction_test.rb +++ b/test/unit/tag_alias_correction_test.rb @@ -27,7 +27,7 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase should "have the correct statistics hash" do assert_equal("zzz", @correction.statistics_hash["antecedent_cache"]) - assert_equal("bbb", @correction.statistics_hash["consequent_cache"]) + assert_equal(nil, @correction.statistics_hash["consequent_cache"]) assert_equal(-3, @correction.statistics_hash["antecedent_count"]) assert_equal(1, @correction.statistics_hash["consequent_count"]) end diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index 84beb690d..cd1f97b39 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -53,7 +53,7 @@ class WikiPageTest < ActiveSupport::TestCase should "not allow the is_locked attribute to be updated" do @wiki_page.update_attributes(:is_locked => true) - assert_equal(["Is locked can be modified by moderators only", "Is locked and cannot be updated"], @wiki_page.errors.full_messages) + assert_equal(["Is locked can be modified by builders only", "Is locked and cannot be updated"], @wiki_page.errors.full_messages) @wiki_page.reload assert_equal(false, @wiki_page.is_locked?) end