coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: refactor tests/misc/pr.pl into tests/pr/pr-tests.pl


From: Pádraig Brady
Subject: Re: [PATCH] maint: refactor tests/misc/pr.pl into tests/pr/pr-tests.pl
Date: Thu, 25 Oct 2012 12:00:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 10/25/2012 10:48 AM, Jim Meyering wrote:
Pádraig Brady wrote:
* tests/misc/pr.pl: Refactor this test into ...
* tests/pr/pr-tests.pl: ... here.
* tests/local.mk: Remove the reference to the removed test
* tests/pr/m-w-t-1: Input file for the refactored test.
* tests/pr/m-w-t-2: Likewise.
* tests/pr/m-w-t-3: Likewise.
---
  tests/local.mk       |    1 -
  tests/misc/pr.pl     |   43 -------------------------------------------
  tests/pr/m-w-t-1     |    1 +
  tests/pr/m-w-t-2     |    1 +
  tests/pr/m-w-t-3     |    1 +
  tests/pr/pr-tests.pl |    4 ++++
  6 files changed, 7 insertions(+), 44 deletions(-)
  delete mode 100755 tests/misc/pr.pl
  create mode 100644 tests/pr/m-w-t-1
  create mode 100644 tests/pr/m-w-t-2
  create mode 100644 tests/pr/m-w-t-3

Thanks.  You're right that those should be consolidated.
However, you can move the content of misc/pr.pl into pr-tests.pl
without adding those three tiny new files to version control.

To see why, some background helps.
In pr-tests.pl, you see tests (option,I/O,exit-status quadruples)
that are very concise, e.g.,

   ['1c', '+3', [\'0Ft'], [\'3-0F'], 0],

That is the old format.  Years ago, I converted nearly all of those
tests to the newer style, which is generally preferable, but in this
case, with many explicitly-named input and output files rather than
just i/o content, converting would have made the tests less readable.
Few would fit on one line.  So, instead, I wrote the loop at the end of
that file that automatically converts the old format to the new one.

However, in the case of this test, now that you know the
old-style tests have been converted to the new style, you
can simply append that lone entry to the @Tests list:

diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl
index f202414..c21cca3 100755
--- a/tests/pr/pr-tests.pl
+++ b/tests/pr/pr-tests.pl
@@ -451,6 +451,13 @@ foreach my $t (@tv)
      push @Tests, $new_ent;
    }

+push @Tests,
+   ['merge-w-tabs', '-m -s -t',
+    {IN=>{1=>"a\tb\tc\n"}},
+    {IN=>{2=>"m\tn\to\n"}},
+    {IN=>{3=>"x\ty\tz\n"}},
+     {OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ];
+
  @Tests = triple_test \@Tests;

  my $save_temps = $ENV{DEBUG};

Much better.

Pushed with that adjustment.

thanks,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]