Skip to content

Commit

Permalink
Add test reproducing core dump on unterminated \verb
Browse files Browse the repository at this point in the history
See #82
  • Loading branch information
pkubowicz committed Dec 16, 2023
1 parent e338b83 commit 85e7400
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ indent_size = 2

[{Makefile,README,*.pl,*.sh,*.l,*.h}]
indent_style = tab

[{*.txt,*.tex}]
insert_final_newline = false
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,7 @@ package: clean detex.c
detex.c: detex.h
detex.c: detex.l

inpdf:
cd test && xelatex -interaction=nonstopmode in.tex || echo there were errors
rm -f test/*.toc test/*.log test/*.aux
mv test/in.pdf .
19 changes: 17 additions & 2 deletions test.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/perl -w

use strict;

assert_produces_correct_output('in.tex', 'correct.txt');
assert_produces_correct_output('in.tex', 'correct.txt', '-l');
assert_produces_correct_output('noinclude.tex', 'noinclude-correct.txt', '-n');
Expand All @@ -12,7 +14,11 @@
run_for_wrong_input("non-existent-file");
run_for_wrong_input("non-existent-file.tex");
run_for_wrong_input("non-existent-file.txt");
run_for_wrong_input("test/unterminated.txt");
run_for_wrong_input("test/unterminated.tex");
run_for_wrong_input("test/unterminated-verb-pipe.tex");

run_for_input_with_error("test/unterminated-verb.tex");
run_for_input_with_error("test/unterminated-verb-eol.tex");

print "Tests ok\n";

Expand Down Expand Up @@ -46,9 +52,18 @@ sub run_for_wrong_input {
execute_cmd("./delatex $input");
}

sub run_for_input_with_error {
my ($input) = @_;
print "Checking response for $input...\n";
# https://www.perlmonks.org/?node_id=81640
my $res = system(get_cmd("./delatex $input")) >> 8;
die "exit code $res" if ($res != 1);
}

sub execute_cmd {
my ($cmd) = @_;
system(get_cmd($cmd)) == 0 or die;
my $res = system(get_cmd($cmd));
die "exit code $res" if ($res != 0);
}

sub get_cmd {
Expand Down
4 changes: 4 additions & 0 deletions test/unterminated-verb-eol.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass[draft]{book}
\begin{document}
\verb+ok+
\verb
4 changes: 4 additions & 0 deletions test/unterminated-verb-pipe.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass[draft]{book}
\begin{document}
\verb+ok+
\verb|
4 changes: 4 additions & 0 deletions test/unterminated-verb.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass[draft]{book}
\begin{document}
\verb+ok+
\verb
File renamed without changes.

0 comments on commit 85e7400

Please sign in to comment.