Annotation of loncom/test/filecomparetest.pl, revision 1.2
1.1 harris41 1: #!/usr/bin/perl
2:
3: # The LearningOnline Network with CAPA
4: #
5: # YEAR=2001
6: # 11/16 Scott Harrison
7: #
8: #
9: ###
10:
11: my $dir='fctest';
12: my %tests=(
13: "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileB.txt",
1.2 ! harris41 14: "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: same\tsize: 0\tlines: 0\tdiffs: 0:0",
1.1 harris41 15: "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileE.txt",
16: "",
17: "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileC.txt",
18: "",
19: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileB.txt",
20: "",
21: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileE.txt",
1.2 ! harris41 22: "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: 29\tlines: 1\tdiffs: 1:0",
1.1 harris41 23: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt",
1.2 ! harris41 24: "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: -2\tlines: 0\tdiffs: 1:1",
1.1 harris41 25: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileF.txt",
1.2 ! harris41 26: "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: -3\tmd5sum: different\tsize: 29\tlines: 1\tdiffs: 1:0",
1.1 harris41 27: "perl ../build/filecompare.pl -q $dir/fileA.txt $dir/fileF.txt",
1.2 ! harris41 28: "$dir/fileA.txt",
1.1 harris41 29: "perl ../build/filecompare.pl -b1 $dir/fileA.txt $dir/fileB.txt",
30: "1",
31: "perl ../build/filecompare.pl -b1 $dir/fileA.txt $dir/fileC.txt",
32: "2",
33: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt age",
34: "",
35: "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt age size",
1.2 ! harris41 36: "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: -2\tlines: 0\tdiffs: 1:1",
1.1 harris41 37: );
38:
39: unless (-d $dir) {
40: `mkdir $dir`;
41: }
42: chdir $dir;
43: open OUT,">fileA.txt";
44: print OUT <<END;
45: Mary had a little lamb
46: Little lamb
47: Little lamb
48: Mary had a little lamb
49: whose hair was white as snow
50: END
51: close OUT;
52: open OUT,">fileB.txt";
53: print OUT <<END;
54: Mary had a little lamb
55: Little lamb
56: Little lamb
57: Mary had a little lamb
58: whose hair was white as snow
59: END
60: close OUT;
61: open OUT,">fileC.txt";
62: print OUT <<END;
63: Mary had a little lamb
64: Little lamb
65: Little lamb
66: Mary had a little lamb
67: whose fleece was white as snow
68: END
69: close OUT;
70: open OUT,">fileD.txt";
71: print OUT <<END;
72: Mary had a little lamb
73: Little lamb
74: Little lamb
75: Mary had a little lamb
76: whose fleece was white as snow
77: END
78: close OUT;
79: open OUT,">fileE.txt";
80: print OUT <<END;
81: Mary had a little lamb
82: Little lamb
83: Little lamb
84: Mary had a little lamb
85: END
86: close OUT;
87: my $now=time;
88: utime($now,$now,'fileA.txt');
89: utime($now,$now,'fileB.txt');
90: utime($now,$now,'fileC.txt');
91: utime($now,$now,'fileD.txt');
92: utime($now,$now,'fileE.txt');
93: sleep 3;
94: open OUT,">fileF.txt";
95: print OUT <<END;
96: Mary had a little lamb
97: Little lamb
98: Little lamb
99: Mary had a little lamb
100: END
101: close OUT;
102: `install -d CVS`;
103: open OUT,">CVS/Entries";
104: print OUT <<END;
105: /fileA.txt/3.14/Mon May 3 15:33:20 1976//
106: /fileF.txt/3.14/Mon May 3 15:33:20 1976//
107: END
108: close OUT;
109:
110: chdir '..';
111: my $tc=1;
112: my $tt=0;
113: foreach my $test (keys %tests) {
114: print "Test $tc...";
115: my $value=`$test 2>/dev/null`; chomp $value;
116: my $ec=$?/256;
117: if (length($tests{$test})==1 and $ec==$tests{$test}) {
118: print "ok\n";
119: $tt++;
120: }
121: elsif (length($tests{$test})==1 and $ec!=$tests{$test}) {
122: print "FAILED\n";
123: }
124: elsif ($value eq $tests{$test}) {
125: print "ok\n";
126: $tt++;
127: }
128: else {
129: print "FAILED $test\n";
130: }
131: $tc++;
132: }
133: $tc--;
134:
135: print "Tests: $tt/$tc successful (".sprintf("%3.1f",$tt/$tc*100)." \%)\n";
136: if ($tt!=$tc) {
137: print "ERROR with filecompare.pl\n";
138: exit 1;
139: }
140: exit 0;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>