Debian Codegraph @

test/main.t

raw
1 #!/usr/bin/env perl
2 # =============================================================================
3 #
4 # This file is part of BibTool.
5 # It is distributed under the GNU General Public License.
6 # See the file COPYING for details.
7 #
8 # (c) 2011-2020 Gerd Neugebauer
9 #
10 # Net: [email protected]
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
15 # any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #
26 #*=============================================================================
27
28 =head1 NAME
29
30 main.t - Test suite for BibTool main.
31
32 =head1 SYNOPSIS
33
34 main.t
35
36 =head1 DESCRIPTION
37
38 This module contains some test cases. Running this module as program
39 will run all test cases and print a summary for each. Optionally files
40 *.out and *.err are left if the expected result does not match the
41 actual result.
42
43 =head1 OPTIONS
44
45 none
46
47 =head1 AUTHOR
48
49 Gerd Neugebauer
50
51 =cut
52
53 use strict;
54 use BUnit;use warnings;
55
56
57
58 #------------------------------------------------------------------------------
59 BUnit::run(name => 'main_0',
60 args => '',
61 expected_out => '',
62 expected_err => '');
63
64 #------------------------------------------------------------------------------
65 BUnit::run(name => 'main_1',
66 args => 'xyzzy',
67 expected_out => '',
68 expected_err => <<__EOF__);
69
70 *** BibTool WARNING: File xyzzy not found.
71 __EOF__
72
73 #------------------------------------------------------------------------------
74 BUnit::run(name => 'main_2',
75 args => 'bib/x1.bib',
76 expected_out => <<__EOF__,
77
78 \@Manual{ bibtool,
79 title = {BibTool},
80 author = {Gerd Neugebauer},
81 year = 2018
82 }
83 __EOF__
84 expected_err => '');
85
86 #------------------------------------------------------------------------------
87 BUnit::run(name => 'main_3',
88 args => 'bib/x1',
89 expected_out => <<__EOF__,
90
91 \@Manual{ bibtool,
92 title = {BibTool},
93 author = {Gerd Neugebauer},
94 year = 2018
95 }
96 __EOF__
97 expected_err => '');
98
99 #------------------------------------------------------------------------------
100 BUnit::run(name => 'main_4',
101 args => 'bib/xampl.bib',
102 expected_out => <<__EOF__,
103 \@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} "
104 # "\\newcommand{\\printfirst}[2]{#1} "
105 # "\\newcommand{\\singleletter}[1]{#1} "
106 # "\\newcommand{\\switchargs}[2]{#2#1} " }
107 \@STRING{acm = "The OX Association for Computing Machinery" }
108 \@STRING{stoc = " Symposium on the Theory of Computing" }
109 \@STRING{stoc-key= "OX{\\singleletter{stoc}}" }
110
111 \@Article{ article-minimal,
112 author = {L[eslie] A. Aamport},
113 title = {The Gnats and Gnus Document Preparation System},
114 journal = {\\mbox{G-Animal's} Journal},
115 year = 1986
116 }
117
118 \@Article{ article-full,
119 author = {L[eslie] A. Aamport},
120 title = {The Gnats and Gnus Document Preparation System},
121 journal = {\\mbox{G-Animal's} Journal},
122 year = 1986,
123 volume = 41,
124 number = 7,
125 pages = "73+",
126 month = jul,
127 note = "This is a full ARTICLE entry"
128 }
129
130 \@Article{ article-crossref,
131 crossref = {WHOLE-JOURNAL},
132 key = "",
133 author = {L[eslie] A. Aamport},
134 title = {The Gnats and Gnus Document Preparation System},
135 pages = "73+",
136 note = "This is a cross-referencing ARTICLE entry"
137 }
138
139 \@Article{ whole-journal,
140 key = "GAJ",
141 journal = {\\mbox{G-Animal\'s} Journal},
142 year = 1986,
143 volume = 41,
144 number = 7,
145 month = jul,
146 note = {The entire issue is devoted to gnats and gnus (this entry
147 is a cross-referenced ARTICLE (journal))}
148 }
149
150 \@InBook{ inbook-minimal,
151 author = "Donald E. Knuth",
152 title = "Fundamental Algorithms",
153 publisher = "Addison-Wesley",
154 year = "{\\noopsort{1973b}}1973",
155 chapter = "1.2"
156 }
157
158 \@InBook{ inbook-full,
159 author = "Donald E. Knuth",
160 title = "Fundamental Algorithms",
161 volume = 1,
162 series = "The Art of Computer Programming",
163 publisher = "Addison-Wesley",
164 address = "Reading, Massachusetts",
165 edition = "Second",
166 month = "10~" # jan,
167 year = "{\\noopsort{1973b}}1973",
168 type = "Section",
169 chapter = "1.2",
170 pages = "10--119",
171 note = "This is a full INBOOK entry"
172 }
173
174 \@InBook{ inbook-crossref,
175 crossref = "whole-set",
176 title = "Fundamental Algorithms",
177 volume = 1,
178 series = "The Art of Computer Programming",
179 edition = "Second",
180 year = "{\\noopsort{1973b}}1973",
181 type = "Section",
182 chapter = "1.2",
183 note = "This is a cross-referencing INBOOK entry"
184 }
185
186 \@Book{ book-minimal,
187 author = "Donald E. Knuth",
188 title = "Seminumerical Algorithms",
189 publisher = "Addison-Wesley",
190 year = "{\\noopsort{1973c}}1981"
191 }
192
193 \@Book{ book-full,
194 author = "Donald E. Knuth",
195 title = "Seminumerical Algorithms",
196 volume = 2,
197 series = "The Art of Computer Programming",
198 publisher = "Addison-Wesley",
199 address = "Reading, Massachusetts",
200 edition = "Second",
201 month = "10~" # jan,
202 year = "{\\noopsort{1973c}}1981",
203 note = "This is a full BOOK entry"
204 }
205
206 \@Book{ book-crossref,
207 crossref = "whole-set",
208 title = "Seminumerical Algorithms",
209 volume = 2,
210 series = "The Art of Computer Programming",
211 edition = "Second",
212 year = "{\\noopsort{1973c}}1981",
213 note = "This is a cross-referencing BOOK entry"
214 }
215
216 \@Book{ whole-set,
217 author = "Donald E. Knuth",
218 publisher = "Addison-Wesley",
219 title = "The Art of Computer Programming",
220 series = "Four volumes",
221 year = "{\\noopsort{1973a}}{\\switchargs{--90}{1968}}",
222 note = "Seven volumes planned (this is a cross-referenced set of
223 BOOKs)"
224 }
225
226 \@Booklet{ booklet-minimal,
227 key = "Kn{\\printfirst{v}{1987}}",
228 title = "The Programming of Computer Art"
229 }
230
231 \@Booklet{ booklet-full,
232 author = "Jill C. Knvth",
233 title = "The Programming of Computer Art",
234 howpublished = "Vernier Art Center",
235 address = "Stanford, California",
236 month = feb,
237 year = 1988,
238 note = "This is a full BOOKLET entry"
239 }
240
241 \@InCollection{ incollection-minimal,
242 author = "Daniel D. Lincoll",
243 title = "Semigroups of Recurrences",
244 booktitle = "High Speed Computer and Algorithm Organization",
245 publisher = "Academic Press",
246 year = 1977
247 }
248
249 \@InCollection{ incollection-full,
250 author = "Daniel D. Lincoll",
251 title = "Semigroups of Recurrences",
252 editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh",
253 booktitle = "High Speed Computer and Algorithm Organization",
254 number = 23,
255 series = "Fast Computers",
256 chapter = 3,
257 type = "Part",
258 pages = "179--183",
259 publisher = "Academic Press",
260 address = "New York",
261 edition = "Third",
262 month = sep,
263 year = 1977,
264 note = "This is a full INCOLLECTION entry"
265 }
266
267 \@InCollection{ incollection-crossref,
268 crossref = "whole-collection",
269 author = "Daniel D. Lincoll",
270 title = "Semigroups of Recurrences",
271 pages = "179--183",
272 note = "This is a cross-referencing INCOLLECTION entry"
273 }
274
275 \@Book{ whole-collection,
276 editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh",
277 title = "High Speed Computer and Algorithm Organization",
278 booktitle = "High Speed Computer and Algorithm Organization",
279 number = 23,
280 series = "Fast Computers",
281 publisher = "Academic Press",
282 address = "New York",
283 edition = "Third",
284 month = sep,
285 year = 1977,
286 note = "This is a cross-referenced BOOK (collection) entry"
287 }
288
289 \@Manual{ manual-minimal,
290 key = "Manmaker",
291 title = "The Definitive Computer Manual"
292 }
293
294 \@Manual{ manual-full,
295 author = "Larry Manmaker",
296 title = "The Definitive Computer Manual",
297 organization = "Chips-R-Us",
298 address = "Silicon Valley",
299 edition = "Silver",
300 month = apr # "-" # may,
301 year = 1986,
302 note = "This is a full MANUAL entry"
303 }
304
305 \@MastersThesis{ mastersthesis-minimal,
306 author = "{\\'{E}}douard Masterly",
307 title = "Mastering Thesis Writing",
308 school = "Stanford University",
309 year = 1988
310 }
311
312 \@MastersThesis{ mastersthesis-full,
313 author = "{\\'{E}}douard Masterly",
314 title = "Mastering Thesis Writing",
315 school = "Stanford University",
316 type = "Master's project",
317 address = "English Department",
318 month = jun # "-" # aug,
319 year = 1988,
320 note = "This is a full MASTERSTHESIS entry"
321 }
322
323 \@Misc{ misc-minimal,
324 key = "Missilany",
325 note = "This is a minimal MISC entry"
326 }
327
328 \@Misc{ misc-full,
329 author = "Joe-Bob Missilany",
330 title = "Handing out random pamphlets in airports",
331 howpublished = "Handed out at O'Hare",
332 month = oct,
333 year = 1984,
334 note = "This is a full MISC entry"
335 }
336
337 \@InProceedings{ inproceedings-minimal,
338 author = "Alfred V. Oaho and Jeffrey D. Ullman and Mihalis
339 Yannakakis",
340 title = "On Notions of Information Transfer in {VLSI} Circuits",
341 booktitle = "Proc. Fifteenth Annual ACM" # stoc,
342 year = 1983
343 }
344
345 \@InProceedings{ inproceedings-full,
346 author = "Alfred V. Oaho and Jeffrey D. Ullman and Mihalis
347 Yannakakis",
348 title = "On Notions of Information Transfer in {VLSI} Circuits",
349 editor = "Wizard V. Oz and Mihalis Yannakakis",
350 booktitle = "Proc. Fifteenth Annual ACM" # stoc,
351 number = 17,
352 series = "All ACM Conferences",
353 pages = "133--139",
354 month = mar,
355 year = 1983,
356 address = "Boston",
357 organization = acm,
358 publisher = "Academic Press",
359 note = "This is a full INPROCEDINGS entry"
360 }
361
362 \@InProceedings{ inproceedings-crossref,
363 crossref = "whole-proceedings",
364 author = "Alfred V. Oaho and Jeffrey D. Ullman and Mihalis
365 Yannakakis",
366 title = "On Notions of Information Transfer in {VLSI} Circuits",
367 organization = "",
368 pages = "133--139",
369 note = "This is a cross-referencing INPROCEEDINGS entry"
370 }
371
372 \@Proceedings{ proceedings-minimal,
373 key = stoc-key,
374 title = "Proc. Fifteenth Annual" # stoc,
375 year = 1983
376 }
377
378 \@Proceedings{ proceedings-full,
379 editor = "Wizard V. Oz and Mihalis Yannakakis",
380 title = "Proc. Fifteenth Annual" # stoc,
381 number = 17,
382 series = "All ACM Conferences",
383 month = mar,
384 year = 1983,
385 address = "Boston",
386 organization = acm,
387 publisher = "Academic Press",
388 note = "This is a full PROCEEDINGS entry"
389 }
390
391 \@Proceedings{ whole-proceedings,
392 key = stoc-key,
393 organization = acm,
394 title = "Proc. Fifteenth Annual" # stoc,
395 address = "Boston",
396 year = 1983,
397 booktitle = "Proc. Fifteenth Annual ACM" # stoc,
398 note = "This is a cross-referenced PROCEEDINGS"
399 }
400
401 \@PhDThesis{ phdthesis-minimal,
402 author = "F. Phidias Phony-Baloney",
403 title = "Fighting Fire with Fire: Festooning {F}rench Phrases",
404 school = "Fanstord University",
405 year = 1988
406 }
407
408 \@PhDThesis{ phdthesis-full,
409 author = "F. Phidias Phony-Baloney",
410 title = "Fighting Fire with Fire: Festooning {F}rench Phrases",
411 school = "Fanstord University",
412 type = "{PhD} Dissertation",
413 address = "Department of French",
414 month = jun # "-" # aug,
415 year = 1988,
416 note = "This is a full PHDTHESIS entry"
417 }
418
419 \@TechReport{ techreport-minimal,
420 author = "Tom Terrific",
421 title = "An {\$O(n \\log n / \\! \\log\\log n)\$} Sorting Algorithm",
422 institution = "Fanstord University",
423 year = 1988
424 }
425
426 \@TechReport{ techreport-full,
427 author = "Tom T{\\'{e}}rrific",
428 title = "An {\$O(n \\log n / \\! \\log\\log n)\$} Sorting Algorithm",
429 institution = "Fanstord University",
430 type = "Wishful Research Result",
431 number = "7",
432 address = "Computer Science Department, Fanstord, California",
433 month = oct,
434 year = 1988,
435 note = "This is a full TECHREPORT entry"
436 }
437
438 \@Unpublished{ unpublished-minimal,
439 author = "Ulrich {\\"{U}}nderwood and Ned {\\~N}et and Paul {\\={P}}ot",
440 title = "Lower Bounds for Wishful Research Results",
441 note = "Talk at Fanstord University (this is a minimal UNPUBLISHED
442 entry)"
443 }
444
445 \@Unpublished{ unpublished-full,
446 author = "Ulrich {\\"{U}}nderwood and Ned {\\~N}et and Paul {\\={P}}ot",
447 title = "Lower Bounds for Wishful Research Results",
448 month = nov # ", " # dec,
449 year = 1988,
450 note = "Talk at Fanstord University (this is a full UNPUBLISHED
451 entry)"
452 }
453
454 \@Misc{ random-note-crossref,
455 key = {Volume-2},
456 note = "Volume~2 is listed under Knuth \\cite{book-full}"
457 }
458 __EOF__
459 expected_err => <<__EOF__);
460
461 *** BibTool WARNING (line 29 in ./bib/xampl.bib): 125 non-space characters ignored.
462 __EOF__
463
464 #------------------------------------------------------------------------------
465 BUnit::run(name => '_h_1',
466 args => '-h',
467 expected_out => '',
468 expected_err => <<__EOF__ ,
469 BibTool Vers. 2.xxx (C) 1996-2xxx Gerd Neugebauer
470
471 bibtool [options] [-o outfile] [[-i] infile] ...
472
473 Options:
474 -A<c> Kind of disambiguating key strings: <c>=0|a|A
475 -c Include crossreferenced entries into the output (toggle)
476 -d Check double entries (toggle)
477 -f <format> Key generation enabled (formatted key)
478 -F Key generation enabled with formatted key
479 -h Print this help info and exit
480 [-i] infile Specify input file. If -i omitted it may not start
481 with a -. If absent stdin is taken to read from.
482 Multiple input files may be given.
483 -k Key generation enabled.
484 -K Key generation enabled (long key).
485 -m macfile Dump macros to macfile. - is stdout
486 -M macfile Dump used macros to macfile. - is stdout
487 -o outfile Specify output file as next argument
488 If absent stdout is taken to write to.
489 -q Quiet mode. No warnings.
490 -r resource Load resource file (several are possible).
491 -R Load default resource file here.
492 -s Sort.
493 -S Sort reverse.
494 -v Enable verbose mode.
495 -V Print version and exit.
496 -x file Extract from aux file.
497 -X <regex> Extract regular expression.
498 -- <rsc> Evaluate one resource command <rsc>.
499 -\@ Print statistics (short).
500 -# Print statistics.
501
502 Library path: xxx
503 Special configuration options: xxx
504 __EOF__
505 fct_err =>
506 sub{local $_ = shift;
507 s/Vers. 2.[0-9]+[-a-z]*/Vers. 2.xxx/;
508 s/1996-2.../1996-2xxx/;
509 s/Library path: .*/Library path: xxx/;
510 s/Special configuration options: .*/Special configuration options: xxx/;
511 return $_
512 } );
513
514 #------------------------------------------------------------------------------
515 BUnit::run(name => '_V_1',
516 args => '-V',
517 expected_out => '',
518 expected_err => <<__EOF__ ,
519 BibTool Vers. 2.xxx (C) 1996-2xxx Gerd Neugebauer
520
521 Library path: xxx
522 Special configuration options: xxx
523 __EOF__
524 fct_err =>
525 sub{local $_ = shift;
526 s/Vers. 2.[0-9]+[-a-z]*/Vers. 2.xxx/;
527 s/1996-2.../1996-2xxx/;
528 s/Library path: .*/Library path: xxx/;
529 s/Special configuration options: .*/Special configuration options: xxx/;
530 return $_
531 } );
532
533 #------------------------------------------------------------------------------
534 BUnit::run(name => '_dash_dash_1',
535 args => '-- xyzzy=on',
536 expected_err => "\n*** BibTool ERROR: Resource xyzzy unknown.\n");
537
538
539 #------------------------------------------------------------------------------
540 BUnit::run(name => '_dash_dash_2',
541 args => '--xyzzy=on',
542 expected_err => "\n*** BibTool ERROR: Resource xyzzy unknown.\n");
543
544
545 1;
546 #------------------------------------------------------------------------------
547 # Local Variables:
548 # mode: perl
549 # End: