diff options
author | Jim Meyering <jim@meyering.net> | 1996-12-10 21:16:48 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1996-12-10 21:16:48 +0000 |
commit | d468c227b023963cfcc5d8024239c21382c85ddb (patch) | |
tree | bed21c884e53c6760016ba1cbaf6653aec20e5b2 /tests/cut | |
parent | 52314f2cd8cb515779b117062a8ef0b0258c7a34 (diff) | |
download | coreutils-d468c227b023963cfcc5d8024239c21382c85ddb.tar.xz |
renamed from build-script.pl
Diffstat (limited to 'tests/cut')
-rw-r--r-- | tests/cut/mk-script.pl | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/cut/mk-script.pl b/tests/cut/mk-script.pl new file mode 100644 index 000000000..58a1328f6 --- /dev/null +++ b/tests/cut/mk-script.pl @@ -0,0 +1,88 @@ +#! @PERL@ -w +# -*- perl -*- +# @configure_input@ + +require 5.002; + +BEGIN { push @INC, '@srcdir@' if '@srcdir@' ne '.'; } +use strict; +use Test; + +$| = 1; + +my $xx = $ARGV[0]; + +print <<EOF; +#! /bin/sh +# This script was generated automatically by build-script. +case \$# in + 0) xx='$xx';; + *) xx="\$1";; +esac +test "\$VERBOSE" && echo=echo || echo=: +\$echo testing program: \$xx +errors=0 +test "\$srcdir" || srcdir=. +test "\$VERBOSE" && \$xx --version 2> /dev/null +EOF + +my %seen; + +my $test_vector; +foreach $test_vector (@Test::t) + { + my ($test_name, $flags, $file1, $file2, $expected, $e_ret_code) + = @{$test_vector}; + die "$0: $.: duplicate test name \`$test_name'\n" + if (defined ($seen{$test_name})); + $seen{$test_name} = 1; + + my $in1 = "t$test_name.in1"; + my $in2 = "t$test_name.in2"; + my $exp_name = "t$test_name.exp"; + my $out = "t$test_name.out"; + + open (IN1, ">$in1") || die "$0: $in1: $!\n"; + print IN1 $file1; + close (IN1) || die "$0: $in1: $!\n"; + + open (IN2, ">$in2") || die "$0: $in2: $!\n"; + print IN2 $file2; + close (IN2) || die "$0: $in2: $!\n"; + + open (EXP, ">$exp_name") || die "$0: $exp_name: $!\n"; + print EXP $expected; + close (EXP) || die "$0: $exp_name: $!\n"; + + my $err_output = "t$test_name.err"; + my $cmd = "\$xx $flags \$srcdir/$in1 \$srcdir/$in2 > $out 2> $err_output"; + $exp_name = "\$srcdir/$exp_name"; + print <<EOF ; +$cmd +code=\$? +if test \$code != $e_ret_code ; then + \$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2 + errors=`expr \$errors + 1` +else + cmp $out $exp_name + case \$? in + 0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files + 1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2; + errors=`expr \$errors + 1` ;; + 2) \$echo Test $test_name may have failed. 1>&2; + \$echo The command \"cmp $out $exp_name\" failed. 1>&2 ; + errors=`expr \$errors + 1` ;; + esac +fi +test -s $err_output || rm -f $err_output +EOF + } +print <<EOF2 ; +if test \$errors = 0 ; then + \$echo Passed all tests. 1>&2 +else + \$echo Failed \$errors tests. 1>&2 +fi +test \$errors = 0 || errors=1 +exit \$errors +EOF2 |