Skip to content

Commit c09bb59

Browse files
committed
refactor shared context "texmf_context"
1 parent d38a520 commit c09bb59

File tree

9 files changed

+30
-35
lines changed

9 files changed

+30
-35
lines changed

spec/action/files_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
context "the output" do
2929
# known files
30-
let(:texdoclib) { texmf_home / "scripts/texdoc/texdoclib.tlu" }
30+
let(:texdoclib) { ps_texmf_home / "scripts/texdoc/texdoclib.tlu" }
3131

32-
let(:dist_texdoc_dist_cnf) { texmf_dist / "texdoc/texdoc-dist.cnf" }
33-
let(:dist_texdoc_cnf) { texmf_dist / "texdoc/texdoc.cnf" }
32+
let(:dist_texdoc_dist_cnf) { ps_texmf_dist / "texdoc/texdoc-dist.cnf" }
33+
let(:dist_texdoc_cnf) { ps_texmf_dist / "texdoc/texdoc.cnf" }
3434

35-
let(:home_texdoc_dist_cnf) { texmf_home / "texdoc/texdoc-dist.cnf" }
36-
let(:home_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
35+
let(:home_texdoc_dist_cnf) { ps_texmf_home / "texdoc/texdoc-dist.cnf" }
36+
let(:home_texdoc_cnf) { ps_texmf_home / "texdoc/texdoc.cnf" }
3737

3838
# message
3939
let(:version_info) { "#{normalize_path(texdoclib)} #{version}" }
@@ -51,7 +51,7 @@ def file_line status, file
5151
end
5252

5353
context "with normal setting" do
54-
before(:each) { set_environment_variable "TEXMFDIST", texmf_dist.to_s }
54+
before(:each) { set_environment_variable "TEXMFDIST", ps_texmf_dist.to_s }
5555
before(:each) { run_texdoc "-f" }
5656

5757
it "should contain version information" do
@@ -78,7 +78,7 @@ def file_line status, file
7878
end
7979

8080
context "with verbose setting" do
81-
before(:each) { set_environment_variable "TEXMFDIST", texmf_dist.to_s }
81+
before(:each) { set_environment_variable "TEXMFDIST", ps_texmf_dist.to_s }
8282
before(:each) { run_texdoc "-vf" }
8383

8484
it "should contain version information" do

spec/config/items_spec.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88

99
context "texlive_tlpdb" do
1010
context "to set custom path" do
11-
before(:each) { set_environment_variable "TEXMFVAR", texmf_var.to_s }
1211
before(:each) {
13-
run_texdoc "-dtlpdb", "-c texlive_tlpdb=#{tlpdb.to_s}", "texlive-en"
12+
run_texdoc "-dtlpdb", "-c texlive_tlpdb=#{ps_tlpdb.to_s}", "texlive-en"
1413
}
1514

16-
after(:each) { FileUtils.remove_dir(texmf_var) }
17-
1815
it "should be effective" do
1916
expect(stderr).to include(
20-
debug_line "tlpdb", "Getting data from tlpdb file #{tlpdb.to_s}")
17+
debug_line "tlpdb", "Getting data from tlpdb file #{ps_tlpdb.to_s}")
2118
end
2219
end
2320

spec/config/texdoc_cnf_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
include_context "messages"
55
include_context "texmf"
66

7-
let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
8-
97
context "config lines in texdoc.cnf" do
108
let(:config_content) {
119
<<~EOF

spec/config/texdoc_dist_cnf_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
include_context "messages"
55
include_context "texmf"
66

7-
let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
8-
let(:texdoc_dist_cnf) { texmf_home / "texdoc/texdoc-dist.cnf" }
97

108
context "when it loaded" do
119
before(:each) { run_texdoc "-dconfig", "-lI", "texlive-en" }

spec/score/adjscore_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
include_context "messages"
55
include_context "texmf"
66

7-
let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
8-
97
context "global pattern score adjustment" do
108
let(:config_content) {
119
<<~EOF

spec/search/alias_spec.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
include_context "messages"
66
include_context "texmf"
77

8-
let(:test_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
9-
108
context "is set in texdoc.cnf" do
119
let(:config_content) {
1210
<<~EOF
1311
alias testalias = texlive
1412
EOF
1513
}
16-
before(:each) { File.write(test_texdoc_cnf, config_content) }
14+
before(:each) { File.write(texdoc_cnf, config_content) }
1715

1816
let(:test_res_name) { "texlive/texlive-en/texlive-en.pdf" }
1917
let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] }

spec/search/texdocs_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
context "with standard testing setup" do
3333
before(:each) { run_texdoc "-dtexdocs", "listings" }
3434

35-
let(:texmf_dist_regex) { Regexp.escape(normalize_path(`kpsewhich -var-value TEXMFDIST`.chomp)) }
36-
let(:texmf_home_regex) { Regexp.escape(normalize_path(texmf_home)) }
35+
let(:texmf_dist_regex) { Regexp.escape(normalize_path(texmf_dist)) }
36+
let(:texmf_home_regex) { Regexp.escape(normalize_path(ps_texmf_home)) }
3737

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

spec/support/helpers/texdoc.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ module Texdoc
1212

1313
TMP_DIR = BASE_DIR / "tmp"
1414

15-
REPO_TEXMF = TMP_DIR / "texmf"
15+
REPO_TEXMF_HOME = TMP_DIR / "texmf"
1616
REPO_TEXMF_DIST = TMP_DIR / "texmf-dist"
17-
REPO_TEXLIVE_TLPDB = TMP_DIR / "texlive.tlpdb"
17+
REPO_TEXLIVE_TLPDB = TMP_DIR / "texlive.tlpdb" # used in shared_context/texmf_context.rb
1818

1919
# for testing
2020
HOME_DIR = TMP_DIR / "aruba"
2121

22-
PS_TEXMF = HOME_DIR / "texmf"
23-
PS_TEXMF_DIST = HOME_DIR / "texmf-dist"
22+
PS_TEXMF_HOME = HOME_DIR / "texmf"
23+
PS_TEXMF_DIST = HOME_DIR / "texmf-dist" # used in shared_context/texmf_context.rb
2424
PS_TEXMF_VAR = HOME_DIR / "texmf-var"
2525

2626
# mock
@@ -38,10 +38,10 @@ def setup_mock_viewers
3838

3939
# setup TEXMF trees
4040
def setup_texmf_trees
41-
FileUtils.cp_r(REPO_TEXMF, HOME_DIR)
41+
FileUtils.cp_r(REPO_TEXMF_HOME, HOME_DIR)
4242
FileUtils.cp_r(REPO_TEXMF_DIST, HOME_DIR)
4343

44-
set_environment_variable "TEXMFHOME", PS_TEXMF.to_s
44+
set_environment_variable "TEXMFHOME", PS_TEXMF_HOME.to_s
4545
set_environment_variable "TEXMFVAR", PS_TEXMF_VAR.to_s
4646
# WARNING: leave TEXMFDIST as is for searching local TeX Live docs
4747
end

spec/support/shared_contexts/texmf_context.rb

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
require 'pathname'
33

44
shared_context "texmf" do
5-
# pseudo TEXMF trees
6-
let(:texmf_home) { SpecHelplers::Texdoc::PS_TEXMF }
7-
let(:texmf_dist) { SpecHelplers::Texdoc::PS_TEXMF_DIST }
8-
let(:texmf_var) { SpecHelplers::Texdoc::PS_TEXMF_VAR }
5+
# pseudo TEXMF trees (dynamically generated)
6+
let(:ps_texmf_home) { SpecHelplers::Texdoc::PS_TEXMF_HOME }
7+
let(:ps_texmf_dist) { SpecHelplers::Texdoc::PS_TEXMF_DIST }
8+
9+
# the only real TEXMF tree
10+
let(:texmf_dist) { `kpsewhich --var-value TEXMFDIST`.chomp }
911

1012
# link to texlive.tlpdb
11-
let(:tlpdb) { SpecHelplers::Texdoc::REPO_TEXLIVE_TLPDB }
13+
let(:ps_tlpdb) { SpecHelplers::Texdoc::REPO_TEXLIVE_TLPDB }
14+
15+
# texdoc.cnf for testing
16+
let(:texdoc_cnf) { ps_texmf_home / "texdoc/texdoc.cnf" }
17+
let(:texdoc_dist_cnf) { ps_texmf_home / "texdoc/texdoc-dist.cnf" }
1218

1319
# sample files
1420
["html", "htm", "dvi", "md", "txt", "pdf", "ps", "tex"].each do |ext|
1521
let("sample_#{ext}".to_sym) {
16-
texmf_home / "doc/sample/sample.#{ext}"
22+
ps_texmf_home / "doc/sample/sample.#{ext}"
1723
}
1824
end
1925
end

0 commit comments

Comments
 (0)