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 63 64 65 66 67 68 69 70 71 72 73
|
##
## TEST.pl -- WML Test Suite utility functions
## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
##
package TEST;
@TMPFILES = ();
$TMPFILECNT = 0;
sub init {
return;
}
sub tmpfile {
local (*FP, $file);
$file = "tmp." . sprintf("%02d", $TMPFILECNT++);
push(@TMPFILES, $file);
if (@_ != -1) {
open(FP, ">$file");
print FP @_;
close(FP);
}
return $file;
}
sub tmpfile_with_name {
local ($name) = shift @_;
local (*FP, $file);
$file = $name;
push(@TMPFILES, $file);
if (@_ != -1) {
open(FP, ">$file");
print FP @_;
close(FP);
}
return $file;
}
sub system {
local ($cmd) = @_;
local ($rc);
$rc = system($cmd);
return $rc;
}
sub generic {
local ($pass, $in, $out, $opt) = @_;
local($tmpfile1, $tmpfile2, $tmpfile3, $rc);
$tmpfile1 = &tmpfile(qq#$in#);
$tmpfile2 = &tmpfile(qq#$out#);
$tmpfile3 = &tmpfile;
$rc = &system("$ENV{WML} -p$pass $opt $tmpfile1 >$tmpfile3");
print ($rc == 0 ? "ok\n" : "not ok\n");
$rc = &system("cmp $tmpfile2 $tmpfile3");
print ($rc == 0 ? "ok\n" : "not ok\n");
}
sub cleanup {
foreach $file (@TMPFILES) {
unlink($file);
}
}
1;
##EOF##
|