[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Tue May 29 20:24:45 UTC 2007


 tests/t0000-basic.sh       |    5 ++---
 tests/t3000-constraints.sh |    8 --------
 tests/test-lib.sh          |    7 +++++++
 3 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit f1fbf278ba03388242b7adf5dcba90918bac78c9
Author: Jim Meyering <jim at meyering.net>
Date:   Tue May 29 20:29:47 2007 +0200

    Move a test/utility function into test-lib.sh.
    
    * tests/t3000-constraints.sh (emit_superuser_warning): Move this
    function to...
    * tests/test-lib.sh (emit_superuser_warning): ...here.
    * tests/t0000-basic.sh: Use the function instead of open-coding it.
    
    Signed-off-by: Jim Meyering <jim at meyering.net>

diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 5f651b3..1a11121 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -57,10 +57,9 @@ test_expect_success \
     'run parted mklabel (without -s) on a blank disk' \
     'parted $dev mklabel msdos > out 2>&1'
 
-warning_msg='WARNING: You are not superuser.  Watch out for permissions.'
 test_expect_success \
     'create expected output file' \
-    'test "$uid" = 0 && : > exp || echo "$warning_msg" > exp'
+    'emit_superuser_warning > exp'
 
 test_expect_success \
     'check its "interactive" output' \
@@ -82,7 +81,7 @@ test_expect_success \
 
 # Create expected output file.
 fail=0
-{ test "$uid" = 0 && : > exp || echo "$warning_msg" > exp; } || fail=1
+{ emit_superuser_warning > exp; } || fail=1
 cat <<EOF >> exp || fail=1
 Warning: The existing disk label on DEVICE will be destroyed and all\
  data on this disk will be lost. Do you want to continue?
diff --git a/tests/t3000-constraints.sh b/tests/t3000-constraints.sh
index 07fe1b3..179a33c 100755
--- a/tests/t3000-constraints.sh
+++ b/tests/t3000-constraints.sh
@@ -21,14 +21,6 @@ test_description="exercise Parted's constraint-management code"
 
 . ./init.sh
 
-# FIXME: move this to test-lib.sh, and use it in t0000*.sh
-emit_superuser_warning()
-{
-  uid=`id -u` || uid=1
-  test "$uid" != 0 &&
-    echo 'WARNING: You are not superuser.  Watch out for permissions.'
-}
-
 dev=loop-file
 N=2
 t=ext2
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 050b967..29a2be1 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -201,6 +201,13 @@ if test "$privileges_required_" != ''; then
     fi
 fi
 
+emit_superuser_warning()
+{
+  uid=`id -u` || uid=1
+  test "$uid" != 0 &&
+    echo 'WARNING: You are not superuser.  Watch out for permissions.'
+}
+
 # Test the binaries we have just built.
 pwd_=`pwd`
 parted_="$pwd_/../parted/parted"



More information about the Parted-commits mailing list