coreutils
[Top][All Lists]
Advanced

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

[PATCH 3/4] tests: use perl's qx!...! rather than `...`


From: Jim Meyering
Subject: [PATCH 3/4] tests: use perl's qx!...! rather than `...`
Date: Tue, 3 Apr 2012 22:25:35 +0200

From: Jim Meyering <address@hidden>

* tests/misc/expr: As above.
* tests/misc/ls-misc: Likewise.
* tests/misc/pwd-long: Likewise.
* tests/misc/uniq: Likewise.

tests: convert nearly all `...` expressions to $(...)
Exempt init.sh because it runs before we're assured to have a
shell that groks $(...).  Exempt *.mk because "$" would have to
be doubled, and besides, any `...` expression in a .mk file is
almost certainly evaluated before init.sh is run.  Finally, also
exempt the perl-based tests, because perl's `...` cannot be
converted to $(...).  Do that by running this command:

git grep -l '`.*`' tests \
  | grep -Ev 'init\.sh|\.mk$' | xargs grep -Lw perl \
  | xargs perl -pi -e 's/`(.*?)`/\$($1)/g'

One minor fix-up change was required after that, due to how
quoting differs:
diff --git a/tests/chmod/equals b/tests/chmod/equals
-    expected_perms=$(eval 'echo \$expected_'$dest)
+    expected_perms=$(eval 'echo $expected_'$dest)
---
 tests/misc/expr     |    2 +-
 tests/misc/ls-misc  |    2 +-
 tests/misc/pwd-long |    6 +-----
 tests/misc/uniq     |    2 +-
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/tests/misc/expr b/tests/misc/expr
index 781cf38..c298d4c 100755
--- a/tests/misc/expr
+++ b/tests/misc/expr
@@ -175,7 +175,7 @@ my @Tests =
     );

 # If using big numbers fails, remove all /^bignum-/ tests
-`expr $big_prod '*' $big_prod '*' $big_prod`
+qx!expr $big_prod '*' $big_prod '*' $big_prod!
   or @Tests = grep {$_->[0] !~ /^bignum-/} @Tests;

 # Append a newline to end of each expected 'OUT' string.
diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc
index 14e1176..71647f9 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc
@@ -331,7 +331,7 @@ $fail
   and exit 1;

 # Be careful to use the just-build dircolors.
-my $env = `$ENV{abs_top_builddir}/src/dircolors -b`;
+my $env = qx/dircolors -b/;
 $env =~ s/^LS_COLORS=\'//;
 $env =~ s/\';.*//sm;
 $ENV{LS_COLORS} = $env;
diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long
index a030a18..033c0e3 100755
--- a/tests/misc/pwd-long
+++ b/tests/misc/pwd-long
@@ -93,11 +93,7 @@ $build_src_dir =~ m!^([-+.:/\w]+)$!
     . "$build_src_dir\n";
 $build_src_dir = $1;

-my $pwd_binary = "$build_src_dir/pwd";
-
--x $pwd_binary
-  or die "$ME: $pwd_binary is not an executable file\n";
-chomp (my $actual = `$pwd_binary`);
+chomp (my $actual = qx!env pwd!);

 # Convert the absolute name from pwd into a $CWD-relative name.
 # This is necessary in order to avoid a spurious failure when run
diff --git a/tests/misc/uniq b/tests/misc/uniq
index f7211a3..91028a9 100755
--- a/tests/misc/uniq
+++ b/tests/misc/uniq
@@ -86,7 +86,7 @@ my $locale = $ENV{LOCALE_FR};
   and CuSkip::skip "$prog: skipping this test -- no appropriate locale\n";

 # See if isblank returns true for nbsp.
-my $x = `env printf '\xa0'| LC_ALL=$locale tr '[:blank:]' x`;
+my $x = qx!env printf '\xa0'| LC_ALL=$locale tr '[:blank:]' x!;
 # If so, expect just one line of output in the schar test.
 # Otherwise, expect two.
 my $in = " y z\n\xa0 y z\n";
-- 
1.7.9.3




reply via email to

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