Skip to content

Commit

Permalink
add spec/search/tlpdb_spec.rb; update texdocs_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
wtsnjp committed Aug 12, 2024
1 parent e10ae17 commit 4371114
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
7 changes: 3 additions & 4 deletions spec/search/texdocs_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'digest/md5'

RSpec.describe "Handling texdocs", :type => :aruba do
include_context "messages"
Expand Down Expand Up @@ -62,18 +61,18 @@

context "for a docfile name query" do
let(:test_res_name) { "latex/babel/babel-code.pdf" }
let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] }
let(:test_res_hash) { "4abb904" }
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }

let(:test_query) { "babel-code" }
before(:each) { run_texdoc "-ddocfile", test_query }

it "should find the documents" do
it "should find the document" do
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) source: texdocs")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) sources: texdocs")
end
end
end
60 changes: 60 additions & 0 deletions spec/search/tlpdb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require 'spec_helper'

RSpec.describe "Document search in tlpdb", :type => :aruba do
include_context "messages"

context "for a runfile, tlp, and docfile name query" do
let(:test_res_name) { "latex/babel/babel.pdf" }
let(:test_res_hash) { "b26f92e" }
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }

let(:test_query) { "babel" }
before(:each) { run_texdoc "-ddocfile", test_query }

it "should find the document from both tlpdb and texdocs" do
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) sources: tlpdb, texdocs")
end
end

context "for a tlp and docfile name query" do
let(:test_res_name) { "texmf-dist/doc/man/man1/dvipdfmx.man1.pdf" }
let(:test_res_hash) { "e49c24d" }
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }

let(:test_query) { "dvipdfmx" }
before(:each) { run_texdoc "-ddocfile", test_query }

it "should find the document from tlpdb" do
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}")
expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true")
end
end

context "for a runfile and docfile name query" do
let(:test_res_name) { "latex/tools/xspace.pdf" }
let(:test_res_hash) { "9146ab6" }
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }

let(:test_query) { "xspace" }
before(:each) { run_texdoc "-ddocfile", test_query }

it "should find the document from tlpdb" do
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}")
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true")
expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true")
end
end
end

0 comments on commit 4371114

Please sign in to comment.