GNU bug report logs - #9237
[PATCH] tests: get rid of obsolete 'error_' shell function

Previous Next

Package: coreutils;

Reported by: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Date: Thu, 4 Aug 2011 08:54:01 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Meyering <jim <at> meyering.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#9237: closed ([PATCH] tests: get rid of obsolete 'error_'
 shell function)
Date: Sun, 13 Nov 2011 11:42:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 13 Nov 2011 12:41:18 +0100
with message-id <87k474ntb5.fsf <at> rho.meyering.net>
and subject line Re: bug#9237: [PATCH] tests: get rid of obsolete 'error_' shell function
has caused the debbugs.gnu.org bug report #9237,
regarding [PATCH] tests: get rid of obsolete 'error_' shell function
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
9237: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9237
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] tests: get rid of obsolete 'error_' shell function
Date: Thu, 4 Aug 2011 10:52:26 +0200
[Message part 3 (text/plain, inline)]
 $ cd ~/src/coreutils
 $ grep -I -r --exclude-dir=.git '\berror_\b' .
 ./tests/shell-or-perl:error_ ()
 ./tests/shell-or-perl:  test $# -gt 1 || error_ "option '\''$1'\'' requires an argument"
 ./tests/shell-or-perl:    -*) error_ "unknown option '$1'";;
 ./tests/shell-or-perl:  0) error_ "missing argument";;
 ./tests/shell-or-perl:  || error_ "test script '$test_script' does not exist, or isn't readable"
 ./tests/shell-or-perl:  || error_ "cannot read from the test script '$test_script'"
 ./tests/shell-or-perl:error_ "dead code reached"
 ./tests/init.cfg:# FIXME: eventually s/error_/fail_/ and remove the definition of error_ below.
 ./tests/init.cfg:    error_ "Error running getlimits"
 ./tests/init.cfg:error_() { echo "$0: $@" 1>&2; Exit 1; }
 ./tests/init.cfg:framework_failure() { error_ 'failure in testing framework'; }

So, time to remove dead code, right? :-)

What about the attached patch?

Regards,
  Stefano
[0001-tests-get-rid-of-obsolete-error_-shell-function.patch (text/x-patch, inline)]
From ddc9db5fb98069066f3fb2160be433fa7a2a5d44 Mon Sep 17 00:00:00 2001
Message-Id: <ddc9db5fb98069066f3fb2160be433fa7a2a5d44.1312447742.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Thu, 4 Aug 2011 10:48:38 +0200
Subject: [PATCH] tests: get rid of obsolete 'error_' shell function

* tests/init.cfg (framework_failure, getlimits_): Use 'fatal_'
instead of 'error_'.
(error_): Delete, it's not used anymore (and one is anyway
advised to use 'fatal_' instead).
Update heading comments.
* tests/shell-or-perl (error_): Renamed ...
(fatal_): ... to this, for consistency.  Also, add a useful
comment.
---
 tests/init.cfg      |   10 ++++------
 tests/shell-or-perl |   16 +++++++++-------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/tests/init.cfg b/tests/init.cfg
index 1b8f870..60c5108 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -4,8 +4,8 @@
 # TESTS_ENVIRONMENT definition.
 stderr_fileno_=9
 
-# FIXME: eventually s/error_/fail_/ and remove the definition of error_ below.
-# FIXME: s/(framework_failure)\>/${1}_/ and remove def. of framework_failure
+# FIXME: eventually, FIXME: s/(framework_failure)\>/${1}_/ and remove the
+# FIXME: definition of framework_failure below
 
 # Having an unsearchable directory in PATH causes execve to fail with EACCES
 # when applied to an unresolvable program name, contrary to the desired ENOENT.
@@ -37,8 +37,7 @@ sanitize_path_()
 getlimits_()
 {
   eval $(getlimits)
-  test "$INT_MAX" ||
-    error_ "Error running getlimits"
+  test "$INT_MAX" || fatal_ "running getlimits"
 }
 
 require_acl_()
@@ -266,8 +265,7 @@ require_root_()
 }
 
 skip_if_root_() { uid_is_privileged_ && skip_ "must be run as non-root"; }
-error_() { echo "$0: $@" 1>&2; Exit 1; }
-framework_failure() { error_ 'failure in testing framework'; }
+framework_failure() { fatal_ 'failure in testing framework'; }
 
 # Set `groups' to a space-separated list of at least two groups
 # of which the user is a member.
diff --git a/tests/shell-or-perl b/tests/shell-or-perl
index accb37a..489c112 100644
--- a/tests/shell-or-perl
+++ b/tests/shell-or-perl
@@ -28,9 +28,11 @@ set -u
 
 me=shell-or-perl
 
-error_ ()
+fatal_ ()
 {
   echo "$me: $*" >&2
+  # Exit with status `99' to inform the testsuite harness that an
+  # hard error occurred.
   exit 99
 }
 
@@ -47,7 +49,7 @@ EOH
 # ---------------- #
 
 assign_optarg_to_var='
-  test $# -gt 1 || error_ "option '\''$1'\'' requires an argument"
+  test $# -gt 1 || fatal_ "option '\''$1'\'' requires an argument"
   eval "$var=\$2"
   shift'
 
@@ -64,7 +66,7 @@ while test $# -gt 0; do
     --srcdir) var=srcdir;;
     --test-name) var=test_name;;
     --) shift; break;;
-    -*) error_ "unknown option '$1'";;
+    -*) fatal_ "unknown option '$1'";;
     *) break;;
   esac
   test -z "$var" || eval "$assign_optarg_to_var"
@@ -74,7 +76,7 @@ done
 unset assign_optarg_to_var var
 
 case $# in
-  0) error_ "missing argument";;
+  0) fatal_ "missing argument";;
   *) test_script=$1; shift;;
 esac
 
@@ -85,10 +87,10 @@ test -z "$test_name" && test_name=$test_script
 # --------------------- #
 
 test -f "$test_script" && test -r "$test_script" \
-  || error_ "test script '$test_script' does not exist, or isn't readable"
+  || fatal_ "test script '$test_script' does not exist, or isn't readable"
 
 read shebang_line < "$test_script" \
-  || error_ "cannot read from the test script '$test_script'"
+  || fatal_ "cannot read from the test script '$test_script'"
 
 case $shebang_line in
 '#!/usr/bin/perl'*)
@@ -116,4 +118,4 @@ esac
 #  Not reached  #
 # ------------- #
 
-error_ "dead code reached"
+fatal_ "dead code reached"
-- 
1.7.2.3

[Message part 5 (message/rfc822, inline)]
From: Jim Meyering <jim <at> meyering.net>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 9237-done <at> debbugs.gnu.org
Subject: Re: bug#9237: [PATCH] tests: get rid of obsolete 'error_' shell
	function
Date: Sun, 13 Nov 2011 12:41:18 +0100
Stefano Lattarini wrote:
...
>> Also, I have queued this additional change set:
...
>> Subject: [PATCH 2/2] maint: prevent accidental future use of the old shell
>>  function name

This was addressed months ago.
Closing the bug.


This bug report was last modified 13 years and 192 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.