From 17e6c3926d9b634237fc92e3185e068b0549d358 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Mon, 16 Jan 2017 16:27:11 -0800
Subject: [PATCH 01/12] tests: support perl-based tests like those of grep and
coreutils
* configure.ac: Define HAVE_PERL.
* testsuite/Coreutils.pm: New file. From grep.
* testsuite/CuSkip.pm: Likewise.
* testsuite/CuTmpdir.pm: Likewise.
* testsuite/local.mk (, TEST_EXTENSIONS): Add .pl.
(TESTSUITE_PERL, TESTSUITE_PERL_OPTIONS): Define.
(PL_LOG_COMPILER): Define.
(EXTRA_DIST): Add the new .pm files.
---
configure.ac | 7 +
testsuite/Coreutils.pm | 620 +++++++++++++++++++++++++++++++++++++++++++++++++
testsuite/CuSkip.pm | 39 ++++
testsuite/CuTmpdir.pm | 111 +++++++++
testsuite/local.mk | 23 +-
5 files changed, 798 insertions(+), 2 deletions(-)
create mode 100644 testsuite/Coreutils.pm
create mode 100644 testsuite/CuSkip.pm
create mode 100644 testsuite/CuTmpdir.pm
diff --git a/configure.ac b/configure.ac
index 8076382..f6a68ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,13 @@ gl_EARLY
gl_INIT
gl_DISABLE_THREADS
+# The test suite needs to know if we have a working perl.
+# FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
+# with an ACTION-IF-NOT-FOUND argument ...
+cu_have_perl=yes
+case $PERL in *"/missing "*) cu_have_perl=no;; esac
+AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
+
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
# ------------------------------------------------
# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
diff --git a/testsuite/Coreutils.pm b/testsuite/Coreutils.pm
new file mode 100644
index 0000000..d7b644e
--- /dev/null
+++ b/testsuite/Coreutils.pm
@@ -0,0 +1,620 @@
+package Coreutils;
+# This is a testing framework.
+
+# Copyright (C) 1998-2015, 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT);
+
+use FileHandle;
+use File::Compare qw(compare);
+
address@hidden = qw(Exporter);
+($VERSION = '$Revision: 1.5 $ ') =~ tr/[0-9].//cd;
address@hidden = qw (run_tests triple_test getlimits);
+
+my $debug = $ENV{DEBUG};
+
+my @Types = qw (IN IN_PIPE OUT ERR AUX CMP EXIT PRE POST OUT_SUBST
+ ERR_SUBST ENV ENV_DEL);
+my %Types = map {$_ => 1} @Types;
+my %Zero_one_type = map {$_ => 1}
+ qw (OUT ERR EXIT PRE POST OUT_SUBST ERR_SUBST ENV);
+my $srcdir = "$ENV{srcdir}";
+my $Global_count = 1;
+
+# When running in a DJGPP environment, make $ENV{SHELL} point to bash.
+# Otherwise, a bad shell might be used (e.g. command.com) and many
+# tests would fail.
+defined $ENV{DJDIR}
+ and $ENV{SHELL} = "$ENV{DJDIR}/bin/bash.exe";
+
+# A file spec: a scalar or a reference to a single-keyed hash
+# ================
+# 'contents' contents only (file name is derived from test name)
+# {filename => 'contents'} filename and contents
+# {filename => undef} filename only -- $(srcdir)/tests/filename must exist
+#
+# FIXME: If there is more than one input file, then you can't specify 'REDIR'.
+# PIPE is still ok.
+#
+# I/O spec: a hash ref with the following properties
+# ================
+# - one key/value pair
+# - the key must be one of these strings: IN, OUT, ERR, AUX, CMP, EXIT
+# - the value must be a file spec
+# {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
+# {OUT => {'filename'=>undef}} compare contents of existing filename to
+# stdout from cmd
+# {OUT => {'filename'=>[$CTOR, $DTOR]}} $CTOR and $DTOR are references to
+# functions, each which is passed the single argument 'filename'.
+# $CTOR must create 'filename'.
+# DTOR may be omitted in which case 'sub{unlink @_[0]}' is used.
+# FIXME: implement this
+# {ERR => ...}
+# Same as for OUT, but compare with stderr, not stdout.
+# {OUT_SUBST => 's/variable_output/expected_output/'}
+# Transform actual standard output before comparing it against expected.
+# This is useful e.g. for programs like du that produce output that
+# varies a lot from system. E.g., an empty file may consume zero file
+# blocks, or more, depending on the OS and on the file system type.
+# {ERR_SUBST => 's/variable_output/expected_output/'}
+# Transform actual stderr output before comparing it against expected.
+# This is useful when verifying that we get a meaningful diagnostic.
+# For example, in rm/fail-2eperm, we have to account for three different
+# diagnostics: Operation not permitted, Not owner, and Permission denied.
+# {EXIT => N} expect exit status of cmd to be N
+# {ENV => 'VAR=val ...'}
+# Prepend 'VAR=val ...' to the command that we execute via 'system'.
+# {ENV_DEL => 'VAR'}
+# Remove VAR from the environment just before running the corresponding
+# command, and restore any value just afterwards.
+#
+# There may be many input file specs. File names from the input specs
+# are concatenated in order on the command line.
+# There may be at most one of the OUT-, ERR-, and EXIT-keyed specs.
+# If the OUT-(or ERR)-keyed hash ref is omitted, then expect no output
+# on stdout (or stderr).
+# If the EXIT-keyed one is omitted, then expect the exit status to be zero.
+
+# FIXME: Make sure that no junkfile is also listed as a
+# non-junkfile (i.e., with undef for contents)
+
+sub _shell_quote ($)
+{
+ my ($string) = @_;
+ $string =~ s/\'/\'\\\'\'/g;
+ return "'$string'";
+}
+
+sub _create_file ($$$$)
+{
+ my ($program_name, $test_name, $file_name, $data) = @_;
+ my $file;
+ if (defined $file_name)
+ {
+ $file = $file_name;
+ }
+ else
+ {
+ $file = "$test_name.$Global_count";
+ ++$Global_count;
+ }
+
+ warn "creating file '$file' with contents '$data'\n" if $debug;
+
+ # The test spec gave a string.
+ # Write it to a temp file and return tempfile name.
+ my $fh = new FileHandle "> $file";
+ die "$program_name: $file: $!\n" if ! $fh;
+ print $fh $data;
+ $fh->close || die "$program_name: $file: $!\n";
+
+ return $file;
+}
+
+sub _compare_files ($$$$$)
+{
+ my ($program_name, $test_name, $in_or_out, $actual, $expected) = @_;
+
+ my $differ = compare ($actual, $expected);
+ if ($differ)
+ {
+ my $info = (defined $in_or_out ? "std$in_or_out " : '');
+ warn "$program_name: test $test_name: ${info}mismatch, comparing "
+ . "$expected (expected) and $actual (actual)\n";
+ # Ignore any failure, discard stderr.
+ system "diff -c $expected $actual 2>/dev/null";
+ }
+
+ return $differ;
+}
+
+sub _process_file_spec ($$$$$)
+{
+ my ($program_name, $test_name, $file_spec, $type, $junk_files) = @_;
+
+ my ($file_name, $contents);
+ if (!ref $file_spec)
+ {
+ ($file_name, $contents) = (undef, $file_spec);
+ }
+ elsif (ref $file_spec eq 'HASH')
+ {
+ my $n = keys %$file_spec;
+ die "$program_name: $test_name: $type spec has $n elements --"
+ . " expected 1\n"
+ if $n != 1;
+ ($file_name, $contents) = each %$file_spec;
+
+ # This happens for the AUX hash in an io_spec like this:
+ # {CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
+ defined $contents
+ or return $file_name;
+ }
+ else
+ {
+ die "$program_name: $test_name: invalid RHS in $type-spec\n"
+ }
+
+ my $is_junk_file = (! defined $file_name
+ || (($type eq 'IN' || $type eq 'AUX' || $type eq 'CMP')
+ && defined $contents));
+ my $file = _create_file ($program_name, $test_name,
+ $file_name, $contents);
+
+ if ($is_junk_file)
+ {
+ push @$junk_files, $file
+ }
+ else
+ {
+ # FIXME: put $srcdir in here somewhere
+ warn "$program_name: $test_name: specified file '$file' does"
+ . " not exist\n"
+ if ! -f "$srcdir/tests/$file";
+ }
+
+ return $file;
+}
+
+sub _at_replace ($$)
+{
+ my ($map, $s) = @_;
+ foreach my $eo (qw (AUX OUT ERR))
+ {
+ my $f = $map->{$eo};
+ $f
+ and $s =~ /address@hidden@/
+ and $s =~ s/address@hidden@/$f/g;
+ }
+ return $s;
+}
+
+sub getlimits()
+{
+ my $NV;
+ open $NV, "getlimits |" or die "Error running getlimits\n";
+ my %limits = map {split /=|\n/} <$NV>;
+ return \%limits;
+}
+
+# FIXME: cleanup on interrupt
+# FIXME: extract 'do_1_test' function
+
+# FIXME: having to include $program_name here is an expedient kludge.
+# Library code doesn't 'die'.
+sub run_tests ($$$$$)
+{
+ my ($program_name, $prog, $t_spec, $save_temps, $verbose) = @_;
+
+ # To indicate that $prog is a shell built-in, you'd make it a string 'ref'.
+ # E.g., call run_tests ($prog, \$prog, address@hidden, $save_temps, $verbose);
+ # If it's a ref, invoke it via "env":
+ my @prog = ref $prog ? (qw(env --), $$prog) : $prog;
+
+ # Warn about empty t_spec.
+ # FIXME
+
+ # Remove all temp files upon interrupt.
+ # FIXME
+
+ # Verify that test names are distinct.
+ my $bad_test_name = 0;
+ my %seen;
+ my %seen_8dot3;
+ my $t;
+ foreach $t (@$t_spec)
+ {
+ my $test_name = $t->[0];
+ if ($seen{$test_name})
+ {
+ warn "$program_name: $test_name: duplicate test name\n";
+ $bad_test_name = 1;
+ }
+ $seen{$test_name} = 1;
+
+ if (0)
+ {
+ my $t8 = lc substr $test_name, 0, 8;
+ if ($seen_8dot3{$t8})
+ {
+ warn "$program_name: 8.3 test name conflict: "
+ . "$test_name, $seen_8dot3{$t8}\n";
+ $bad_test_name = 1;
+ }
+ $seen_8dot3{$t8} = $test_name;
+ }
+
+ # The test name may be no longer than 30 bytes.
+ # Yes, this is an arbitrary limit. If it causes trouble,
+ # consider removing it.
+ my $max = 30;
+ if ($max < length $test_name)
+ {
+ warn "$program_name: $test_name: test name is too long (> $max)\n";
+ $bad_test_name = 1;
+ }
+ }
+ return 1 if $bad_test_name;
+
+ # FIXME check exit status
+ system (@prog, '--version') if $verbose;
+
+ my @junk_files;
+ my $fail = 0;
+ foreach my $tt (@$t_spec)
+ {
+ my @post_compare;
+ my @dummy = @$tt;
+ my $t = address@hidden;
+ my $test_name = shift @$t;
+ my $expect = {};
+ my ($pre, $post);
+
+ # FIXME: maybe don't reset this.
+ $Global_count = 1;
+ my @args;
+ my $io_spec;
+ my %seen_type;
+ my @env_delete;
+ my $env_prefix = '';
+ my $input_pipe_cmd;
+ foreach $io_spec (@$t)
+ {
+ if (!ref $io_spec)
+ {
+ push @args, $io_spec;
+ next;
+ }
+
+ if (ref $io_spec ne 'HASH')
+ {
+ eval 'use Data::Dumper';
+ die "$program_name: $test_name: invalid entry in test spec; "
+ . "expected HASH-ref,\nbut got this:\n"
+ . Data::Dumper->Dump ([\$io_spec], ['$io_spec']) . "\n";
+ }
+
+ my $n = keys %$io_spec;
+ die "$program_name: $test_name: spec has $n elements --"
+ . " expected 1\n"
+ if $n != 1;
+ my ($type, $val) = each %$io_spec;
+ die "$program_name: $test_name: invalid key '$type' in test spec\n"
+ if ! $Types{$type};
+
+ # Make sure there's no more than one of OUT, ERR, EXIT, etc.
+ die "$program_name: $test_name: more than one $type spec\n"
+ if $Zero_one_type{$type} and $seen_type{$type}++;
+
+ if ($type eq 'PRE' or $type eq 'POST')
+ {
+ $expect->{$type} = $val;
+ next;
+ }
+
+ if ($type eq 'CMP')
+ {
+ my $t = ref $val;
+ $t && $t eq 'ARRAY'
+ or die "$program_name: $test_name: invalid CMP spec\n";
+ @$val == 2
+ or die "$program_name: $test_name: invalid CMP list; must have"
+ . " exactly 2 elements\n";
+ my @cmp_files;
+ foreach my $e (@$val)
+ {
+ my $r = ref $e;
+ $r && $r ne 'HASH'
+ and die "$program_name: $test_name: invalid element ($r)"
+ . " in CMP list; only scalars and hash references "
+ . "are allowed\n";
+ if ($r && $r eq 'HASH')
+ {
+ my $n = keys %$e;
+ $n == 1
+ or die "$program_name: $test_name: CMP spec has $n "
+ . "elements -- expected 1\n";
+
+ # Replace any '@AUX@' in the key of %$e.
+ my ($ff, $val) = each %$e;
+ my $new_ff = _at_replace $expect, $ff;
+ if ($new_ff ne $ff)
+ {
+ $e->{$new_ff} = $val;
+ delete $e->{$ff};
+ }
+ }
+ my $cmp_file = _process_file_spec ($program_name, $test_name,
+ $e, $type, address@hidden);
+ push @cmp_files, $cmp_file;
+ }
+ push @post_compare, address@hidden;
+
+ $expect->{$type} = $val;
+ next;
+ }
+
+ if ($type eq 'EXIT')
+ {
+ die "$program_name: $test_name: invalid EXIT code\n"
+ if $val !~ /^\d+$/;
+ # FIXME: make sure $data is numeric
+ $expect->{EXIT} = $val;
+ next;
+ }
+
+ if ($type =~ /^(OUT|ERR)_SUBST$/)
+ {
+ $expect->{RESULT_SUBST} ||= {};
+ $expect->{RESULT_SUBST}->{$1} = $val;
+ next;
+ }
+
+ if ($type eq 'ENV')
+ {
+ $env_prefix = "$val ";
+ next;
+ }
+
+ if ($type eq 'ENV_DEL')
+ {
+ push @env_delete, $val;
+ next;
+ }
+
+ my $file = _process_file_spec ($program_name, $test_name, $val,
+ $type, address@hidden);
+
+ if ($type eq 'IN' || $type eq 'IN_PIPE')
+ {
+ my $quoted_file = _shell_quote $file;
+ if ($type eq 'IN_PIPE')
+ {
+ defined $input_pipe_cmd
+ and die "$program_name: $test_name: only one input"
+ . " may be specified with IN_PIPE\n";
+ $input_pipe_cmd = "cat $quoted_file |";
+ }
+ else
+ {
+ push @args, $quoted_file;
+ }
+ }
+ elsif ($type eq 'AUX' || $type eq 'OUT' || $type eq 'ERR')
+ {
+ $expect->{$type} = $file;
+ }
+ else
+ {
+ die "$program_name: $test_name: invalid type: $type\n"
+ }
+ }
+
+ # Expect an exit status of zero if it's not specified.
+ $expect->{EXIT} ||= 0;
+
+ # Allow ERR to be omitted -- in that case, expect no error output.
+ foreach my $eo (qw (OUT ERR))
+ {
+ if (!exists $expect->{$eo})
+ {
+ $expect->{$eo} = _create_file ($program_name, $test_name,
+ undef, '');
+ push @junk_files, $expect->{$eo};
+ }
+ }
+
+ # FIXME: Does it ever make sense to specify a filename *and* contents
+ # in OUT or ERR spec?
+
+ # FIXME: this is really suboptimal...
+ my @new_args;
+ foreach my $a (@args)
+ {
+ $a = _at_replace $expect, $a;
+ push @new_args, $a;
+ }
+ @args = @new_args;
+
+ warn "$test_name...\n" if $verbose;
+ &{$expect->{PRE}} if $expect->{PRE};
+ my %actual;
+ $actual{OUT} = "$test_name.O";
+ $actual{ERR} = "$test_name.E";
+ push @junk_files, $actual{OUT}, $actual{ERR};
+ my @cmd = (@prog, @args, "> $actual{OUT}", "2> $actual{ERR}");
+ $env_prefix
+ and unshift @cmd, $env_prefix;
+ defined $input_pipe_cmd
+ and unshift @cmd, $input_pipe_cmd;
+ my $cmd_str = join (' ', @cmd);
+
+ # Delete from the environment any symbols specified by syntax
+ # like this: {ENV_DEL => 'TZ'}.
+ my %pushed_env;
+ foreach my $env_sym (@env_delete)
+ {
+ my $val = delete $ENV{$env_sym};
+ defined $val
+ and $pushed_env{$env_sym} = $val;
+ }
+
+ warn "Running command: '$cmd_str'\n" if $debug;
+ my $rc = 0xffff & system $cmd_str;
+
+ # Restore any environment setting we changed via a deletion.
+ foreach my $env_sym (keys %pushed_env)
+ {
+ $ENV{$env_sym} = $pushed_env{$env_sym};
+ }
+
+ if ($rc == 0xff00)
+ {
+ warn "$program_name: test $test_name failed: command failed:\n"
+ . " '$cmd_str': $!\n";
+ $fail = 1;
+ goto cleanup;
+ }
+ $rc >>= 8 if $rc > 0x80;
+ if ($expect->{EXIT} != $rc)
+ {
+ warn "$program_name: test $test_name failed: exit status mismatch:"
+ . " expected $expect->{EXIT}, got $rc\n";
+ $fail = 1;
+ goto cleanup;
+ }
+
+ my %actual_data;
+ # Record actual stdout and stderr contents, if POST may need them.
+ if ($expect->{POST})
+ {
+ foreach my $eo (qw (OUT ERR))
+ {
+ my $out_file = $actual{$eo};
+ open IN, $out_file
+ or (warn
+ "$program_name: cannot open $out_file for reading: $!\n"),
+ $fail = 1, next;
+ $actual_data{$eo} = ;
+ close IN
+ or (warn "$program_name: failed to read $out_file: $!\n"),
+ $fail = 1;
+ }
+ }
+
+ foreach my $eo (qw (OUT ERR))
+ {
+ my $subst_expr = $expect->{RESULT_SUBST}->{$eo};
+ if (defined $subst_expr)
+ {
+ my $out = $actual{$eo};
+ my $orig = "$out.orig";
+
+ # Move $out aside (to $orig), then recreate $out
+ # by transforming each line of $orig via $subst_expr.
+ rename $out, $orig
+ or (warn "$program_name: cannot rename $out to $orig: $!\n"),
+ $fail = 1, next;
+ open IN, $orig
+ or (warn "$program_name: cannot open $orig for reading: $!\n"),
+ $fail = 1, (unlink $orig), next;
+ unlink $orig
+ or (warn "$program_name: cannot unlink $orig: $!\n"),
+ $fail = 1;
+ open OUT, ">$out"
+ or (warn "$program_name: cannot open $out for writing: $!\n"),
+ $fail = 1, next;
+ while (defined (my $line = ))
+ {
+ eval "\$_ = \$line; $subst_expr; \$line = \$_";
+ print OUT $line;
+ }
+ close IN;
+ close OUT
+ or (warn "$program_name: failed to write $out: $!\n"),
+ $fail = 1, next;
+ }
+
+ my $eo_lower = lc $eo;
+ _compare_files ($program_name, $test_name, $eo_lower,
+ $actual{$eo}, $expect->{$eo})
+ and $fail = 1;
+ }
+
+ foreach my $pair (@post_compare)
+ {
+ my ($expected, $actual) = @$pair;
+ _compare_files $program_name, $test_name, undef, $actual, $expected
+ and $fail = 1;
+ }
+
+ cleanup:
+ $expect->{POST}
+ and &{$expect->{POST}} ($actual_data{OUT}, $actual_data{ERR});
+
+ }
+
+ # FIXME: maybe unlink files inside the big foreach loop?
+ unlink @junk_files if ! $save_temps;
+
+ return $fail;
+}
+
+# For each test in @$TESTS, generate two additional tests,
+# one using stdin, the other using a pipe. I.e., given this one
+# ['idem-0', {IN=>''}, {OUT=>''}],
+# generate these:
+# ['idem-0.r', '<', {IN=>''}, {OUT=>''}],
+# ['idem-0.p', {IN_PIPE=>''}, {OUT=>''}],
+# Generate new tests only if there is exactly one input spec.
+# The returned list of tests contains each input test, followed
+# by zero or two derived tests.
+sub triple_test($)
+{
+ my ($tests) = @_;
+ my @new;
+ foreach my $t (@$tests)
+ {
+ push @new, $t;
+
+ my @in;
+ my @args;
+ my @list_of_hash;
+ foreach my $e (@$t)
+ {
+ !ref $e
+ and push (@args, $e), next;
+
+ ref $e && ref $e eq 'HASH'
+ or (warn "$0: $t->[0]: unexpected entry type\n"), next;
+ defined $e->{IN}
+ and (push @in, $e->{IN}), next;
+ push @list_of_hash, $e;
+ }
+ # Add variants IFF there is exactly one input file.
+ @in == 1
+ or next;
+ shift @args; # discard test name
+ push @new, ["$t->[0].r", @args, '<', {IN => $in[0]}, @list_of_hash];
+ push @new, ["$t->[0].p", @args, {IN_PIPE => $in[0]}, @list_of_hash];
+ }
+ return @new;
+}
+
+## package return
+1;
diff --git a/testsuite/CuSkip.pm b/testsuite/CuSkip.pm
new file mode 100644
index 0000000..f2e306b
--- /dev/null
+++ b/testsuite/CuSkip.pm
@@ -0,0 +1,39 @@
+package CuSkip;
+# Skip a test: emit diag to log and to stderr, and exit 77
+
+# Copyright (C) 2011-2015, 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+use strict;
+use warnings;
+
+our $ME = $0 || "??>";
+
+# Emit a diagnostic both to stderr and to $stderr_fileno_.
+# FIXME: don't hard-code that value (9), since it's already defined in init.cfg.
+sub skip ($)
+{
+ my ($msg) = @_;
+ my $stderr_fileno_ = 9;
+ warn $msg;
+ open FH, ">&$stderr_fileno_"
+ or warn "$ME: failed to dup stderr\n";
+ print FH $msg;
+ close FH
+ or warn "$ME: failed to close FD $stderr_fileno_\n";
+ exit 77;
+}
+
+1;
diff --git a/testsuite/CuTmpdir.pm b/testsuite/CuTmpdir.pm
new file mode 100644
index 0000000..a9e2a4e
--- /dev/null
+++ b/testsuite/CuTmpdir.pm
@@ -0,0 +1,111 @@
+package CuTmpdir;
+# create, then chdir into a temporary sub-directory
+
+# Copyright (C) 2007-2015, 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+use strict;
+use warnings;
+
+use File::Temp;
+use File::Find;
+
+our $ME = $0 || "??>";
+
+my $dir;
+
+sub skip_test($)
+{
+ warn "$ME: skipping test: unsafe working directory name: '$_[0]'\n";
+ exit 77;
+}
+
+sub chmod_1
+{
+ my $name = $_;
+
+ # Skip symlinks and non-directories.
+ -l $name || !-d _
+ and return;
+
+ chmod 0700, $name;
+}
+
+sub chmod_tree
+{
+ # When tempdir fails, it croaks, which leaves $dir undefined.
+ defined $dir
+ or return;
+
+ # Perform the equivalent of find "$dir" -type d -print0|xargs -0 chmod -R 700.
+ my $options = {untaint => 1, wanted => \&chmod_1};
+ find ($options, $dir);
+}
+
+sub import {
+ my $prefix = $_[1];
+
+ $ME eq '-' && defined $prefix
+ and $ME = $prefix;
+
+ if ($prefix !~ /^\//)
+ {
+ eval 'use Cwd';
+ my $cwd = $@ ? '.' : Cwd::getcwd();
+ $prefix = "$cwd/$prefix";
+ }
+
+ # Untaint for the upcoming mkdir.
+ $prefix =~ m!^(address@hidden/]+)$!
+ or skip_test $prefix;
+ $prefix = $1;
+
+ my $original_pid = $$;
+
+ my $on_sig_remove_tmpdir = sub {
+ my ($sig) = @_;
+ if ($$ == $original_pid and defined $dir)
+ {
+ chmod_tree;
+ # Older versions of File::Temp lack this method.
+ exists &File::Temp::cleanup
+ and &File::Temp::cleanup;
+ }
+ $SIG{$sig} = 'DEFAULT';
+ kill $sig, $$;
+ };
+
+ foreach my $sig (qw (INT TERM HUP))
+ {
+ $SIG{$sig} = $on_sig_remove_tmpdir;
+ }
+
+ $dir = File::Temp::tempdir("$prefix.tmp-XXXX", CLEANUP => 1 );
+ chdir $dir
+ or warn "$ME: failed to chdir to $dir: $!\n";
+}
+
+END {
+ # Move cwd out of the directory we're about to remove.
+ # This is required on some systems, and by some versions of File::Temp.
+ chdir '..'
+ or warn "$ME: failed to chdir to .. from $dir: $!\n";
+
+ my $saved_errno = $?;
+ chmod_tree;
+ $? = $saved_errno;
+}
+
+1;
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 732c86d..5eb1f7f 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -15,8 +15,25 @@
CLEANFILES += tmp* core *.core $(EXTRA_PROGRAMS) *.*out *.log eval.in2
-TEST_EXTENSIONS = .sh
+TEST_EXTENSIONS = .sh .pl
+
+if HAVE_PERL
+TESTSUITE_PERL = $(PERL)
+else
+TESTSUITE_PERL = $(SHELL) $(srcdir)/no-perl
+endif
+
+# Options passed to the perl invocations running the perl test scripts.
+TESTSUITE_PERL_OPTIONS = -w -I$(srcdir)/testsuite -MCuSkip -MCoreutils
+# '$f' is set by the Automake-generated test harness to the path of the
+# current test script stripped of VPATH components, and is used by the
+# CuTmpdir module to determine the name of the temporary files to be
+# used. Note that $f is a shell variable, not a make macro, so the use
+# of '$$f' below is correct, and not a typo.
+TESTSUITE_PERL_OPTIONS += -M"CuTmpdir qw($$f)"
+
SH_LOG_COMPILER = $(SHELL)
+PL_LOG_COMPILER = $(TESTSUITE_PERL) $(TESTSUITE_PERL_OPTIONS)
# Put new, init.sh-using tests here, so that each name
# is listed in only one place.
@@ -166,9 +183,11 @@ TESTS_ENVIRONMENT = \
LOG_COMPILER = $(top_srcdir)/testsuite/runtest
-
EXTRA_DIST += \
$(T) \
+ testsuite/Coreutils.pm \
+ testsuite/CuSkip.pm \
+ testsuite/CuTmpdir.pm \
testsuite/init.sh init.cfg \
testsuite/envvar-check \
testsuite/PCRE.tests testsuite/BOOST.tests testsuite/SPENCER.tests \
--
2.9.3
From 36c3b6366a2679c52a4111dafd51f11bc9310ca7 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Sun, 22 Jan 2017 20:10:07 -0800
Subject: [PATCH 02/12] maint: ignore more
* .gitignore: Ignore a bunch of doc/*.* texinfo artifacts and sort.
---
.gitignore | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7962434..c411f8c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,9 @@
*/.deps/
**~
+*
+*.gcda
+*.gcno
+.dirstamp
/gnulib-tests/*
!/gnulib-tests/Makefile.am
/.version
@@ -31,14 +34,28 @@
/config.status
/config_h.in
/configure
+/doc/.dirstamp
/doc/.gitignore
/doc/Makefile
+/doc/coverage/
/doc/sed.1
+/doc/sed.aux
+/doc/sed.cp
+/doc/sed.cps
+/doc/sed.fn
+/doc/sed.fns
/doc/sed.info
+/doc/sed.ky
+/doc/sed.log
+/doc/sed.op
+/doc/sed.pdf
+/doc/sed.pg
+/doc/sed.toc
+/doc/sed.tp
+/doc/sed.vr
/doc/stamp-vti
-/doc/.dirstamp
/doc/version.texi
-/doc/coverage/
+/lib/.dirstamp
/lib/Makefile
/lib/arg-nonnull.h
/lib/c++defs.h
@@ -48,7 +65,6 @@
/lib/selinux/
/lib/unused-parameter.h
/lib/warn-on-use.h
-/lib/.dirstamp
/m4
/maint.mk
/po/Makefile
@@ -58,21 +74,18 @@
/po/stamp-po
/sed-*.tar.xz
/sed-[4-9]*
+/sed/.dirstamp
/sed/Makefile
/sed/sed
/sed/version.[ch]
-/sed/.dirstamp
/stamp-h1
/testsuite/*.log
/testsuite/*.trs
/testsuite/Makefile
/testsuite/eval.in2
-/testsuite/utf8-[1-4].out
-/testsuite/test-mbrtowc
/testsuite/get-mb-cur-max
-test-suite.log
+/testsuite/test-mbrtowc
+/testsuite/utf8-[1-4].out
Makefile
Makefile.in
-.dirstamp
-*.gcda
-*.gcno
+test-suite.log
--
2.9.3
From 7cd2b9761913d071f0ff37a03ca985d7989488d3 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Sun, 22 Jan 2017 20:44:21 -0800
Subject: [PATCH 03/12] tests: begin migrating test triples into perl framework
* testsuite/head.good: Delete file.
* testsuite/head.inp: Likewise.
* testsuite/head.sed: Likewise.
* testsuite/space.good: Likewise
* testsuite/space.inp: Likewise.
* testsuite/space.sed: Likewise.
* testsuite/empty.good: Likewise
* testsuite/empty.inp: Likewise.
* testsuite/empty.sed: Likewise.
* testsuite/zero-anchor.good: Likewise
* testsuite/zero-anchor.inp: Likewise.
* testsuite/zero-anchor.sed: Likewise.
* testsuite/misc.pl: New file, subsuming the above, with one test
for each of the test file triples (input, output, sed commands).
(empty, empty2, head, space, zero-anchor): Converted tests.
* testsuite/local.mk: Remove references to deleted files.
(T): Add misc.pl.
---
testsuite/empty.good | 2 --
testsuite/empty.inp | 2 --
testsuite/empty.sed | 1 -
testsuite/head.good | 3 ---
testsuite/head.inp | 9 ---------
testsuite/head.sed | 1 -
testsuite/local.mk | 23 +++++-----------------
testsuite/misc.pl | 47 +++++++++++++++++++++++++++++++++++++++++++++
testsuite/space.good | 2 --
testsuite/space.inp | 2 --
testsuite/space.sed | 1 -
testsuite/zero-anchor.good | Bin 14 -> 0 bytes
testsuite/zero-anchor.inp | Bin 6 -> 0 bytes
testsuite/zero-anchor.sed | 6 ------
14 files changed, 52 insertions(+), 47 deletions(-)
delete mode 100644 testsuite/empty.good
delete mode 100644 testsuite/empty.inp
delete mode 100644 testsuite/empty.sed
delete mode 100644 testsuite/head.good
delete mode 100644 testsuite/head.inp
delete mode 100644 testsuite/head.sed
create mode 100644 testsuite/misc.pl
delete mode 100644 testsuite/space.good
delete mode 100644 testsuite/space.inp
delete mode 100644 testsuite/space.sed
delete mode 100644 testsuite/zero-anchor.good
delete mode 100644 testsuite/zero-anchor.inp
delete mode 100644 testsuite/zero-anchor.sed
diff --git a/testsuite/empty.good b/testsuite/empty.good
deleted file mode 100644
index 07e1a15..0000000
--- a/testsuite/empty.good
+++ /dev/null
@@ -1,2 +0,0 @@
-x
-
diff --git a/testsuite/empty.inp b/testsuite/empty.inp
deleted file mode 100644
index 07e1a15..0000000
--- a/testsuite/empty.inp
+++ /dev/null
@@ -1,2 +0,0 @@
-x
-
diff --git a/testsuite/empty.sed b/testsuite/empty.sed
deleted file mode 100644
index b35aed6..0000000
--- a/testsuite/empty.sed
+++ /dev/null
@@ -1 +0,0 @@
-s/^ *//
diff --git a/testsuite/head.good b/testsuite/head.good
deleted file mode 100644
index 6392831..0000000
--- a/testsuite/head.good
+++ /dev/null
@@ -1,3 +0,0 @@
- "...by imposing a tiny bit of order in a communication you are
- translating, you are carving out a little bit of order in the
- universe. You will never succeed. Everything will fail and come
diff --git a/testsuite/head.inp b/testsuite/head.inp
deleted file mode 100644
index 5c4b4a4..0000000
--- a/testsuite/head.inp
+++ /dev/null
@@ -1,9 +0,0 @@
- "...by imposing a tiny bit of order in a communication you are
- translating, you are carving out a little bit of order in the
- universe. You will never succeed. Everything will fail and come
- to an end finally. But you have a chance to carve a little bit
- of order and maybe even beauty out of the raw materials that
- surround you everywhere, and I think there is no greater meaning
- in life."
-
- Donald L. Philippi, Oct 1930 - Jan 1993
diff --git a/testsuite/head.sed b/testsuite/head.sed
deleted file mode 100644
index d8ea37d..0000000
--- a/testsuite/head.sed
+++ /dev/null
@@ -1 +0,0 @@
-3q
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 5eb1f7f..c295c7b 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -39,6 +39,7 @@ PL_LOG_COMPILER = $(TESTSUITE_PERL) $(TESTSUITE_PERL_OPTIONS)
# is listed in only one place.
T = \
+ testsuite/misc.pl \
testsuite/cmd-l.sh \
testsuite/cmd-R.sh \
testsuite/colon-with-no-label.sh \
@@ -102,8 +103,6 @@ check_PROGRAMS += testsuite/bug-regex7 \
testsuite/bug-regex21 testsuite/bug-regex27 testsuite/bug-regex28 \
testsuite/tst-pcre testsuite/tst-boost testsuite/runtests \
testsuite/runptests testsuite/tst-rxspencer testsuite/tst-regex2
-
-SEDTESTS += space
endif
SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
@@ -112,8 +111,8 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/noeolw testsuite/modulo testsuite/numsub \
testsuite/numsub2 testsuite/numsub3 testsuite/numsub4 \
testsuite/numsub5 testsuite/0range testsuite/bkslashes \
- testsuite/head testsuite/madding testsuite/mac-mf \
- testsuite/empty testsuite/xbxcx testsuite/xbxcx3 \
+ testsuite/madding testsuite/mac-mf \
+ testsuite/xbxcx testsuite/xbxcx3 \
testsuite/recall testsuite/recall2 testsuite/xemacs \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
@@ -128,7 +127,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/amp-escape testsuite/help testsuite/file \
testsuite/quiet testsuite/factor testsuite/binary3 \
testsuite/binary2 testsuite/binary testsuite/dc \
- testsuite/newline-anchor testsuite/zero-anchor
+ testsuite/newline-anchor
# Note that the first lines are statements. They ensure that environment
# variables that can perturb tests are unset or set to expected values.
@@ -239,9 +238,6 @@ EXTRA_DIST += \
testsuite/dollar.good \
testsuite/dollar.inp \
testsuite/dollar.sed \
- testsuite/empty.good \
- testsuite/empty.inp \
- testsuite/empty.sed \
testsuite/enable.good \
testsuite/enable.inp \
testsuite/enable.sed \
@@ -257,9 +253,6 @@ EXTRA_DIST += \
testsuite/flipcase.good \
testsuite/flipcase.inp \
testsuite/flipcase.sed \
- testsuite/head.good \
- testsuite/head.inp \
- testsuite/head.sed \
testsuite/inclib.good \
testsuite/inclib.inp \
testsuite/inclib.sed \
@@ -275,9 +268,6 @@ EXTRA_DIST += \
testsuite/linecnt.good \
testsuite/linecnt.inp \
testsuite/linecnt.sed \
- testsuite/space.good \
- testsuite/space.inp \
- testsuite/space.sed \
testsuite/mac-mf.good \
testsuite/mac-mf.inp \
testsuite/mac-mf.sed \
@@ -379,10 +369,7 @@ EXTRA_DIST += \
testsuite/y-zero.inp \
testsuite/y-newline.good \
testsuite/y-newline.sed \
- testsuite/y-newline.inp \
- testsuite/zero-anchor.good \
- testsuite/zero-anchor.sed \
- testsuite/zero-anchor.inp
+ testsuite/y-newline.inp
# automake makes `check' depend on $(TESTS). Declare
# dummy targets for $(TESTS) so that make does not complain.
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
new file mode 100644
index 0000000..a7ca6bb
--- /dev/null
+++ b/testsuite/misc.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+# Test misc.
+
+# Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+use strict;
+use File::stat;
+
+(my $program_name = $0) =~ s|.*/||;
+
+# Turn off localization of executable's output.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $prog = 'sed';
+
+my @Tests =
+ (
+ ['empty', {IN=>''}, {OUT=>''}],
+ ['empty2', q('s/^ *//'), {IN=>"x\n\n"}, {OUT=>"x\n\n"}],
+
+ ['head', qw(3q), {IN=>"1\n2\n3\n4\n"}, {OUT=>"1\n2\n3\n"}],
+ ['space', q('s/_\S/XX/g;s/\s/_/g'),
+ {IN=> "Hello World\t!\nSecond_line_ of tests\n" },
+ {OUT=> "Hello_World_!\nSecondXXine__of_tests\n" }],
+ ['zero-anchor', qw(-z), q('N;N;s/^/X/g;s/^/X/mg;s/$/Y/g;s/$/Y/mg'),
+ {IN=>"a\0b\0c\0" },
+ {OUT=>"XXaY\0XbY\0XcYY\0" }],
+ );
+
+my $save_temps = $ENV{SAVE_TEMPS};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, address@hidden, $save_temps, $verbose);
+exit $fail;
diff --git a/testsuite/space.good b/testsuite/space.good
deleted file mode 100644
index 9b267aa..0000000
--- a/testsuite/space.good
+++ /dev/null
@@ -1,2 +0,0 @@
-Hello_World_!
-SecondXXine__of_tests
diff --git a/testsuite/space.inp b/testsuite/space.inp
deleted file mode 100644
index 83b0adb..0000000
--- a/testsuite/space.inp
+++ /dev/null
@@ -1,2 +0,0 @@
-Hello World !
-Second_line_ of tests
diff --git a/testsuite/space.sed b/testsuite/space.sed
deleted file mode 100644
index 0bfa522..0000000
--- a/testsuite/space.sed
+++ /dev/null
@@ -1 +0,0 @@
-s/_\S/XX/g;s/\s/_/g
diff --git a/testsuite/zero-anchor.good b/testsuite/zero-anchor.good
deleted file mode 100644
index a62d3b4e58355ea6928a5756a2d1cab928e80cae..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 14
Tcma!uNQ`8NNCM*I$VdhNA58=6
diff --git a/testsuite/zero-anchor.inp b/testsuite/zero-anchor.inp
deleted file mode 100644
index 7207ec48b9862c834457031abf3a8bffc831fb11..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 6
NcmYdfNMcB4000D<0Ve
Date: Sun, 19 Feb 2017 09:54:40 -0800
Subject: [PATCH 04/12] tests: convert "insens" to new framework
* testsuite/misc.pl (case-insensitive): New test, replacing...
* testsuite/insens.good: Delete file.
* testsuite/insens.inp: Likewise.
* testsuite/insens.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "insens".
---
testsuite/insens.good | 2 --
testsuite/insens.inp | 1 -
testsuite/insens.sed | 4 ----
testsuite/local.mk | 9 +++------
testsuite/misc.pl | 6 ++++++
5 files changed, 9 insertions(+), 13 deletions(-)
delete mode 100644 testsuite/insens.good
delete mode 100644 testsuite/insens.inp
delete mode 100644 testsuite/insens.sed
diff --git a/testsuite/insens.good b/testsuite/insens.good
deleted file mode 100644
index 6fd1bc1..0000000
--- a/testsuite/insens.good
+++ /dev/null
@@ -1,2 +0,0 @@
-1.2.3
-1.2.3
diff --git a/testsuite/insens.inp b/testsuite/insens.inp
deleted file mode 100644
index baefc12..0000000
--- a/testsuite/insens.inp
+++ /dev/null
@@ -1 +0,0 @@
-Version: 1.2.3
diff --git a/testsuite/insens.sed b/testsuite/insens.sed
deleted file mode 100644
index afab9fa..0000000
--- a/testsuite/insens.sed
+++ /dev/null
@@ -1,4 +0,0 @@
-h
-s/Version: *//p
-g
-s/version: *//Ip
diff --git a/testsuite/local.mk b/testsuite/local.mk
index c295c7b..67596b5 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -111,8 +111,8 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/noeolw testsuite/modulo testsuite/numsub \
testsuite/numsub2 testsuite/numsub3 testsuite/numsub4 \
testsuite/numsub5 testsuite/0range testsuite/bkslashes \
- testsuite/madding testsuite/mac-mf \
- testsuite/xbxcx testsuite/xbxcx3 \
+ testsuite/madding testsuite/mac-mf \
+ testsuite/xbxcx testsuite/xbxcx3 \
testsuite/recall testsuite/recall2 testsuite/xemacs \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
@@ -120,7 +120,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/y-newline testsuite/y-zero testsuite/allsub \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
- testsuite/insens testsuite/subwrite testsuite/writeout \
+ testsuite/subwrite testsuite/writeout \
testsuite/readin testsuite/insert testsuite/utf8-1 \
testsuite/utf8-2 testsuite/utf8-3 testsuite/utf8-4 \
testsuite/badenc testsuite/inplace-hold testsuite/brackets \
@@ -256,9 +256,6 @@ EXTRA_DIST += \
testsuite/inclib.good \
testsuite/inclib.inp \
testsuite/inclib.sed \
- testsuite/insens.good \
- testsuite/insens.inp \
- testsuite/insens.sed \
testsuite/insert.good \
testsuite/insert.inp \
testsuite/insert.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index a7ca6bb..360c2ab 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -35,9 +35,15 @@ my @Tests =
['space', q('s/_\S/XX/g;s/\s/_/g'),
{IN=> "Hello World\t!\nSecond_line_ of tests\n" },
{OUT=> "Hello_World_!\nSecondXXine__of_tests\n" }],
+
['zero-anchor', qw(-z), q('N;N;s/^/X/g;s/^/X/mg;s/$/Y/g;s/$/Y/mg'),
{IN=>"a\0b\0c\0" },
{OUT=>"XXaY\0XbY\0XcYY\0" }],
+
+ ['case-insensitive', qw(-n), q('h;s/Version: *//p;g;s/version: *//Ip'),
+ {IN=>"Version: 1.2.3\n" },
+ {OUT=>"1.2.3\n1.2.3\n" },
+ ],
);
my $save_temps = $ENV{SAVE_TEMPS};
--
2.9.3
From a2e0bc09bfa3572573593b6c7cba1d9d67ae9b7d Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Sun, 19 Feb 2017 13:31:18 -0800
Subject: [PATCH 05/12] tests: convert "noeol" to new framework
* testsuite/misc.pl (preserve-missing-EOL-at-EOF): New test,
replacing...
* testsuite/noeol.good: Delete file.
* testsuite/noeol.inp: Likewise.
* testsuite/noeol.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "noeol".
* testsuite/Makefile.tests (noeol): Remove target.
We also require this additional change, since the noeolw test
used the just-deleted noeol.inp input file:
* testsuite/noeolw.inp: New file, renamed from testsuite/noeol.inp.
* testsuite/Makefile.tests: Use noeolw.inp, not the other test's file.
(EXTRA_DIST): Add testsuite/noeolw.inp.
---
testsuite/Makefile.tests | 4 ++--
testsuite/local.mk | 6 ++----
testsuite/misc.pl | 5 +++++
testsuite/noeol.good | 3 ---
testsuite/noeol.sed | 1 -
testsuite/{noeol.inp => noeolw.inp} | 0
6 files changed, 9 insertions(+), 10 deletions(-)
delete mode 100644 testsuite/noeol.good
delete mode 100644 testsuite/noeol.sed
rename testsuite/{noeol.inp => noeolw.inp} (100%)
diff --git a/testsuite/Makefile.tests b/testsuite/Makefile.tests
index 00a4ec8..c4b6a72 100644
--- a/testsuite/Makefile.tests
+++ b/testsuite/Makefile.tests
@@ -19,7 +19,7 @@ elide_cr = $(SEDENV_2) $(SED) 's/\r//g'
SKIP = :>address@hidden; exit 77
-enable sep inclib 8bit 8to7 newjis xabcx dollar noeol bkslashes \
+enable sep inclib 8bit 8to7 newjis xabcx dollar bkslashes \
numsub head madding mac-mf empty xbxcx xbxcx3 recall recall2 xemacs \
appquit fasts uniq manis linecnt khadafy allsub flipcase space modulo \
y-bracket y-newline y-zero insert brackets amp-escape newline-anchor::
@@ -107,7 +107,7 @@ insens::
noeolw::
$(SEDENV) $(SED) -n -f $(srcdir)/address@hidden \
- $(srcdir)/noeol.inp $(srcdir)/noeol.inp | $(elide_cr) > address@hidden
+ $(srcdir)/address@hidden $(srcdir)/address@hidden | $(elide_cr) > address@hidden
$(CMP) $(srcdir)/address@hidden address@hidden
$(elide_cr) < address@hidden | $(CMP) $(srcdir)/address@hidden -
$(elide_cr) < address@hidden | $(CMP) $(srcdir)/address@hidden -
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 67596b5..dd6a252 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -107,7 +107,7 @@ endif
SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/inclib testsuite/8bit testsuite/newjis \
- testsuite/xabcx testsuite/dollar testsuite/noeol \
+ testsuite/xabcx testsuite/dollar \
testsuite/noeolw testsuite/modulo testsuite/numsub \
testsuite/numsub2 testsuite/numsub3 testsuite/numsub4 \
testsuite/numsub5 testsuite/0range testsuite/bkslashes \
@@ -286,10 +286,8 @@ EXTRA_DIST += \
testsuite/newline-anchor.good \
testsuite/newline-anchor.inp \
testsuite/newline-anchor.sed \
- testsuite/noeol.good \
- testsuite/noeol.inp \
- testsuite/noeol.sed \
testsuite/noeolw.good \
+ testsuite/noeolw.inp \
testsuite/noeolw.1good \
testsuite/noeolw.2good \
testsuite/noeolw.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index 360c2ab..dac0e24 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -44,6 +44,11 @@ my @Tests =
{IN=>"Version: 1.2.3\n" },
{OUT=>"1.2.3\n1.2.3\n" },
],
+
+ ['preserve-missing-EOL-at-EOF', q('s/$/x/'),
+ {IN=> "a\nb" },
+ {OUT=>"ax\nbx" },
+ ],
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/noeol.good b/testsuite/noeol.good
deleted file mode 100644
index fa5fc0e..0000000
--- a/testsuite/noeol.good
+++ /dev/null
@@ -1,3 +0,0 @@
-This file is uniquewakuwaku
-in that it doeswakuwaku
-end in a newline.wakuwaku
\ No newline at end of file
diff --git a/testsuite/noeol.sed b/testsuite/noeol.sed
deleted file mode 100644
index bea7110..0000000
--- a/testsuite/noeol.sed
+++ /dev/null
@@ -1 +0,0 @@
-s/$/wakuwaku/g
diff --git a/testsuite/noeol.inp b/testsuite/noeolw.inp
similarity index 100%
rename from testsuite/noeol.inp
rename to testsuite/noeolw.inp
--
2.9.3
From 726bc598a78f5e3083a63f77fc0718b540564f64 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Wed, 1 Mar 2017 20:54:48 -0800
Subject: [PATCH 06/12] tests: convert "y-bracket" test to new framework
* testsuite/misc.pl (Tests): Add y-bracket.
* testsuite/y-bracket.good: Delete file.
* testsuite/y-bracket.inp: Likewise.
* testsuite/y-bracket.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "y-bracket".
---
testsuite/local.mk | 5 +----
testsuite/misc.pl | 6 ++++++
testsuite/y-bracket.good | 1 -
testsuite/y-bracket.inp | 1 -
testsuite/y-bracket.sed | 1 -
5 files changed, 7 insertions(+), 7 deletions(-)
delete mode 100644 testsuite/y-bracket.good
delete mode 100644 testsuite/y-bracket.inp
delete mode 100644 testsuite/y-bracket.sed
diff --git a/testsuite/local.mk b/testsuite/local.mk
index dd6a252..4e56b61 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -116,7 +116,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/recall testsuite/recall2 testsuite/xemacs \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
- testsuite/distrib testsuite/8to7 testsuite/y-bracket \
+ testsuite/distrib testsuite/8to7 \
testsuite/y-newline testsuite/y-zero testsuite/allsub \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
@@ -356,9 +356,6 @@ EXTRA_DIST += \
testsuite/xemacs.good \
testsuite/xemacs.inp \
testsuite/xemacs.sed \
- testsuite/y-bracket.good \
- testsuite/y-bracket.sed \
- testsuite/y-bracket.inp \
testsuite/y-zero.good \
testsuite/y-zero.sed \
testsuite/y-zero.inp \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index dac0e24..47ecf45 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -49,6 +49,12 @@ my @Tests =
{IN=> "a\nb" },
{OUT=>"ax\nbx" },
],
+
+ ['y-bracket', q('y/[/ /'),
+ {IN => "Are you sure (y/n)? [y]\n" },
+ {OUT=> "Are you sure (y/n)? y]\n" },
+ ],
+
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/y-bracket.good b/testsuite/y-bracket.good
deleted file mode 100644
index 7e1a0ac..0000000
--- a/testsuite/y-bracket.good
+++ /dev/null
@@ -1 +0,0 @@
-Are you sure (y/n)? y]
diff --git a/testsuite/y-bracket.inp b/testsuite/y-bracket.inp
deleted file mode 100644
index 131c38c..0000000
--- a/testsuite/y-bracket.inp
+++ /dev/null
@@ -1 +0,0 @@
-Are you sure (y/n)? [y]
diff --git a/testsuite/y-bracket.sed b/testsuite/y-bracket.sed
deleted file mode 100644
index 79f3b61..0000000
--- a/testsuite/y-bracket.sed
+++ /dev/null
@@ -1 +0,0 @@
-y/[/ /
--
2.9.3
From c4feaf48f902b312d86cd55526787724e62c2301 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Wed, 1 Mar 2017 20:58:09 -0800
Subject: [PATCH 07/12] tests: convert "y-zero" test to new framework
* testsuite/misc.pl (Tests): Add y-zero.
* testsuite/y-zero.good: Delete file.
* testsuite/y-zero.inp: Likewise.
* testsuite/y-zero.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "y-zero".
---
testsuite/local.mk | 5 +----
testsuite/misc.pl | 5 +++++
testsuite/y-zero.good | Bin 4 -> 0 bytes
testsuite/y-zero.inp | 1 -
testsuite/y-zero.sed | 1 -
5 files changed, 6 insertions(+), 6 deletions(-)
delete mode 100644 testsuite/y-zero.good
delete mode 100644 testsuite/y-zero.inp
delete mode 100644 testsuite/y-zero.sed
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 4e56b61..7525e9d 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -117,7 +117,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
testsuite/distrib testsuite/8to7 \
- testsuite/y-newline testsuite/y-zero testsuite/allsub \
+ testsuite/y-newline testsuite/allsub \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
testsuite/subwrite testsuite/writeout \
@@ -356,9 +356,6 @@ EXTRA_DIST += \
testsuite/xemacs.good \
testsuite/xemacs.inp \
testsuite/xemacs.sed \
- testsuite/y-zero.good \
- testsuite/y-zero.sed \
- testsuite/y-zero.inp \
testsuite/y-newline.good \
testsuite/y-newline.sed \
testsuite/y-newline.inp
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index 47ecf45..b98ce4a 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -55,6 +55,11 @@ my @Tests =
{OUT=> "Are you sure (y/n)? y]\n" },
],
+ ['y-zero', q('y/b/\x00/'),
+ {IN => "abc\n" },
+ {OUT=> "a\0c\n" },
+ ],
+
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/y-zero.good b/testsuite/y-zero.good
deleted file mode 100644
index 659b72404b70ab54da8f878f31930baac622ca49..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 4
LcmYdfNag|n0$2dg
diff --git a/testsuite/y-zero.inp b/testsuite/y-zero.inp
deleted file mode 100644
index 8baef1b..0000000
--- a/testsuite/y-zero.inp
+++ /dev/null
@@ -1 +0,0 @@
-abc
diff --git a/testsuite/y-zero.sed b/testsuite/y-zero.sed
deleted file mode 100644
index 6b0af7b..0000000
--- a/testsuite/y-zero.sed
+++ /dev/null
@@ -1 +0,0 @@
-y/b/\x00/
--
2.9.3
From bf9ca8dd29c40c3dc366b8b1bd662c5bdd70c691 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Wed, 1 Mar 2017 21:05:26 -0800
Subject: [PATCH 08/12] tests: convert "y-newline" test to new framework
* testsuite/misc.pl (Tests): Add y-newline.
* testsuite/y-newline.good: Delete file.
* testsuite/y-newline.inp: Likewise.
* testsuite/y-newline.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "y-newline".
---
testsuite/local.mk | 7 ++-----
testsuite/misc.pl | 7 +++++++
testsuite/y-newline.good | 1 -
testsuite/y-newline.inp | 1 -
testsuite/y-newline.sed | 3 ---
5 files changed, 9 insertions(+), 10 deletions(-)
delete mode 100644 testsuite/y-newline.good
delete mode 100644 testsuite/y-newline.inp
delete mode 100644 testsuite/y-newline.sed
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 7525e9d..4991fb5 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -117,7 +117,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
testsuite/distrib testsuite/8to7 \
- testsuite/y-newline testsuite/allsub \
+ testsuite/allsub \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
testsuite/subwrite testsuite/writeout \
@@ -355,10 +355,7 @@ EXTRA_DIST += \
testsuite/xbxcx3.sed \
testsuite/xemacs.good \
testsuite/xemacs.inp \
- testsuite/xemacs.sed \
- testsuite/y-newline.good \
- testsuite/y-newline.sed \
- testsuite/y-newline.inp
+ testsuite/xemacs.sed
# automake makes `check' depend on $(TESTS). Declare
# dummy targets for $(TESTS) so that make does not complain.
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index b98ce4a..b33e75a 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -60,6 +60,13 @@ my @Tests =
{OUT=> "a\0c\n" },
],
+ ['y-newline', q('H
+G
+y/Ss\nYy/yY$sS/'),
+ {IN => "Are you sure (y/n)? [y]\n" },
+ {OUT=> 'Are Sou Yure (S/n)? [S]$$Are Sou Yure (S/n)? [S]'."\n"},
+ ],
+
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/y-newline.good b/testsuite/y-newline.good
deleted file mode 100644
index 371b9cb..0000000
--- a/testsuite/y-newline.good
+++ /dev/null
@@ -1 +0,0 @@
-Are Sou Yure (S/n)? [S]$$Are Sou Yure (S/n)? [S]
diff --git a/testsuite/y-newline.inp b/testsuite/y-newline.inp
deleted file mode 100644
index 131c38c..0000000
--- a/testsuite/y-newline.inp
+++ /dev/null
@@ -1 +0,0 @@
-Are you sure (y/n)? [y]
diff --git a/testsuite/y-newline.sed b/testsuite/y-newline.sed
deleted file mode 100644
index 3e1dbea..0000000
--- a/testsuite/y-newline.sed
+++ /dev/null
@@ -1,3 +0,0 @@
-H
-G
-y/Ss\nYy/yY$sS/
--
2.9.3
From d2a6e06f975b8269648b5f8a79d83032e808f49b Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Wed, 1 Mar 2017 21:18:32 -0800
Subject: [PATCH 09/12] tests: convert "allsub" test to new framework
* testsuite/misc.pl (Tests): Add allsub.
* testsuite/allsub.good: Delete file.
* testsuite/allsub.inp: Likewise.
* testsuite/allsub.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "allsub".
---
testsuite/allsub.good | 1 -
testsuite/allsub.inp | 1 -
testsuite/allsub.sed | 1 -
testsuite/local.mk | 4 ----
testsuite/misc.pl | 5 +++++
5 files changed, 5 insertions(+), 7 deletions(-)
delete mode 100644 testsuite/allsub.good
delete mode 100644 testsuite/allsub.inp
delete mode 100644 testsuite/allsub.sed
diff --git a/testsuite/allsub.good b/testsuite/allsub.good
deleted file mode 100644
index 234e159..0000000
--- a/testsuite/allsub.good
+++ /dev/null
@@ -1 +0,0 @@
-bar bar fo oo f oo bar bar bar bar bar bar bar bar bar bar bar bar bar
diff --git a/testsuite/allsub.inp b/testsuite/allsub.inp
deleted file mode 100644
index f75655f..0000000
--- a/testsuite/allsub.inp
+++ /dev/null
@@ -1 +0,0 @@
-foo foo fo oo f oo foo foo foo foo foo foo foo foo foo foo foo foo foo
diff --git a/testsuite/allsub.sed b/testsuite/allsub.sed
deleted file mode 100644
index 8aa29c1..0000000
--- a/testsuite/allsub.sed
+++ /dev/null
@@ -1 +0,0 @@
-s/foo/bar/g
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 4991fb5..b36fd40 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -117,7 +117,6 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
testsuite/distrib testsuite/8to7 \
- testsuite/allsub \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
testsuite/subwrite testsuite/writeout \
@@ -200,9 +199,6 @@ EXTRA_DIST += \
testsuite/8to7.good \
testsuite/8to7.inp \
testsuite/8to7.sed \
- testsuite/allsub.good \
- testsuite/allsub.inp \
- testsuite/allsub.sed \
testsuite/amp-escape.good \
testsuite/amp-escape.inp \
testsuite/amp-escape.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index b33e75a..c615ec9 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -67,6 +67,11 @@ y/Ss\nYy/yY$sS/'),
{OUT=> 'Are Sou Yure (S/n)? [S]$$Are Sou Yure (S/n)? [S]'."\n"},
],
+ ['allsub', q('s/foo/bar/g'),
+ {IN => "foo foo fo oo f oo foo foo foo foo foo foo foo foo foo\n"},
+ {OUT=> "bar bar fo oo f oo bar bar bar bar bar bar bar bar bar\n"},
+ ],
+
);
my $save_temps = $ENV{SAVE_TEMPS};
--
2.9.3
From 49763f1fe7f17dd4e28594370c5f0e0c8197863a Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Wed, 8 Mar 2017 07:30:42 -0800
Subject: [PATCH 10/12] tests: convert "insert" test to new framework
* testsuite/misc.pl (Tests): Add insert-nl.
* testsuite/insert.good: Delete file.
* testsuite/insert.inp: Likewise.
* testsuite/insert.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "insert".
---
testsuite/insert.good | 3 ---
testsuite/insert.inp | 2 --
testsuite/insert.sed | 1 -
testsuite/local.mk | 5 +----
testsuite/misc.pl | 5 +++++
5 files changed, 6 insertions(+), 10 deletions(-)
delete mode 100644 testsuite/insert.good
delete mode 100644 testsuite/insert.inp
delete mode 100644 testsuite/insert.sed
diff --git a/testsuite/insert.good b/testsuite/insert.good
deleted file mode 100644
index 5b6d250..0000000
--- a/testsuite/insert.good
+++ /dev/null
@@ -1,3 +0,0 @@
-bar
-
-foo
diff --git a/testsuite/insert.inp b/testsuite/insert.inp
deleted file mode 100644
index 1289765..0000000
--- a/testsuite/insert.inp
+++ /dev/null
@@ -1,2 +0,0 @@
-bar
-foo
diff --git a/testsuite/insert.sed b/testsuite/insert.sed
deleted file mode 100644
index 5f7e611..0000000
--- a/testsuite/insert.sed
+++ /dev/null
@@ -1 +0,0 @@
-/foo/i\
diff --git a/testsuite/local.mk b/testsuite/local.mk
index b36fd40..6d07488 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -120,7 +120,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/cv-vars testsuite/classes testsuite/middle \
testsuite/bsd testsuite/stdin testsuite/flipcase \
testsuite/subwrite testsuite/writeout \
- testsuite/readin testsuite/insert testsuite/utf8-1 \
+ testsuite/readin testsuite/utf8-1 \
testsuite/utf8-2 testsuite/utf8-3 testsuite/utf8-4 \
testsuite/badenc testsuite/inplace-hold testsuite/brackets \
testsuite/amp-escape testsuite/help testsuite/file \
@@ -252,9 +252,6 @@ EXTRA_DIST += \
testsuite/inclib.good \
testsuite/inclib.inp \
testsuite/inclib.sed \
- testsuite/insert.good \
- testsuite/insert.inp \
- testsuite/insert.sed \
testsuite/khadafy.good \
testsuite/khadafy.inp \
testsuite/khadafy.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index c615ec9..55fbf18 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -72,6 +72,11 @@ y/Ss\nYy/yY$sS/'),
{OUT=> "bar bar fo oo f oo bar bar bar bar bar bar bar bar bar\n"},
],
+ ['insert-nl', qw(-f), {IN => "/foo/i\\\n"},
+ {IN => "bar\nfoo\n" },
+ {OUT=> "bar\n\nfoo\n" },
+ ],
+
);
my $save_temps = $ENV{SAVE_TEMPS};
--
2.9.3
From 6292970bc6f036c2ed02c7bd98d9efa2e5ce8dd0 Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Sat, 25 Mar 2017 16:28:25 -0700
Subject: [PATCH 11/12] tests: convert "recall" test to new framework
* testsuite/misc.pl (Tests): Add recall.
* testsuite/recall.good: Delete file.
* testsuite/recall.inp: Likewise.
* testsuite/recall.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "recall".
---
testsuite/local.mk | 5 +----
testsuite/misc.pl | 14 ++++++++++++++
testsuite/recall.good | 7 -------
testsuite/recall.inp | 1 -
testsuite/recall.sed | 7 -------
5 files changed, 15 insertions(+), 19 deletions(-)
delete mode 100644 testsuite/recall.good
delete mode 100644 testsuite/recall.inp
delete mode 100644 testsuite/recall.sed
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 6d07488..77fae8a 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -113,7 +113,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/numsub5 testsuite/0range testsuite/bkslashes \
testsuite/madding testsuite/mac-mf \
testsuite/xbxcx testsuite/xbxcx3 \
- testsuite/recall testsuite/recall2 testsuite/xemacs \
+ testsuite/recall2 testsuite/xemacs \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
testsuite/distrib testsuite/8to7 \
@@ -302,9 +302,6 @@ EXTRA_DIST += \
testsuite/readin.good \
testsuite/readin.inp \
testsuite/readin.sed \
- testsuite/recall.good \
- testsuite/recall.inp \
- testsuite/recall.sed \
testsuite/recall2.good \
testsuite/recall2.inp \
testsuite/recall2.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index 55fbf18..bd9a665 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -77,6 +77,20 @@ y/Ss\nYy/yY$sS/'),
{OUT=> "bar\n\nfoo\n" },
],
+ ['recall',
+ # Check that the empty regex recalls the last *executed* regex,
+ # not the last *compiled* regex
+ qw(-f), {IN => "p;s/e/X/p;:x;s//Y/p;/f/bx"},
+ {IN => "eeefff\n" },
+ {OUT=> "eeefff\n"
+ . "Xeefff\n"
+ . "XYefff\n"
+ . "XYeYff\n"
+ . "XYeYYf\n"
+ . "XYeYYY\n"
+ . "XYeYYY\n"
+ },
+ ],
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/recall.good b/testsuite/recall.good
deleted file mode 100644
index 230cc08..0000000
--- a/testsuite/recall.good
+++ /dev/null
@@ -1,7 +0,0 @@
-eeefff
-Xeefff
-XYefff
-XYeYff
-XYeYYf
-XYeYYY
-XYeYYY
diff --git a/testsuite/recall.inp b/testsuite/recall.inp
deleted file mode 100644
index ef34b7e..0000000
--- a/testsuite/recall.inp
+++ /dev/null
@@ -1 +0,0 @@
-eeefff
diff --git a/testsuite/recall.sed b/testsuite/recall.sed
deleted file mode 100644
index c1d7f9c..0000000
--- a/testsuite/recall.sed
+++ /dev/null
@@ -1,7 +0,0 @@
-# Check that the empty regex recalls the last *executed* regex,
-# not the last *compiled* regex
-p
-s/e/X/p
-:x
-s//Y/p
-/f/bx
--
2.9.3
From 24c546362d5827ba79836535ef839f6bfeb6d6aa Mon Sep 17 00:00:00 2001
From: Jim Meyering
Date: Sat, 25 Mar 2017 17:20:34 -0700
Subject: [PATCH 12/12] tests: convert "recall2" test to new framework
* testsuite/misc.pl (Tests): Add recall2.
* testsuite/recall2.good: Delete file.
* testsuite/recall2.inp: Likewise.
* testsuite/recall2.sed: Likewise.
* testsuite/local.mk (EXTRA_DIST): Remove their names.
(SEDTESTS): Remove "recall2".
---
testsuite/local.mk | 5 +----
testsuite/misc.pl | 10 ++++++++++
testsuite/recall2.good | 1 -
testsuite/recall2.inp | 1 -
testsuite/recall2.sed | 5 -----
5 files changed, 11 insertions(+), 11 deletions(-)
delete mode 100644 testsuite/recall2.good
delete mode 100644 testsuite/recall2.inp
delete mode 100644 testsuite/recall2.sed
diff --git a/testsuite/local.mk b/testsuite/local.mk
index 77fae8a..cd192dd 100644
--- a/testsuite/local.mk
+++ b/testsuite/local.mk
@@ -113,7 +113,7 @@ SEDTESTS += testsuite/appquit testsuite/enable testsuite/sep \
testsuite/numsub5 testsuite/0range testsuite/bkslashes \
testsuite/madding testsuite/mac-mf \
testsuite/xbxcx testsuite/xbxcx3 \
- testsuite/recall2 testsuite/xemacs \
+ testsuite/xemacs \
testsuite/fasts testsuite/uniq testsuite/manis \
testsuite/khadafy testsuite/linecnt testsuite/eval \
testsuite/distrib testsuite/8to7 \
@@ -302,9 +302,6 @@ EXTRA_DIST += \
testsuite/readin.good \
testsuite/readin.inp \
testsuite/readin.sed \
- testsuite/recall2.good \
- testsuite/recall2.inp \
- testsuite/recall2.sed \
testsuite/sep.good \
testsuite/sep.inp \
testsuite/sep.sed \
diff --git a/testsuite/misc.pl b/testsuite/misc.pl
index bd9a665..8cd1a92 100644
--- a/testsuite/misc.pl
+++ b/testsuite/misc.pl
@@ -91,6 +91,16 @@ y/Ss\nYy/yY$sS/'),
. "XYeYYY\n"
},
],
+
+ ['recall2',
+ # Starting from sed 4.1.3, regexes are compiled with REG_NOSUB
+ # if they are used in an address, so that the matcher does not
+ # have to obey leftmost-longest. The tricky part is to recompile
+ # them if they are then used in a substitution.
+ qw(-f), {IN => '/\(ab*\)\+/ s//>\1 "ababb||abbbabbbb\n" },
+ {OUT=> ">abb<||>abbbb<\n" },
+ ],
);
my $save_temps = $ENV{SAVE_TEMPS};
diff --git a/testsuite/recall2.good b/testsuite/recall2.good
deleted file mode 100644
index 74c01ea..0000000
--- a/testsuite/recall2.good
+++ /dev/null
@@ -1 +0,0 @@
->abb<||>abbbb<
diff --git a/testsuite/recall2.inp b/testsuite/recall2.inp
deleted file mode 100644
index 9046d59..0000000
--- a/testsuite/recall2.inp
+++ /dev/null
@@ -1 +0,0 @@
-ababb||abbbabbbb
diff --git a/testsuite/recall2.sed b/testsuite/recall2.sed
deleted file mode 100644
index f668773..0000000
--- a/testsuite/recall2.sed
+++ /dev/null
@@ -1,5 +0,0 @@
-# Starting from sed 4.1.3, regexes are compiled with REG_NOSUB
-# if they are used in an address, so that the matcher does not
-# have to obey leftmost-longest. The tricky part is to recompile
-# them if they are then used in a substitution.
-/\(ab*\)\+/ s//>\1