Skip to content

Commit

Permalink
more w32_path for debug outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
wtsnjp committed Aug 10, 2024
1 parent e137e9d commit edc0e84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion script/texdoclib-config.tlu
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function M.set_config_element(key, value, context)

-- special case: if we just set debug_list, print version info now
if key == 'debug_list' then
dbg_print('version', '%s v%s', C.fullname, C.version)
local w32_path = import_function('util', 'w32_path')
dbg_print('version', '%s v%s', w32_path(C.fullname), C.version)
end

-- now tell what we have just done, for debugging
Expand Down
5 changes: 3 additions & 2 deletions script/texdoclib-search.tlu
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ init_texdocs_database = function()

doc_roots = {}
local kpse_texdocs = kpse.expand_var('$TEXDOCS')
local w32_path = texdoc.util.w32_path

-- expand the path and turn it into a lua list
local raw_doc_roots = kpse.expand_braces(kpse_texdocs):explode(C.kpse_sep)
Expand All @@ -376,13 +377,13 @@ init_texdocs_database = function()
local index_mandatory = (n == 1)
dbg_print('texdocs',
'texdocs[%d] = %s (index_mandatory=%s, recursion_allowed=%s)',
i, path, tostring(index_mandatory), tostring(recursion_allowed))
i, w32_path(path), tostring(index_mandatory), tostring(recursion_allowed))

-- decide if we should use a ls-R index, the filesystem, or do nothing
local root, shift = lsr_root(path)
if root and shift and recursion_allowed then
dbg_print('texdocs',
'texdocs[%d] using index: %s (shift=%s)', i, root, shift)
'texdocs[%d] using index: %s (shift=%s)', i, w32_path(root), w32_path(shift))
db = init_lsr_db(root, shift)
elseif not index_mandatory and lfs.isdir(path) then
dbg_print('texdocs',
Expand Down
20 changes: 13 additions & 7 deletions spec/search/texdocs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
}
before(:each) { run_texdoc "-dtexdocs", "listings" }

let(:tree_prefix) { normalize_path("path/to/") }

it "should be properly interpreted" do
expect(stderr).to include(
debug_line "texdocs",
"texdocs[4] = path/to/tree4 (index_mandatory=false, recursion_allowed=false)")
"texdocs[4] = #{tree_prefix}tree4 (index_mandatory=false, recursion_allowed=false)")
expect(stderr).to include(
debug_line "texdocs",
"texdocs[3] = path/to/tree3 (index_mandatory=false, recursion_allowed=true)")
"texdocs[3] = #{tree_prefix}tree3 (index_mandatory=false, recursion_allowed=true)")
expect(stderr).to include(
debug_line "texdocs",
"texdocs[2] = path/to/tree2 (index_mandatory=true, recursion_allowed=false)")
"texdocs[2] = #{tree_prefix}tree2 (index_mandatory=true, recursion_allowed=false)")
expect(stderr).to include(
debug_line "texdocs",
"texdocs[1] = path/to/tree1 (index_mandatory=true, recursion_allowed=true)")
"texdocs[1] = #{tree_prefix}tree1 (index_mandatory=true, recursion_allowed=true)")
end
end

Expand All @@ -33,15 +35,19 @@
let(:texmf_dist_regex) { Regexp.escape(normalize_path(`kpsewhich -var-value TEXMFDIST`.chomp)) }
let(:texmf_home_regex) { Regexp.escape(normalize_path(texmf_home)) }

let(:path_doc_suffix_regex) { Regexp.escape(normalize_path("/doc")) }
let(:shift_doc_suffix_regex) { Regexp.escape(normalize_path("doc/")) }

let(:texdocs_n_dist) {
/texdocs\[(\d+?)\] = #{texmf_dist_regex}\/doc/.match(stderr).to_a.values_at(1)[0].to_i
/texdocs\[(\d+?)\] = #{texmf_dist_regex}#{path_doc_suffix_regex}/.match(stderr).to_a.values_at(1)[0].to_i
}
let(:texdocs_n_home) {
/texdocs\[(\d+?)\] = #{texmf_home_regex}\/doc/.match(stderr).to_a.values_at(1)[0].to_i
/texdocs\[(\d+?)\] = #{texmf_home_regex}#{path_doc_suffix_regex}/.match(stderr).to_a.values_at(1)[0].to_i
}

it "should search TEXMFDIST using index" do
expect(stderr).to match(/texdocs\[#{texdocs_n_dist}\] using index: #{texmf_dist_regex} \(shift=doc\/\)/)
expect(stderr).to match(
/texdocs\[#{texdocs_n_dist}\] using index: #{texmf_dist_regex} \(shift=#{shift_doc_suffix_regex}\)/)
end

it "should search TEXMFHOME using file system" do
Expand Down

0 comments on commit edc0e84

Please sign in to comment.