[Pkg-shadow-commits] r3607 - in debian/trunk/tests/expiry: 04_expiry_no_options 04_expiry_no_options/data 10_expiry_bad_option 10_expiry_bad_option/data

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Mon Nov 14 20:25:01 UTC 2011


Author: nekral-guest
Date: 2011-11-14 20:25:01 +0000 (Mon, 14 Nov 2011)
New Revision: 3607

Added:
   debian/trunk/tests/expiry/04_expiry_no_options/data/
   debian/trunk/tests/expiry/04_expiry_no_options/data/usage.out
   debian/trunk/tests/expiry/10_expiry_bad_option/data/
   debian/trunk/tests/expiry/10_expiry_bad_option/data/usage.out
Removed:
   debian/trunk/tests/expiry/04_expiry_no_options/expiry.exp
   debian/trunk/tests/expiry/10_expiry_bad_option/expiry.exp
Modified:
   debian/trunk/tests/expiry/04_expiry_no_options/expiry.test
   debian/trunk/tests/expiry/10_expiry_bad_option/expiry.test
Log:
Use simple test (without expect) for usage checking.


Added: debian/trunk/tests/expiry/04_expiry_no_options/data/usage.out
===================================================================
--- debian/trunk/tests/expiry/04_expiry_no_options/data/usage.out	                        (rev 0)
+++ debian/trunk/tests/expiry/04_expiry_no_options/data/usage.out	2011-11-14 20:25:01 UTC (rev 3607)
@@ -0,0 +1,8 @@
+Usage: expiry [options]
+
+Options:
+  -c, --check                   check the user's password expiration
+  -f, --force                   force password change if the user's password
+                                is expired
+  -h, --help                    display this help message and exit
+

Deleted: debian/trunk/tests/expiry/04_expiry_no_options/expiry.exp
===================================================================
--- debian/trunk/tests/expiry/04_expiry_no_options/expiry.exp	2011-11-14 20:19:14 UTC (rev 3606)
+++ debian/trunk/tests/expiry/04_expiry_no_options/expiry.exp	2011-11-14 20:25:01 UTC (rev 3607)
@@ -1,18 +0,0 @@
-#!/usr/bin/expect
-
-set timeout 2
-expect_after default {puts "\nFAIL"; exit 1}
-
-spawn /bin/sh
-send "if \[ \$(id -u) -eq 0 \]; then PS1='# '; else PS1='$ '; fi\r"
-expect "# "
-
-send "expiry\r"
-expect "Usage: expiry {-f|-c}"
-expect "# "
-send "echo \$?\r"
-expect "10"
-expect "# "
-send "exit\r"
-puts "OK\n"
-exit 0

Modified: debian/trunk/tests/expiry/04_expiry_no_options/expiry.test
===================================================================
--- debian/trunk/tests/expiry/04_expiry_no_options/expiry.test	2011-11-14 20:19:14 UTC (rev 3606)
+++ debian/trunk/tests/expiry/04_expiry_no_options/expiry.test	2011-11-14 20:25:01 UTC (rev 3607)
@@ -16,8 +16,25 @@
 
 change_config
 
-./expiry.exp
+echo -n "Call expiry without any option (expiry)..."
+expiry 2>tmp/usage.out && exit 1 || {
+	status=$?
+}
+echo "OK"
 
+echo -n "Check returned status ($status)..."
+test "$status" = "2"
+echo "OK"
+
+echo "expiry reported:"
+echo "======================================================================="
+cat tmp/usage.out
+echo "======================================================================="
+echo -n "Check the usage message..."
+diff -au data/usage.out tmp/usage.out
+echo "usage message OK."
+rm -f tmp/usage.out
+
 echo -n "Check the passwd file..."
 ../../common/compare_file.pl config/etc/passwd /etc/passwd
 echo "OK"

Added: debian/trunk/tests/expiry/10_expiry_bad_option/data/usage.out
===================================================================
--- debian/trunk/tests/expiry/10_expiry_bad_option/data/usage.out	                        (rev 0)
+++ debian/trunk/tests/expiry/10_expiry_bad_option/data/usage.out	2011-11-14 20:25:01 UTC (rev 3607)
@@ -0,0 +1,9 @@
+expiry: invalid option -- 'Z'
+Usage: expiry [options]
+
+Options:
+  -c, --check                   check the user's password expiration
+  -f, --force                   force password change if the user's password
+                                is expired
+  -h, --help                    display this help message and exit
+

Deleted: debian/trunk/tests/expiry/10_expiry_bad_option/expiry.exp
===================================================================
--- debian/trunk/tests/expiry/10_expiry_bad_option/expiry.exp	2011-11-14 20:19:14 UTC (rev 3606)
+++ debian/trunk/tests/expiry/10_expiry_bad_option/expiry.exp	2011-11-14 20:25:01 UTC (rev 3607)
@@ -1,18 +0,0 @@
-#!/usr/bin/expect
-
-set timeout 2
-expect_after default {puts "\nFAIL"; exit 1}
-
-spawn /bin/sh
-send "if \[ \$(id -u) -eq 0 \]; then PS1='# '; else PS1='$ '; fi\r"
-expect "# "
-
-send "expiry -Z\r"
-expect "Usage: expiry {-f|-c}"
-expect "# "
-send "echo \$?\r"
-expect "10"
-expect "# "
-send "exit\r"
-puts "OK\n"
-exit 0

Modified: debian/trunk/tests/expiry/10_expiry_bad_option/expiry.test
===================================================================
--- debian/trunk/tests/expiry/10_expiry_bad_option/expiry.test	2011-11-14 20:19:14 UTC (rev 3606)
+++ debian/trunk/tests/expiry/10_expiry_bad_option/expiry.test	2011-11-14 20:25:01 UTC (rev 3607)
@@ -6,9 +6,8 @@
 
 . ../../common/config.sh
 . ../../common/log.sh
+log_start "$0" "expiry provides an Usage message if an invalid option is given"
 
-log_start "$0" "expiry provides an Usage message if no options are given"
-
 save_config
 
 # restore the files on exit
@@ -16,8 +15,25 @@
 
 change_config
 
-./expiry.exp
+echo -n "Call expiry with an invalid option (expiry -Z)..."
+expiry -Z 2>tmp/usage.out && exit 1 || {
+	status=$?
+}
+echo "OK"
 
+echo -n "Check returned status ($status)..."
+test "$status" = "2"
+echo "OK"
+
+echo "expiry reported:"
+echo "======================================================================="
+cat tmp/usage.out
+echo "======================================================================="
+echo -n "Check the usage message..."
+diff -au data/usage.out tmp/usage.out
+echo "usage message OK."
+rm -f tmp/usage.out
+
 echo -n "Check the passwd file..."
 ../../common/compare_file.pl config/etc/passwd /etc/passwd
 echo "OK"




More information about the Pkg-shadow-commits mailing list