erbtex 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,181 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CommandLineTest < Test::Unit::TestCase
4
- include ErbTeX
5
-
6
- def setup
7
- @test_dir = File.dirname(File.absolute_path(__FILE__))
8
- @junk_tex = @test_dir + '/junk.tex'
9
- FileUtils.touch(@junk_tex)
10
-
11
- @tex_dir = @test_dir + '/tex_dir'
12
- FileUtils.mkdir(@tex_dir) unless File.exists?(@tex_dir)
13
- @junk2_tex = @tex_dir + '/junk2.tex'
14
- FileUtils.touch(@junk2_tex)
15
-
16
- @tex_dir_nw = @test_dir + '/tex_dir_nw'
17
- FileUtils.mkdir(@tex_dir_nw) unless File.exists?(@tex_dir_nw)
18
- @junk3_tex = @tex_dir_nw + '/junk3.tex'
19
- FileUtils.touch(@junk3_tex)
20
- FileUtils.chmod(0500, @tex_dir_nw)
21
-
22
- @junk4_tex = File.expand_path('~/junk.tex')
23
- FileUtils.touch(@junk4_tex)
24
- end
25
-
26
- def teardown
27
- FileUtils.rm(@junk_tex)
28
- FileUtils.rm(@junk4_tex)
29
- FileUtils.rm_rf(@tex_dir)
30
- FileUtils.chmod(0700, @tex_dir_nw)
31
- FileUtils.rm_rf(@tex_dir_nw)
32
- end
33
-
34
- def test_find_ordinary_input_file
35
- cl = 'pdflatex -ini --halt-on-error junk'
36
- assert_equal("junk.tex",
37
- CommandLine.new(cl).input_file)
38
- end
39
-
40
- def test_find_input_file_relative
41
- cl = 'pdflatex -ini --halt-on-error ./junk.tex'
42
- assert_equal("./junk.tex",
43
- CommandLine.new(cl).input_file)
44
- end
45
-
46
- def test_find_input_file_relative_no_ext
47
- cl = 'pdflatex -ini --halt-on-error ./junk'
48
- assert_equal("./junk.tex",
49
- CommandLine.new(cl).input_file)
50
- end
51
-
52
- def test_find_ordinary_input_file_with_ext
53
- cl = 'pdflatex -ini --halt-on-error junk.tex'
54
- assert_equal("junk.tex",
55
- CommandLine.new(cl).input_file)
56
- end
57
-
58
- def test_find_ordinary_input_file_with_spaces
59
- fn = 'A junk.tex'
60
- FileUtils.touch(fn)
61
- cl = "pdflatex -ini --halt-on-error \'#{fn}\'"
62
- assert_equal("A junk.tex",
63
- CommandLine.new(cl).input_file)
64
- FileUtils.rm(fn)
65
- end
66
-
67
- def test_no_input_file
68
- assert_raise ErbTeX::NoInputFile do
69
- cl = 'pdflatex -ini'
70
- CommandLine.new(cl)
71
- end
72
- end
73
-
74
- def test_no_input_file_with_eq
75
- assert_raise ErbTeX::NoInputFile do
76
- cl = 'pdflatex -ini -output-directory=/tmp'
77
- CommandLine.new(cl).input_file
78
- end
79
- end
80
-
81
- def test_find_progname
82
- cl = 'pdflatex -ini --halt-on-error junk.tex'
83
- assert_equal("pdflatex",
84
- CommandLine.new(cl).progname)
85
- end
86
-
87
- def test_mark_command_line
88
- cl = 'pdflatex -ini --halt-on-error junk'
89
- clm = '^p^ -ini --halt-on-error ^f^'
90
- assert_equal(clm,
91
- CommandLine.new(cl).marked_command_line)
92
- end
93
-
94
- def test_mark_command_line_with_ext
95
- cl = 'pdflatex -ini --halt-on-error junk.tex'
96
- clm = '^p^ -ini --halt-on-error ^f^'
97
- assert_equal(clm,
98
- CommandLine.new(cl).marked_command_line)
99
- end
100
-
101
- def test_mark_command_line_with_dir
102
- cl = 'pdflatex -ini --halt-on-error ~/junk.tex'
103
- clm = '^p^ -ini --halt-on-error ^f^'
104
- assert_equal(clm,
105
- CommandLine.new(cl).marked_command_line)
106
- end
107
-
108
- def test_mark_command_line_with_spaces
109
- cl = 'pdflatex -ini --halt-on-error \'/home/ded/A junk.tex\''
110
- clm = '^p^ -ini --halt-on-error ^f^'
111
- assert_equal(clm,
112
- CommandLine.new(cl).marked_command_line)
113
- end
114
-
115
- def test_find_embedded_input_file
116
- cl = 'pdflatex -ini --halt-on-error \input junk'
117
- assert_equal("junk.tex",
118
- CommandLine.new(cl).input_file)
119
- end
120
-
121
- def test_find_embedded_input_file_with_ext
122
- cl = 'pdflatex -ini --halt-on-error \input junk.tex'
123
- assert_equal("junk.tex",
124
- CommandLine.new(cl).input_file)
125
- end
126
-
127
- def test_find_input_file_with_relative
128
- cl = 'pdflatex -ini --halt-on-error \input tex_dir/junk2.tex'
129
- assert_equal("tex_dir/junk2.tex",
130
- CommandLine.new(cl).input_file)
131
- end
132
-
133
- def test_find_input_file_with_spaces
134
- fn = "my junk2.tex"
135
- FileUtils.touch(fn)
136
- cl = "pdflatex -ini --halt-on-error \input \"#{fn}\""
137
- assert_equal(fn,
138
- CommandLine.new(cl).input_file)
139
- FileUtils.rm(fn)
140
- end
141
-
142
- def test_find_input_path_existing
143
- cl = 'pdflatex -ini --halt-on-error \input junk.tex'
144
- assert_equal("./junk.tex",
145
- CommandLine.new(cl).input_path)
146
- end
147
-
148
- def test_dont_find_input_path_non_existing
149
- cl = 'pdflatex -ini --halt-on-error \input junk3.tex'
150
- assert_raise NoInputFile do
151
- CommandLine.new(cl).input_path
152
- end
153
- end
154
-
155
- def test_find_full_path_with_env
156
- save_env = ENV['TEXINPUTS']
157
- ENV['TEXINPUTS'] = File.dirname(__FILE__) + '/tex_dir'
158
- cl = 'pdflatex -ini --halt-on-error \input junk2.tex'
159
- assert_equal("./tex_dir/junk2.tex",
160
- CommandLine.new(cl).input_path)
161
- ENV['TEXINPUTS'] = save_env
162
- end
163
-
164
- def test_find_output_dir
165
- cl = 'pdflatex -ini --halt-on-error \input junk.tex'
166
- assert_equal(File.expand_path('./'), CommandLine.new(cl).output_dir)
167
- end
168
-
169
- def test_find_output_dir_with_options
170
- cl = 'pdflatex -ini -output-d=~/tmp \input junk.tex'
171
- assert_equal(File.expand_path('~/tmp'), CommandLine.new(cl).output_dir)
172
- end
173
-
174
- def test_find_output_dir_with_non_writable_pwd
175
- cl = 'pdflatex -ini \input junk3.tex'
176
- ENV['TEXMFOUTPUT'] = File.expand_path(File.dirname(__FILE__) + '/tex_dir')
177
- Dir.chdir('tex_dir_nw') do
178
- assert_equal(File.expand_path('../tex_dir'), CommandLine.new(cl).output_dir)
179
- end
180
- end
181
- end
@@ -1,44 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FindBinaryTest < Test::Unit::TestCase
4
- include ErbTeX
5
-
6
- # Here we set up the situation as we expect it to be after
7
- # installation. There is a "real" pdflatex executable binary and
8
- # there is one that is just a link to our script, the "fake" binary.
9
- # The fake binary is earlier in PATH than the real binary, and we want
10
- # this function, when fed the name of the fake binary to deduce the
11
- # name of the real binary.
12
- def setup
13
- # Create a "fake" ruby script named pdflatex
14
- @fake_dir = File.dirname(File.absolute_path(__FILE__)) + '/fake_bin'
15
- FileUtils.mkdir(@fake_dir) unless File.exist?(@fake_dir)
16
- @fake_binary = @fake_dir + '/pdflatex'
17
- @erbtex = @fake_dir + '/erbtex'
18
- FileUtils.touch(@erbtex)
19
- FileUtils.chmod(0700, @erbtex)
20
- FileUtils.rm_rf(@fake_binary) if File.exists?(@fake_binary)
21
- FileUtils.ln_s(@erbtex, @fake_binary)
22
-
23
- # Point to "real" pdflatex to find
24
- @real_binary = '/usr/bin/pdflatex'
25
- @real_dir = '/usr/bin'
26
-
27
- # Put the fake dir on the PATH before the real dir
28
- ENV['PATH'] = @fake_dir + ':' + @real_dir + ':' + ENV['PATH']
29
- end
30
-
31
- def teardown
32
- FileUtils.rm_rf(@fake_dir)
33
- end
34
-
35
- def test_find_pdflatex
36
- assert_equal(@real_binary,
37
- ErbTeX.find_executable(@fake_binary))
38
- end
39
-
40
- def test_find_pdflatex_with_erbtex
41
- assert_equal(@real_binary,
42
- ErbTeX.find_executable(@erbtex))
43
- end
44
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
-
2
- # Set up load path for tests.
3
-
4
- lib_dir = File.dirname(__FILE__) + '/../lib'
5
- $:.unshift lib_dir unless $:.include?(lib_dir)
6
-
7
- require 'test/unit'
8
- require 'erbtex'
9
- require 'fileutils'
10
-