File:  [LON-CAPA] / loncom / test / filecomparetest.pl
Revision 1.2: download - view: text, annotated - select for diffs
Sun Jul 14 00:41:40 2002 UTC (22 years, 4 months ago) by harris41
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse
changing hard-coded directory name to existing directory variable

#!/usr/bin/perl

# The LearningOnline Network with CAPA
#
# YEAR=2001
# 11/16 Scott Harrison
#
#
###

my $dir='fctest';
my %tests=(
	   "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileB.txt",
	   "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: same\tsize: 0\tlines: 0\tdiffs: 0:0",
	   "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileE.txt",
	   "",
	   "perl ../build/filecompare.pl -p $dir/fileA.txt $dir/fileC.txt",
	   "",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileB.txt",
	   "",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileE.txt",
	   "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: 29\tlines: 1\tdiffs: 1:0",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt",
	   "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: -2\tlines: 0\tdiffs: 1:1",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileF.txt",
	   "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: -3\tmd5sum: different\tsize: 29\tlines: 1\tdiffs: 1:0",
	   "perl ../build/filecompare.pl -q $dir/fileA.txt $dir/fileF.txt",
	   "$dir/fileA.txt",
	   "perl ../build/filecompare.pl -b1 $dir/fileA.txt $dir/fileB.txt",
	   "1",
	   "perl ../build/filecompare.pl -b1 $dir/fileA.txt $dir/fileC.txt",
	   "2",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt age",
	   "",
	   "perl ../build/filecompare.pl -n $dir/fileA.txt $dir/fileC.txt age size",
	   "$dir/fileA.txt\texistence: yes:yes\tcvstime: n/a\tage: 0\tmd5sum: different\tsize: -2\tlines: 0\tdiffs: 1:1",
	   );

unless (-d $dir) {
    `mkdir $dir`;
}
chdir $dir;
open OUT,">fileA.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
whose hair was white as snow
END
close OUT;
open OUT,">fileB.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
whose hair was white as snow
END
close OUT;
open OUT,">fileC.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
whose fleece was white as snow
END
close OUT;
open OUT,">fileD.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
whose fleece was white as snow
END
close OUT;
open OUT,">fileE.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
END
close OUT;
my $now=time;
utime($now,$now,'fileA.txt');
utime($now,$now,'fileB.txt');
utime($now,$now,'fileC.txt');
utime($now,$now,'fileD.txt');
utime($now,$now,'fileE.txt');
sleep 3;
open OUT,">fileF.txt";
print OUT <<END;
Mary had a little lamb
Little lamb
Little lamb
Mary had a little lamb
END
close OUT;
`install -d CVS`;
open OUT,">CVS/Entries";
print OUT <<END;
/fileA.txt/3.14/Mon May  3 15:33:20 1976//
/fileF.txt/3.14/Mon May  3 15:33:20 1976//
END
close OUT;

chdir '..';
my $tc=1;
my $tt=0;
foreach my $test (keys %tests) {
    print "Test $tc...";
    my $value=`$test 2>/dev/null`; chomp $value;
    my $ec=$?/256;
    if (length($tests{$test})==1 and $ec==$tests{$test}) {
	print "ok\n";
	$tt++;
    }
    elsif (length($tests{$test})==1 and $ec!=$tests{$test}) {
	print "FAILED\n";
    }
    elsif ($value eq $tests{$test}) {
	print "ok\n";
	$tt++;
    }
    else {
	print "FAILED $test\n";
    }
    $tc++;
}
$tc--;

print "Tests: $tt/$tc successful (".sprintf("%3.1f",$tt/$tc*100)." \%)\n";
if ($tt!=$tc) {
    print "ERROR with filecompare.pl\n";
    exit 1;
}
exit 0;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>