summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrestez Dan Leonard <cdleonard@gmail.com>2010-02-03 13:30:05 +0200
committerCrestez Dan Leonard <cdleonard@gmail.com>2010-02-03 14:09:31 +0200
commitce624f79834221b90b9b8a73ad5748ae0d0c2295 (patch)
treed83bb5a6990b15d75d35a5b43806f73d45f55745
parent2ad9001556917f199470ba0467ed84d4305248eb (diff)
downloadbash-completion-ce624f79834221b90b9b8a73ad5748ae0d0c2295.tar.gz
Use find_unique_completion_pair in chown test
-rw-r--r--test/lib/completions/chown.exp35
1 files changed, 15 insertions, 20 deletions
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp
index 480f6743..b1207eed 100644
--- a/test/lib/completions/chown.exp
+++ b/test/lib/completions/chown.exp
@@ -14,26 +14,21 @@ assert_complete_any "chown "
sync_after_int
-# All the tests use the root:root user and group. They're assumed to exist.
-set fulluser "root"
-set fullgroup "root"
-
-# Partial username is assumed to be unambiguous.
-set partuser "roo"
-set partgroup "roo"
-
-# Skip tests if root:root not available or if roo:roo matches multiple
-# users/groups
-#
-# compgen -A is used because it's a bash builtin and available everywhere.
-# The || true part prevents exec from throwing an exception if nothing is
-# found.
-if {[exec bash -c "compgen -A user $partuser || true" | wc -l] > 1 ||
- [exec bash -c "compgen -A user $fulluser || true" | wc -l] != 1 ||
- [exec bash -c "compgen -A group $partgroup || true" | wc -l] > 1 ||
- [exec bash -c "compgen -A group $fullgroup || true" | wc -l] != 1} {
- untested "Not running complex chown tests."
-} else {
+# Find user/group suitable for testing.
+set failed_find_unique_completion 0
+foreach ug {user group} {
+ # compgen -A is used because it's a bash builtin and available everywhere.
+ # The || true part prevents exec from throwing an exception if nothing is
+ # found (very very unlikely).
+ set list [split [exec bash -c "compgen -A $ug || true"] "\n"]
+ if {![find_unique_completion_pair $list part$ug full$ug]} {
+ untested "Not running complex chown tests; no suitable test $ug found."
+ set failed_find_unique_completion 1
+ }
+}
+
+# These tests require an unique completion.
+if {!$failed_find_unique_completion} {
assert_complete $fulluser "chown $partuser"
sync_after_int