From 3de61b2bfe7de2e313d5173b0826a671aeb14dc9 Mon Sep 17 00:00:00 2001 From: Keith Fahlgren Date: Wed, 11 Aug 2010 04:09:42 +0000 Subject: [PATCH] Working toward getting the automated test suite working in Windows --- xsl/epub/bin/lib/docbook.rb | 11 ++++++----- xsl/epub/bin/spec/README | 2 +- xsl/epub/bin/spec/epub_realbook_spec.rb | 2 +- xsl/epub/bin/spec/epub_regressions_spec.rb | 18 +++++++++--------- xsl/epub/bin/spec/epub_spec.rb | 20 ++++++++++---------- xsl/epub/bin/spec/spec_helper.rb | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/xsl/epub/bin/lib/docbook.rb b/xsl/epub/bin/lib/docbook.rb index 2bb90a97b..430662e54 100755 --- a/xsl/epub/bin/lib/docbook.rb +++ b/xsl/epub/bin/lib/docbook.rb @@ -47,7 +47,7 @@ module DocBook def self.invalid?(file) # Obnoxiously, we can't just check for a non-zero output... - cmd = "#{CHECKER} #{file}" + cmd = %Q(#{CHECKER} "#{file}") output = `#{cmd} 2>&1` if $?.to_i == 0 @@ -85,7 +85,7 @@ module DocBook html_stylesheet, ].join(" ") # Double-quote stylesheet & file to help Windows cmd.exe - db2epub_cmd = "cd #{@output_dir} && #{XSLT_PROCESSOR} #{options} \"#{@stylesheet}\" \"#{@collapsed_docbook_file}\"" + db2epub_cmd = %Q(cd "#{@output_dir}" && #{XSLT_PROCESSOR} #{options} "#{@stylesheet}" "#{@collapsed_docbook_file}") STDERR.puts db2epub_cmd if $DEBUG success = system(db2epub_cmd) raise "Could not render as .epub to #{output_file} (#{db2epub_cmd})" unless success @@ -105,7 +105,7 @@ module DocBook callouts = copy_callouts() # zip -X -r ../book.epub mimetype META-INF OEBPS # Double-quote stylesheet & file to help Windows cmd.exe - zip_cmd = "cd \"#{@output_dir}\" && #{ZIPPER} #{quiet} -X -r \"#{File.expand_path(output_file)}\" \"#{mimetype_filename}\" \"#{meta}\" \"#{oebps}\"" + zip_cmd = %Q(cd "#{@output_dir}" && #{ZIPPER} #{quiet} -X -r "#{File.expand_path(output_file)}" "#{mimetype_filename}" "#{meta}" "#{oebps}") puts zip_cmd if $DEBUG success = system(zip_cmd) raise "Could not bundle into .epub file to #{output_file}" unless success @@ -115,13 +115,14 @@ module DocBook # were XIncluded or added by ENTITY # http://sourceforge.net/tracker/?func=detail&aid=2750442&group_id=21935&atid=373747 def collapse_docbook + # Double-quote stylesheet & file to help Windows cmd.exe collapsed_file = File.join(File.expand_path(File.dirname(@docbook_file)), '.collapsed.' + File.basename(@docbook_file)) - entity_collapse_command = "xmllint --loaddtd --noent -o '#{collapsed_file}' '#{@docbook_file}'" + entity_collapse_command = %Q(xmllint --loaddtd --noent -o "#{collapsed_file}" "#{@docbook_file}") entity_success = system(entity_collapse_command) raise "Could not collapse named entites in #{@docbook_file}" unless entity_success - xinclude_collapse_command = "xmllint --xinclude -o '#{collapsed_file}' '#{collapsed_file}'" + xinclude_collapse_command = %Q(xmllint --xinclude -o "#{collapsed_file}" "#{collapsed_file}") xinclude_success = system(xinclude_collapse_command) raise "Could not collapse XIncludes in #{@docbook_file}" unless xinclude_success diff --git a/xsl/epub/bin/spec/README b/xsl/epub/bin/spec/README index d604a4615..033e13235 100644 --- a/xsl/epub/bin/spec/README +++ b/xsl/epub/bin/spec/README @@ -25,7 +25,7 @@ PATH (or equivalent for Windows): * XML Catalogs for DocBook 4.4 & 4.5 (this can be a pain) * ruby 1.8+ * rspec version=1.1 http://rspec.info (gem install rspec --version 1.1) -* zip +* zip & unzip * java * epubcheck (1.0.5+) http://code.google.com/p/epubcheck/ Note: a standalone epubcheck command is just a shell script or .bat as: diff --git a/xsl/epub/bin/spec/epub_realbook_spec.rb b/xsl/epub/bin/spec/epub_realbook_spec.rb index fd0f571c8..aa8a569b9 100755 --- a/xsl/epub/bin/spec/epub_realbook_spec.rb +++ b/xsl/epub/bin/spec/epub_realbook_spec.rb @@ -29,7 +29,7 @@ describe DocBook::Epub do FileUtils.copy(@epub_file, "." + File.basename(@xml_file, ".xml") + ".epub") if $DEBUG @tmpdir2 = File.join(Dir::tmpdir(), "epubreal"); Dir.mkdir(@tmpdir2) rescue Errno::EEXIST - success = system("unzip -q -o -d #{@tmpdir2} #{@epub_file}") + success = system(%Q(unzip -q -o -d "#{@tmpdir2}" "#{@epub_file}")) raise "Could not unzip #{epub_file}" unless success @html_files = Dir.glob(File.join(@tmpdir2, "**", "*.html")) diff --git a/xsl/epub/bin/spec/epub_regressions_spec.rb b/xsl/epub/bin/spec/epub_regressions_spec.rb index d7ad15b59..d30aa9814 100755 --- a/xsl/epub/bin/spec/epub_regressions_spec.rb +++ b/xsl/epub/bin/spec/epub_regressions_spec.rb @@ -34,7 +34,7 @@ describe DocBook::Epub do FileUtils.copy(epub_file, "./.t.epub") if $DEBUG itemref_tmpdir = File.join(Dir::tmpdir(), "epubitemref"); Dir.mkdir(itemref_tmpdir) rescue Errno::EEXIST - system("unzip -q -o -d #{itemref_tmpdir} #{epub_file}") + system(%Q(unzip -q -o -d "#{itemref_tmpdir}" "#{epub_file}")) opf_file = File.join(itemref_tmpdir, "OEBPS", "content.opf") opf = REXML::Document.new(File.new(opf_file)) @@ -51,7 +51,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".re.ded.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.opf")) index_html_links = glob.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /href=["']index.html["']/} @@ -73,7 +73,7 @@ describe DocBook::Epub do tmpdir = File.join(Dir::tmpdir(), "epubcssreg"); Dir.mkdir(tmpdir) rescue Errno::EEXIST - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{css_epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{css_epubfile}") raise "Could not unzip #{css_epubfile}" unless success opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) opf_files.find_all {|opf_file| @@ -97,10 +97,10 @@ describe DocBook::Epub do xhtml_dtd = "DTD XHTML 1.1" itemref_tmpdir = File.join(Dir::tmpdir(), "epubitemref"); Dir.mkdir(itemref_tmpdir) rescue Errno::EEXIST - system("unzip -q -o -d #{itemref_tmpdir} #{epub_file}") + system(%Q(unzip -q -o -d "#{itemref_tmpdir}" "#{epub_file}")) opf_file = File.join(itemref_tmpdir, "OEBPS", "content.opf") - xhtml_dtd_in_opf_file = system("grep '#{xhtml_dtd}' #{opf_file}") + xhtml_dtd_in_opf_file = system(%Q(grep "#{xhtml_dtd}" "#{opf_file}")) xhtml_dtd_in_opf_file.should_not be_true end @@ -160,7 +160,7 @@ describe DocBook::Epub do epubfile = File.join(tmpdir, shortname + ".epub") epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, "." + shortname + ".epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{File.expand_path(epubfile)}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{File.expand_path(epubfile)}")) raise "Could not unzip #{epubfile}" unless success container_file = File.join(tmpdir, 'META-INF', 'container.xml') container_lines = File.open(container_file).readlines @@ -199,7 +199,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".b.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.html")) glob.each {|html_file| @@ -229,12 +229,12 @@ describe DocBook::Epub do ncx_epubfile.should be_valid_epub ncx_tmpdir = File.join(Dir::tmpdir(), "epubncx"); Dir.mkdir(ncx_tmpdir) rescue Errno::EEXIST - system("unzip -q -o -d #{ncx_tmpdir} #{ncx_epubfile}") + system(%Q(unzip -q -o -d "#{ncx_tmpdir}" "#{ncx_epubfile}")) ncx_file = File.join(ncx_tmpdir, "OEBPS", "toc.ncx") ncx_default = ']*#{@css_file_base}/} @@ -202,7 +202,7 @@ describe DocBook::Epub do begin tmpdir = File.join(Dir::tmpdir(), "epubcssfiletest"); Dir.mkdir(tmpdir) rescue Errno::EEXIST - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{@css_epubfile}")) raise "Could not unzip #{@css_epubfile}" unless success css_files = Dir.glob(File.join(tmpdir, "**", "*.css")) css_files.should_not be_empty @@ -217,7 +217,7 @@ describe DocBook::Epub do begin tmpdir = File.join(Dir::tmpdir(), "epubcsshtmltest"); Dir.mkdir(tmpdir) rescue Errno::EEXIST - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{@css_epubfile}")) raise "Could not unzip #{@css_epubfile}" unless success opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) opf_links = opf_files.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /<(opf:item|item) [^>]*#{@css_file_base}/} @@ -233,7 +233,7 @@ describe DocBook::Epub do begin tmpdir = File.join(Dir::tmpdir(), "epubfontman"); Dir.mkdir(tmpdir) rescue Errno::EEXIST - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{@css_epubfile}")) raise "Could not unzip #{@css_epubfile}" unless success opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) @@ -252,7 +252,7 @@ describe DocBook::Epub do begin tmpdir = File.join(Dir::tmpdir(), "epubfontbundle"); Dir.mkdir(tmpdir) rescue Errno::EEXIST - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{@css_epubfile}")) raise "Could not unzip #{@css_epubfile}" unless success @embedded_fonts.each {|font| font_files = Dir.glob(File.join(tmpdir, "**", File.basename(font))) @@ -278,7 +278,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".h1c.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.html")) glob.each {|html_file| @@ -302,7 +302,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".h1c2.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.html")) glob.each {|html_file| @@ -326,7 +326,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".tcl.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.opf")) toc_links = glob.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /type=["']toc["']/} @@ -350,7 +350,7 @@ describe DocBook::Epub do epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, ".cust.epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{epubfile}")) raise "Could not unzip #{epubfile}" unless success glob = Dir.glob(File.join(tmpdir, "**", "*.html")) # The customization layer changes the style of cross references to _not_ diff --git a/xsl/epub/bin/spec/spec_helper.rb b/xsl/epub/bin/spec/spec_helper.rb index 51b755d38..30193d09e 100755 --- a/xsl/epub/bin/spec/spec_helper.rb +++ b/xsl/epub/bin/spec/spec_helper.rb @@ -46,7 +46,7 @@ def opf_lines(filename, filedir) epubfile = File.join(tmpdir, shortname + ".epub") epub.render_to_file(epubfile, $DEBUG) FileUtils.copy(epubfile, "." + shortname + ".epub") if $DEBUG - success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{File.expand_path(epubfile)}") + success = system(%Q(unzip -q -d "#{File.expand_path(tmpdir)}" -o "#{File.expand_path(epubfile)}")) raise "Could not unzip #{epubfile}" unless success opf_file = Dir.glob(File.join(tmpdir, "**", "*.opf")).first opf_lines = File.open(opf_file).readlines -- 2.40.0