diff --git a/spec/action/files_spec.rb b/spec/action/files_spec.rb index cdebebc..bab0918 100644 --- a/spec/action/files_spec.rb +++ b/spec/action/files_spec.rb @@ -27,13 +27,13 @@ context "the output" do # known files - let(:texdoclib) { texmf_home / "scripts/texdoc/texdoclib.tlu" } + let(:texdoclib) { ps_texmf_home / "scripts/texdoc/texdoclib.tlu" } - let(:dist_texdoc_dist_cnf) { texmf_dist / "texdoc/texdoc-dist.cnf" } - let(:dist_texdoc_cnf) { texmf_dist / "texdoc/texdoc.cnf" } + let(:dist_texdoc_dist_cnf) { ps_texmf_dist / "texdoc/texdoc-dist.cnf" } + let(:dist_texdoc_cnf) { ps_texmf_dist / "texdoc/texdoc.cnf" } - let(:home_texdoc_dist_cnf) { texmf_home / "texdoc/texdoc-dist.cnf" } - let(:home_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } + let(:home_texdoc_dist_cnf) { ps_texmf_home / "texdoc/texdoc-dist.cnf" } + let(:home_texdoc_cnf) { ps_texmf_home / "texdoc/texdoc.cnf" } # message let(:version_info) { "#{normalize_path(texdoclib)} #{version}" } @@ -51,7 +51,7 @@ def file_line status, file end context "with normal setting" do - before(:each) { set_environment_variable "TEXMFDIST", texmf_dist.to_s } + before(:each) { set_environment_variable "TEXMFDIST", ps_texmf_dist.to_s } before(:each) { run_texdoc "-f" } it "should contain version information" do @@ -78,7 +78,7 @@ def file_line status, file end context "with verbose setting" do - before(:each) { set_environment_variable "TEXMFDIST", texmf_dist.to_s } + before(:each) { set_environment_variable "TEXMFDIST", ps_texmf_dist.to_s } before(:each) { run_texdoc "-vf" } it "should contain version information" do diff --git a/spec/config/items_spec.rb b/spec/config/items_spec.rb index 9798ef0..3f54985 100644 --- a/spec/config/items_spec.rb +++ b/spec/config/items_spec.rb @@ -8,16 +8,13 @@ context "texlive_tlpdb" do context "to set custom path" do - before(:each) { set_environment_variable "TEXMFVAR", texmf_var.to_s } before(:each) { - run_texdoc "-dtlpdb", "-c texlive_tlpdb=#{tlpdb.to_s}", "texlive-en" + run_texdoc "-dtlpdb", "-c texlive_tlpdb=#{ps_tlpdb.to_s}", "texlive-en" } - after(:each) { FileUtils.remove_dir(texmf_var) } - it "should be effective" do expect(stderr).to include( - debug_line "tlpdb", "Getting data from tlpdb file #{tlpdb.to_s}") + debug_line "tlpdb", "Getting data from tlpdb file #{ps_tlpdb.to_s}") end end diff --git a/spec/config/texdoc_cnf_spec.rb b/spec/config/texdoc_cnf_spec.rb index ca72bff..3628e40 100644 --- a/spec/config/texdoc_cnf_spec.rb +++ b/spec/config/texdoc_cnf_spec.rb @@ -4,8 +4,6 @@ include_context "messages" include_context "texmf" - let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } - context "config lines in texdoc.cnf" do let(:config_content) { <<~EOF diff --git a/spec/config/texdoc_dist_cnf_spec.rb b/spec/config/texdoc_dist_cnf_spec.rb index ac53dac..8dfb18b 100644 --- a/spec/config/texdoc_dist_cnf_spec.rb +++ b/spec/config/texdoc_dist_cnf_spec.rb @@ -4,8 +4,6 @@ include_context "messages" include_context "texmf" - let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } - let(:texdoc_dist_cnf) { texmf_home / "texdoc/texdoc-dist.cnf" } context "when it loaded" do before(:each) { run_texdoc "-dconfig", "-lI", "texlive-en" } diff --git a/spec/score/adjscore_spec.rb b/spec/score/adjscore_spec.rb index c0f8c74..4ea310b 100644 --- a/spec/score/adjscore_spec.rb +++ b/spec/score/adjscore_spec.rb @@ -4,8 +4,6 @@ include_context "messages" include_context "texmf" - let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } - context "global pattern score adjustment" do let(:config_content) { <<~EOF diff --git a/spec/search/alias_spec.rb b/spec/search/alias_spec.rb index 8f457cb..1572547 100644 --- a/spec/search/alias_spec.rb +++ b/spec/search/alias_spec.rb @@ -5,15 +5,13 @@ include_context "messages" include_context "texmf" - let(:test_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } - context "is set in texdoc.cnf" do let(:config_content) { <<~EOF alias testalias = texlive EOF } - before(:each) { File.write(test_texdoc_cnf, config_content) } + before(:each) { File.write(texdoc_cnf, config_content) } let(:test_res_name) { "texlive/texlive-en/texlive-en.pdf" } let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] } diff --git a/spec/search/texdocs_spec.rb b/spec/search/texdocs_spec.rb index 1d662d0..3cde67b 100644 --- a/spec/search/texdocs_spec.rb +++ b/spec/search/texdocs_spec.rb @@ -32,8 +32,8 @@ context "with standard testing setup" do before(:each) { run_texdoc "-dtexdocs", "listings" } - let(:texmf_dist_regex) { Regexp.escape(normalize_path(`kpsewhich -var-value TEXMFDIST`.chomp)) } - let(:texmf_home_regex) { Regexp.escape(normalize_path(texmf_home)) } + let(:texmf_dist_regex) { Regexp.escape(normalize_path(texmf_dist)) } + let(:texmf_home_regex) { Regexp.escape(normalize_path(ps_texmf_home)) } let(:path_doc_suffix_regex) { Regexp.escape(normalize_path("/doc")) } let(:shift_doc_suffix_regex) { Regexp.escape(normalize_path("doc/")) } diff --git a/spec/support/helpers/texdoc.rb b/spec/support/helpers/texdoc.rb index 5f0b020..b66bc4d 100644 --- a/spec/support/helpers/texdoc.rb +++ b/spec/support/helpers/texdoc.rb @@ -12,15 +12,15 @@ module Texdoc TMP_DIR = BASE_DIR / "tmp" - REPO_TEXMF = TMP_DIR / "texmf" + REPO_TEXMF_HOME = TMP_DIR / "texmf" REPO_TEXMF_DIST = TMP_DIR / "texmf-dist" - REPO_TEXLIVE_TLPDB = TMP_DIR / "texlive.tlpdb" + REPO_TEXLIVE_TLPDB = TMP_DIR / "texlive.tlpdb" # used in shared_context/texmf_context.rb # for testing HOME_DIR = TMP_DIR / "aruba" - PS_TEXMF = HOME_DIR / "texmf" - PS_TEXMF_DIST = HOME_DIR / "texmf-dist" + PS_TEXMF_HOME = HOME_DIR / "texmf" + PS_TEXMF_DIST = HOME_DIR / "texmf-dist" # used in shared_context/texmf_context.rb PS_TEXMF_VAR = HOME_DIR / "texmf-var" # mock @@ -38,10 +38,10 @@ def setup_mock_viewers # setup TEXMF trees def setup_texmf_trees - FileUtils.cp_r(REPO_TEXMF, HOME_DIR) + FileUtils.cp_r(REPO_TEXMF_HOME, HOME_DIR) FileUtils.cp_r(REPO_TEXMF_DIST, HOME_DIR) - set_environment_variable "TEXMFHOME", PS_TEXMF.to_s + set_environment_variable "TEXMFHOME", PS_TEXMF_HOME.to_s set_environment_variable "TEXMFVAR", PS_TEXMF_VAR.to_s # WARNING: leave TEXMFDIST as is for searching local TeX Live docs end diff --git a/spec/support/shared_contexts/texmf_context.rb b/spec/support/shared_contexts/texmf_context.rb index c67b700..07c3ff5 100644 --- a/spec/support/shared_contexts/texmf_context.rb +++ b/spec/support/shared_contexts/texmf_context.rb @@ -2,18 +2,24 @@ require 'pathname' shared_context "texmf" do - # pseudo TEXMF trees - let(:texmf_home) { SpecHelplers::Texdoc::PS_TEXMF } - let(:texmf_dist) { SpecHelplers::Texdoc::PS_TEXMF_DIST } - let(:texmf_var) { SpecHelplers::Texdoc::PS_TEXMF_VAR } + # pseudo TEXMF trees (dynamically generated) + let(:ps_texmf_home) { SpecHelplers::Texdoc::PS_TEXMF_HOME } + let(:ps_texmf_dist) { SpecHelplers::Texdoc::PS_TEXMF_DIST } + + # the only real TEXMF tree + let(:texmf_dist) { `kpsewhich --var-value TEXMFDIST`.chomp } # link to texlive.tlpdb - let(:tlpdb) { SpecHelplers::Texdoc::REPO_TEXLIVE_TLPDB } + let(:ps_tlpdb) { SpecHelplers::Texdoc::REPO_TEXLIVE_TLPDB } + + # texdoc.cnf for testing + let(:texdoc_cnf) { ps_texmf_home / "texdoc/texdoc.cnf" } + let(:texdoc_dist_cnf) { ps_texmf_home / "texdoc/texdoc-dist.cnf" } # sample files ["html", "htm", "dvi", "md", "txt", "pdf", "ps", "tex"].each do |ext| let("sample_#{ext}".to_sym) { - texmf_home / "doc/sample/sample.#{ext}" + ps_texmf_home / "doc/sample/sample.#{ext}" } end end