OSDN Git Service

Move a test/utility function into test-lib.sh.
authorJim Meyering <jim@meyering.net>
Tue, 29 May 2007 18:29:47 +0000 (20:29 +0200)
committerJim Meyering <jim@meyering.net>
Tue, 29 May 2007 20:23:50 +0000 (22:23 +0200)
* 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@meyering.net>
tests/t0000-basic.sh
tests/t3000-constraints.sh
tests/test-lib.sh

index 5f651b3..1a11121 100755 (executable)
@@ -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?
index 07fe1b3..179a33c 100755 (executable)
@@ -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
index 050b967..29a2be1 100644 (file)
@@ -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"