My fork and git-scribe have diverged significantly of late. I am unsure how much effort it will take to get the two back in sync, but there is only one way to find out.
Before getting into a rebase too deep, I think I will dip my toes in with a small cherry pick. The no-clobber symlinks work from the other day seems like a good place to start.
I added the real git-scribe as an
upstreamremote a while back:
➜ git-scribe git:(master) git co -b upstream upstream/master Branch upstream set up to track remote branch master from upstream. Switched to a new branch 'upstream'So, back in that branch, I
bundle installand try running the tests:
➜ git-scribe git:(upstream) rake /home/cstrom/.rvm/rubies/ruby-1.9.3-p0-falcon/bin/ruby -I"lib:test" -I"/home/cstrom/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/rake-0.9.2.2/lib" "/home/cstrom/.rvm/gems/ruby-1.9.3- p0-falcon@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/check_test.rb" "test/init_test.rb" "test/gen_test.rb" Loaded suite /home/cstrom/.rvm/gems/ruby-1.9.3-p0-falcon@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader Started ...FMaking portrait pages on A4 paper (210mmx297mm) .Making portrait pages on A4 paper (210mmx297mm) ..FXSLT Highlighter: Cannot read xslthl-config.xml, no custom highlighters will be available. Writing ar01s02.html for section(_the_first_chapter) Writing ar01s03.html for section(_the_second_chapter) Writing index.html for article FXSLT Highlighter: Cannot read xslthl-config.xml, no custom highlighters will be available. Writing ar01s02.html for section(_the_first_chapter) Writing ar01s03.html for section(_the_second_chapter) Writing index.html for article F.... 1) Failure: test_scribe_can_generate_a_mobi(scribe_gen_tests) ... <nil> expected but was <"book.mobi"> diff: ? n il ? "book.mob " 2) Failure: test_scribe_can_generate_single_page_html(scribe_gen_tests) ... lt;top (required)>']: <false> is not true. 3) Failure: test_scribe_can_generate_site_html(scribe_gen_tests) ... <false> is not true. 4) Failure: test_scribe_can_generate_site_with_syntax_highlighting(scribe_gen_tests) ... <nil> is not true. Finished in 137.003675962 seconds.Ugh. I know that some of those failures are because the upstream branch has been pegged to OSX Saxon configuration. I got that more or less working late last year under Ubuntu. Many of those changes consisted in editing XML files, so it is an open question how to get that working cross platform.
Also, 137 seconds?!
Anyhow, let's see if I can fix those tests (aside from the Saxon failures). I track one down to the simple fact that the images used to be named "image". Hrm... that seems familiar:
➜ git-scribe git:(upstream) ✗ find | grep cover.jpg ./template/book/images/cover.jpg ➜ git-scribe git:(upstream) ✗ git log ./template/book/images/cover.jpg commit 2cce41f371392d7b78de45ad635efec2ab6110b6 Author: Chris Strom <firstname.lastname@example.org> Date: Mon Aug 1 23:13:59 2011 -0400 Books can have multiple images. Back cover, inside cover, etc. Pluralize template image directory to accommodate.Dammit. I didn't realize that any of my pull requests had made it in there. And without tests? Tsk.
The fix for two of the failures is simple enough—change
images. The mobi test failure is a little trickier. In addition to changing an image include to
images, I keep getting warnings about the cover image from the
... Warning(prcgen): Cover file not found : /tmp/test20120405-441-1lcib49/t/output/image/cover.jpg Warning(prcgen): media file not found /tmp/test20120405-441-1lcib49/t/output/image/cover.jpg Warning(prcgen): media file not found /tmp/test20120405-441-1lcib49/t/output/image/cover.jpg ...That is not specified in the test file, rather it is in the OPF generation:
OK so maybe not that tricky.
File.open('book.opf', 'w+') do |f| lang = @config['language'] || 'en' author = @config['author'] || 'Author' cover = @config['cover'] || 'image/cover.jpg' ...
After fixing that by adding an "s", I am ready to try adding my own test / patch. The test case turns out to be more involved than an error when re-copying symlinks with
FileUtils.cp_r. Rather, I can only make the test fail when the symbolic link and target file are in separate directories:
With that, I get a failure from the second
test "scribe don't crash on symlinks when run twice" do in_temp_dir do @scribe.init('t') Dir.chdir('t') do FileUtils.mkdir_p 'book/includes/sub1' FileUtils.mkdir_p 'book/includes/sub2' FileUtils.touch 'book/includes/sub1/real_file' FileUtils.ln_s '../sub1/real_file', 'book/includes/sub2/link_file' assert_nothing_raised do @scribe.gen('html') @scribe.gen('html') end end end end
➜ git-scribe git:(test-fixes) ✗ ruby test/gen_test.rb -n test_scribe_don_t_crash_on_symlinks_when_run_twice Loaded suite test/gen_test Started F 1) Failure: test_scribe_don_t_crash_on_symlinks_when_run_twice(scribe_gen_tests) [test/gen_test.rb:23:in `block (4 levels) in <main>' test/gen_test.rb:17:in `chdir' test/gen_test.rb:17:in `block (3 levels) in <main>' /home/cstrom/repos/git-scribe/test/test_helper.rb:40:in `block in in_temp_dir' /home/cstrom/repos/git-scribe/test/test_helper.rb:39:in `chdir' /home/cstrom/repos/git-scribe/test/test_helper.rb:39:in `in_temp_dir' test/gen_test.rb:15:in `block (2 levels) in <main>']: Exception raised: Class: <Errno::EEXIST> Message: <"File exists - (../sub1/real_file, output/includes/sub2/link_file)">I already know how to solve that—by adding
:remove_destination => trueto the copy:
With that, I have a bug fix pull request ready to go:
def gather_and_process files = Dir.glob("book/*") FileUtils.cp_r files, 'output', :remove_destination => true end
➜ git-scribe git:(test-fixes) ✗ ruby test/gen_test.rb -n test_scribe_don_t_crash_on_symlinks_when_run_twice Loaded suite test/gen_test Started . Finished in 1.607530602 seconds. 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 0.62 tests/s, 0.62 assertions/sSee? My tests run fast.
Problems with existing tests aside, this bug fix was pretty easy. Unfortunately, while fixing this, I found yet another place that my fork has diverged from upstream—this was in a completely different place in my copy. Ugh.