summaryrefslogtreecommitdiff
path: root/support/easylatex/unitTestDiffs.pl
blob: ddf6d4abcfe482a98a8627d56f7e75441e4839a4 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl



$TESTFILES_DIRNAME = 'testFiles';


#echo \*\*\* You should see nothing below except for lines starting with \*\*\*:


opendir(TESTFILESDIR, "$TESTFILES_DIRNAME") || die "can't opendir $TESTFILES_DIRNAME. Aborting.";

@tests = readdir(TESTFILESDIR);
closedir(TESTFILESDIR);

%tests = {};
foreach $test (@tests) { 
    if ($test =~ /.*\.txt$/) {
	$test =~ s/\.txt$//; 
	$test =~ s/.*\///;
	#print "$test\n";
	$tests{$test} = 1;
    }
}


foreach $test (keys %tests) {
    #if (string($test)) 
    #{print "$test\n";}

    print "Comparing $test...";
    #print "Comparing the results of ./easylatex testFiles/$test.txt to testFiles/$test.tex.correct\n";
    unlink "$test.tex";
    #print STDERR "perl easylatex.pl -e testFiles/$test.txt";
    system("perl easylatex.pl -e testFiles/$test.txt\n");
    
    #print STDERR "results: $test.tex vs. testFiles/$test.tex.correct\n";
    open(RESULTFILE, "$test.tex");
    undef $/;
    $result = <RESULTFILE>;
    close RESULTFILE;

    $result =~ s/easyLatexGraph\d+/easyLatexGraph/g;

    open(GOALFILE, "testFiles/$test.tex.correct");
    $goal = <GOALFILE>;
    close GOALFILE;

    #print $result;

    if ($result ne $goal) {
	print "DIFFERENCES!...";
    }

    print "done\n";

}