From aca8b4d3f32b3f644bdb620c2ffe7a544d0f1b1a Mon Sep 17 00:00:00 2001 From: Takuto Asakura Date: Mon, 12 Aug 2024 02:30:01 +0900 Subject: [PATCH] further windows path handling --- script/texdoclib-search.tlu | 5 +++-- spec/config/buitin_spec.rb | 6 +----- spec/search/alias_spec.rb | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/script/texdoclib-search.tlu b/script/texdoclib-search.tlu index 7833372..c50f5a7 100644 --- a/script/texdoclib-search.tlu +++ b/script/texdoclib-search.tlu @@ -126,11 +126,12 @@ function Doclist:add(df) -- if no realpath information, unable to add -- (useful if vanilla == false) if not df.realpath then return end + local w32_path = texdoc.util.w32_path local df_hash = md5.sumhexa(df.normname:lower()):sub(1, 7) -- same as debug-score -- check the existence of the file if not lfs.isfile(df.realpath) then - dbg_print('search', '(%d) File %s not found. Skipping.', df_hash, df.realpath) + dbg_print('search', '(%d) File %s not found. Skipping.', df_hash, w32_path(df.realpath)) return end @@ -139,7 +140,7 @@ function Doclist:add(df) if index then self[index]:mergein(df) else - dbg_print('search', '(%s) File %s found.', df_hash, df.realpath) + dbg_print('search', '(%s) File %s found.', df_hash, w32_path(df.realpath)) dbg_print_docfile(df, df_hash) local newindex = #self + 1 diff --git a/spec/config/buitin_spec.rb b/spec/config/buitin_spec.rb index 4465cde..f0ed83e 100644 --- a/spec/config/buitin_spec.rb +++ b/spec/config/buitin_spec.rb @@ -7,7 +7,7 @@ context "if no other sources of config is set" do before(:each) { run_texdoc "-D", "texlive-en" } - it "config items should be set to the default values" do + it "should be set to the default values" do defaults = [ "badext_list=txt, dat, ", "mode=view", @@ -29,9 +29,5 @@ debug_line "config", "Setting \"#{config}\" from built-in defaults.") end end - - if not OS.windows? - # nothing: just to prevent a bug on windows - end end end diff --git a/spec/search/alias_spec.rb b/spec/search/alias_spec.rb index 4a6a4d8..f166ff1 100644 --- a/spec/search/alias_spec.rb +++ b/spec/search/alias_spec.rb @@ -13,13 +13,14 @@ EOF } before(:each) { File.write(texdoc_cnf, config_content) } + let(:realpath) { Regexp.escape(normalize_path("texlive/texlive-en/texlive-en.pdf")) } context "and query the exact alias" do before(:each) { run_texdoc "-ddocfile", "testalias" } it "should find aliased documents" do expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testalias"') - expect(stderr).to match(/texdoc debug-search: \(0da8ec4\) File \S*texlive\/texlive-en\/texlive-en.pdf found/) + expect(stderr).to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/) expect(stderr).to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf") expect(stderr).to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)") expect(last_command_started).to be_successfully_executed @@ -31,7 +32,7 @@ it "should not find aliased documents" do expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testaliases"') - expect(stderr).not_to match(/texdoc debug-search: \(0da8ec4\) File \S*texlive\/texlive-en\/texlive-en.pdf found/) + expect(stderr).not_to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/) expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf") expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)") end