diff --git a/.editorconfig b/.editorconfig index cc458e2..f5bb98e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ indent_size = 2 [{Makefile,README,*.pl,*.sh,*.l,*.h}] indent_style = tab + +[{*.txt,*.tex}] +insert_final_newline = false diff --git a/Makefile b/Makefile index 29f6c2c..c370ec4 100644 --- a/Makefile +++ b/Makefile @@ -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 . diff --git a/test.pl b/test.pl index 0272c55..cbac267 100755 --- a/test.pl +++ b/test.pl @@ -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'); @@ -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"; @@ -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 { diff --git a/test/unterminated-verb-eol.tex b/test/unterminated-verb-eol.tex new file mode 100644 index 0000000..c54558b --- /dev/null +++ b/test/unterminated-verb-eol.tex @@ -0,0 +1,4 @@ +\documentclass[draft]{book} +\begin{document} +\verb+ok+ +\verb \ No newline at end of file diff --git a/test/unterminated-verb-pipe.tex b/test/unterminated-verb-pipe.tex new file mode 100644 index 0000000..ca82438 --- /dev/null +++ b/test/unterminated-verb-pipe.tex @@ -0,0 +1,4 @@ +\documentclass[draft]{book} +\begin{document} +\verb+ok+ +\verb| diff --git a/test/unterminated-verb.tex b/test/unterminated-verb.tex new file mode 100644 index 0000000..d6b64c4 --- /dev/null +++ b/test/unterminated-verb.tex @@ -0,0 +1,4 @@ +\documentclass[draft]{book} +\begin{document} +\verb+ok+ +\verb diff --git a/test/unterminated.txt b/test/unterminated.tex similarity index 100% rename from test/unterminated.txt rename to test/unterminated.tex