forked from pkubowicz/opendetex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.pl
executable file
·47 lines (40 loc) · 1.13 KB
/
test.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w
assert_produces_correct_output();
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");
print "Tests ok\n";
sub assert_produces_correct_output {
print "Checking correct output is produced...\n";
execute_cmd("./delatex test/in > /tmp/testDelatex.txt");
my $diffResult = `diff test/correct.txt /tmp/testDelatex.txt`;
if ($diffResult ne '') {
print "Test failed:\n";
my $compared = "test/correct.txt /tmp/testDelatex.txt";
if (`which kdiff3`) {
system("kdiff3 $compared");
} elsif (`which vimdiff`) {
system("vimdiff $compared");
} else {
system("diff -u $compared");
}
exit(11);
}
}
sub run_for_wrong_input {
my ($input) = @_;
print "Checking response for $input...\n";
execute_cmd("./delatex $input");
}
sub execute_cmd {
my ($cmd) = @_;
system(get_cmd($cmd)) == 0 or die;
}
sub get_cmd {
my ($cmd) = @_;
if ($ARGV[0] && $ARGV[0] eq '--valgrind') {
$cmd = "valgrind --leak-check=yes --leak-check=full --show-leak-kinds=all --error-exitcode=1 $cmd";
}
return $cmd;
}