@@ -5,48 +5,55 @@ use std::collections::HashSet;
5
5
use std:: path:: PathBuf ;
6
6
7
7
use tectonic:: io:: { FilesystemIo , IoProvider , IoStack , MemoryIo } ;
8
- use tectonic:: BibtexEngine ;
8
+ use tectonic:: { errors :: Result , BibtexEngine } ;
9
9
use tectonic_bridge_core:: { CoreBridgeLauncher , MinimalDriver } ;
10
+ use tectonic_engine_xetex:: TexOutcome ;
10
11
use tectonic_status_base:: NoopStatusBackend ;
11
12
12
13
#[ path = "util/mod.rs" ]
13
14
mod util;
14
15
use crate :: util:: { test_path, Expected , ExpectedFile } ;
15
16
16
17
struct TestCase {
17
- stem : String ,
18
- subdir : Option < String > ,
18
+ parts : & ' static [ & ' static str ] ,
19
19
test_bbl : bool ,
20
+ expected_result : Result < TexOutcome > ,
20
21
}
21
22
22
23
impl TestCase {
23
- fn new ( stem : & str , subdir : Option < & str > ) -> Self {
24
+ fn new ( parts : & ' static [ & ' static str ] ) -> Self {
25
+ assert ! ( !parts. is_empty( ) ) ;
24
26
TestCase {
25
- stem : stem. to_owned ( ) ,
26
- subdir : subdir. map ( String :: from) ,
27
+ parts,
27
28
test_bbl : true ,
29
+ expected_result : Ok ( TexOutcome :: Spotless ) ,
28
30
}
29
31
}
30
32
33
+ fn expect ( mut self , result : Result < TexOutcome > ) -> Self {
34
+ self . expected_result = result;
35
+ self
36
+ }
37
+
31
38
fn test_bbl ( mut self , test : bool ) -> Self {
32
39
self . test_bbl = test;
33
40
self
34
41
}
35
42
36
43
fn test_dir ( & self ) -> PathBuf {
37
44
let mut p = test_path ( & [ "bibtex" ] ) ;
38
- if let Some ( subdir ) = & self . subdir {
39
- p. push ( subdir ) ;
45
+ for sub in & self . parts [ .. self . parts . len ( ) - 1 ] {
46
+ p. push ( sub ) ;
40
47
}
41
48
p
42
49
}
43
50
44
- fn go ( & mut self ) {
51
+ fn go ( self ) {
45
52
util:: set_test_root ( ) ;
46
53
47
54
let mut p = self . test_dir ( ) ;
48
55
49
- let auxname = format ! ( "{}.aux" , self . stem ) ;
56
+ let auxname = format ! ( "{}.aux" , self . parts [ self . parts . len ( ) - 1 ] ) ;
50
57
51
58
// MemoryIo layer that will accept the outputs.
52
59
let mut mem = MemoryIo :: new ( true ) ;
@@ -64,11 +71,11 @@ impl TestCase {
64
71
65
72
// Check that outputs match expectations.
66
73
67
- p. push ( & self . stem ) ;
74
+ p. push ( self . parts [ self . parts . len ( ) - 1 ] ) ;
68
75
69
76
let files = mem. files . borrow ( ) ;
70
77
71
- let mut expect = Expected :: new ( ) ;
78
+ let mut expect = Expected :: new ( ) . res ( self . expected_result , res ) ;
72
79
73
80
if self . test_bbl {
74
81
expect =
@@ -78,109 +85,129 @@ impl TestCase {
78
85
expect
79
86
. file ( ExpectedFile :: read_with_extension ( & mut p, "blg" ) . collection ( & files) )
80
87
. finish ( ) ;
81
-
82
- res. unwrap ( ) ;
83
88
}
84
89
}
85
90
86
91
#[ test]
87
92
fn test_single_entry ( ) {
88
- TestCase :: new ( "single_entry ", Some ( "cites" ) ) . go ( )
93
+ TestCase :: new ( & [ "cites ", "single_entry" ] ) . go ( )
89
94
}
90
95
91
96
#[ test]
92
97
fn test_brace_string ( ) {
93
- TestCase :: new ( "odd_strings ", Some ( "cites" ) ) . go ( ) ;
98
+ TestCase :: new ( & [ "cites ", "odd_strings" ] ) . go ( ) ;
94
99
}
95
100
96
101
#[ test]
97
102
fn test_many ( ) {
98
- TestCase :: new ( "many" , Some ( "cites" ) ) . go ( ) ;
103
+ TestCase :: new ( & [ "cites" , "many" ] )
104
+ . expect ( Ok ( TexOutcome :: Warnings ) )
105
+ . go ( ) ;
99
106
}
100
107
101
108
#[ test]
102
109
fn test_colon ( ) {
103
- TestCase :: new ( "colon" , Some ( "cites" ) ) . go ( ) ;
110
+ TestCase :: new ( & [ "cites" , "colon" ] )
111
+ . expect ( Ok ( TexOutcome :: Warnings ) )
112
+ . go ( ) ;
104
113
}
105
114
106
115
#[ test]
107
116
fn test_empty_files ( ) {
108
- TestCase :: new ( "empty" , None ) . test_bbl ( false ) . go ( )
117
+ TestCase :: new ( & [ "empty" ] )
118
+ . expect ( Ok ( TexOutcome :: Errors ) )
119
+ . test_bbl ( false )
120
+ . go ( )
109
121
}
110
122
111
123
#[ test]
112
124
fn test_mismatched_function ( ) {
113
- TestCase :: new ( "function" , Some ( "mismatched_braces" ) )
125
+ TestCase :: new ( & [ "mismatched_braces" , "function" ] )
126
+ . expect ( Ok ( TexOutcome :: Errors ) )
114
127
. test_bbl ( false )
115
128
. go ( ) ;
116
129
}
117
130
118
131
#[ test]
119
132
fn test_mismatched_expr ( ) {
120
- TestCase :: new ( "expr" , Some ( "mismatched_braces" ) )
133
+ TestCase :: new ( & [ "mismatched_braces" , "expr" ] )
134
+ . expect ( Ok ( TexOutcome :: Errors ) )
121
135
. test_bbl ( false )
122
136
. go ( ) ;
123
137
}
124
138
125
139
#[ test]
126
140
fn test_mismatched_data ( ) {
127
- TestCase :: new ( "data" , Some ( "mismatched_braces" ) )
141
+ TestCase :: new ( & [ "mismatched_braces" , "data" ] )
142
+ . expect ( Ok ( TexOutcome :: Errors ) )
128
143
. test_bbl ( false )
129
144
. go ( ) ;
130
145
}
131
146
132
147
#[ test]
133
148
fn test_mismatched_style ( ) {
134
- TestCase :: new ( "style" , Some ( "mismatched_braces" ) )
149
+ TestCase :: new ( & [ "mismatched_braces" , "style" ] )
150
+ . expect ( Ok ( TexOutcome :: Errors ) )
135
151
. test_bbl ( false )
136
152
. go ( ) ;
137
153
}
138
154
139
155
#[ test]
140
156
fn test_duplicated_data ( ) {
141
- TestCase :: new ( "data" , Some ( "duplicated" ) )
157
+ TestCase :: new ( & [ "duplicated" , "data" ] )
158
+ . expect ( Ok ( TexOutcome :: Errors ) )
142
159
. test_bbl ( false )
143
160
. go ( ) ;
144
161
}
145
162
146
163
#[ test]
147
164
fn test_duplicated_style ( ) {
148
- TestCase :: new ( "style" , Some ( "duplicated" ) )
165
+ TestCase :: new ( & [ "duplicated" , "style" ] )
166
+ . expect ( Ok ( TexOutcome :: Errors ) )
149
167
. test_bbl ( false )
150
168
. go ( ) ;
151
169
}
152
170
153
171
#[ test]
154
172
fn test_bad_crossref ( ) {
155
- TestCase :: new ( "bad" , Some ( "crossref" ) ) . go ( ) ;
173
+ TestCase :: new ( & [ "crossref" , "bad" ] )
174
+ . expect ( Ok ( TexOutcome :: Errors ) )
175
+ . go ( ) ;
156
176
}
157
177
158
178
#[ test]
159
179
fn test_min_crossref ( ) {
160
- TestCase :: new ( "min" , Some ( "crossref" ) ) . go ( ) ;
180
+ TestCase :: new ( & [ "crossref" , "min" ] )
181
+ . expect ( Ok ( TexOutcome :: Warnings ) )
182
+ . go ( ) ;
161
183
}
162
184
163
185
#[ test]
164
186
fn test_single_preamble ( ) {
165
- TestCase :: new ( "single" , Some ( "preamble" ) ) . go ( ) ;
187
+ TestCase :: new ( & [ "preamble" , "single" ] )
188
+ . expect ( Ok ( TexOutcome :: Warnings ) )
189
+ . go ( ) ;
166
190
}
167
191
168
192
#[ test]
169
193
fn test_many_preamble ( ) {
170
- TestCase :: new ( "many" , Some ( "preamble" ) ) . go ( ) ;
194
+ TestCase :: new ( & [ "preamble" , "many" ] )
195
+ . expect ( Ok ( TexOutcome :: Warnings ) )
196
+ . go ( ) ;
171
197
}
172
198
173
199
#[ test]
174
200
fn test_nested_aux ( ) {
175
- TestCase :: new ( "nested ", Some ( "aux_files" ) ) . go ( ) ;
201
+ TestCase :: new ( & [ "aux_files ", "nested" ] ) . go ( ) ;
176
202
}
177
203
178
204
/// Test for [#1105](https://github.com/tectonic-typesetting/tectonic/issues/1105), with enough
179
205
/// citations in the aux and fields in the bst to require more than one allocation of field space
180
206
/// at once.
181
207
#[ test]
182
208
fn test_lots_of_cites ( ) {
183
- TestCase :: new ( "lots_of_cites" , Some ( "aux_files" ) )
209
+ TestCase :: new ( & [ "aux_files" , "lots_of_cites" ] )
210
+ . expect ( Ok ( TexOutcome :: Warnings ) )
184
211
. test_bbl ( false )
185
212
. go ( ) ;
186
213
}
0 commit comments