(testsuite) Don't fail long option tests if command has no long options.

Many basic commands do not have long options on non-GNU systems, mark such
tests as unsupported (if the command doesn't respond to --help) instead of
failing.

Implemented with the new $failcmd parameter to assert_exec().
This commit is contained in:
Ville Skyttä 2010-01-30 14:56:39 +02:00
parent c5470fdf74
commit 8f4111d5a4
19 changed files with 59 additions and 21 deletions

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "env --"
if {[assert_exec {env --help} "" "" "unsupported"]} {
assert_complete_any "env --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "expand --"
if {[assert_exec {expand --help} "" "" "unsupported"]} {
assert_complete_any "expand --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "fold --"
if {[assert_exec {fold --help} "" "" "unsupported"]} {
assert_complete_any "fold --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "gprof --"
if {[assert_exec {gprof --help} "" "" "unsupported"]} {
assert_complete_any "gprof --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "head --"
if {[assert_exec {head --help} "" "" "unsupported"]} {
assert_complete_any "head --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "ls --"
if {[assert_exec {ls --help} "" "" "unsupported"]} {
assert_complete_any "ls --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "m4 --"
if {[assert_exec {m4 --help} "" "" "unsupported"]} {
assert_complete_any "m4 --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "sed --"
if {[assert_exec {sed --help} "" "" "unsupported"]} {
assert_complete_any "sed --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "split --"
if {[assert_exec {split --help} "" "" "unsupported"]} {
assert_complete_any "split --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "tail --"
if {[assert_exec {tail --help} "" "" "unsupported"]} {
assert_complete_any "tail --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "touch --"
if {[assert_exec {touch --help} "" "" "unsupported"]} {
assert_complete_any "touch --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "tr --"
if {[assert_exec {tr --help} "" "" "unsupported"]} {
assert_complete_any "tr --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "uname --"
if {[assert_exec {uname --help} "" "" "unsupported"]} {
assert_complete_any "uname --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "unexpand --"
if {[assert_exec {unexpand --help} "" "" "unsupported"]} {
assert_complete_any "unexpand --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "uniq --"
if {[assert_exec {uniq --help} "" "" "unsupported"]} {
assert_complete_any "uniq --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "units --"
if {[assert_exec {units --help} "" "" "unsupported"]} {
assert_complete_any "units --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "wc --"
if {[assert_exec {wc --help} "" "" "unsupported"]} {
assert_complete_any "wc --"
}; # if
sync_after_int

View File

@ -11,7 +11,9 @@ proc teardown {} {
setup
assert_complete_any "who --"
if {[assert_exec {who --help} "" "" "unsupported"]} {
assert_complete_any "who --"
}; # if
sync_after_int

View File

@ -397,15 +397,17 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
# Make sure the specified command executed from within Tcl/Expect.
# Fail the test with status UNSUPPORTED if Tcl fails with error "POSIX/ENOENT
# (No such file or directory)", or UNRESOLVED if other error occurs.
# (No such file or directory)", or with the given Tcl failure status command
# (default "unresolved") if other error occurs.
# NOTE: Further tests are assumed if executing the command is successful. The
# test isn't immediately declared to have PASSED if the command is
# executed successful.
# @param string $command
# @param string $stdout (optional) Reference to variable to hold stdout.
# @param string $test (optional) Test title
# @param string $failcmd (optional, default "unresolved") Failure command
# @see assert_bash_exec()
proc assert_exec {cmd {stdout ''} {test ''}} {
proc assert_exec {cmd {stdout ''} {test ''} {failcmd "unresolved"}} {
if {$test == ""} {set test "$cmd should execute successfully"}
upvar $stdout results
set status [catch {eval exec $cmd} results]
@ -419,7 +421,7 @@ proc assert_exec {cmd {stdout ''} {test ''}} {
# Indicate test is unsupported
unsupported "$test"
} else {
unresolved "$test"
$failcmd "$test"
}; # if
}; # if
return $result