From 8f4111d5a43500775bbb22edcf0d6cc02280566b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 30 Jan 2010 14:56:39 +0200 Subject: (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(). --- test/lib/completions/env.exp | 4 +++- test/lib/completions/expand.exp | 4 +++- test/lib/completions/fold.exp | 4 +++- test/lib/completions/gprof.exp | 4 +++- test/lib/completions/head.exp | 4 +++- test/lib/completions/ls.exp | 4 +++- test/lib/completions/m4.exp | 4 +++- test/lib/completions/sed.exp | 4 +++- test/lib/completions/split.exp | 4 +++- test/lib/completions/tail.exp | 4 +++- test/lib/completions/touch.exp | 4 +++- test/lib/completions/tr.exp | 4 +++- test/lib/completions/uname.exp | 4 +++- test/lib/completions/unexpand.exp | 4 +++- test/lib/completions/uniq.exp | 4 +++- test/lib/completions/units.exp | 4 +++- test/lib/completions/wc.exp | 4 +++- test/lib/completions/who.exp | 4 +++- test/lib/library.exp | 8 +++++--- 19 files changed, 59 insertions(+), 21 deletions(-) diff --git a/test/lib/completions/env.exp b/test/lib/completions/env.exp index 0f523cbc..f03f5395 100644 --- a/test/lib/completions/env.exp +++ b/test/lib/completions/env.exp @@ -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 diff --git a/test/lib/completions/expand.exp b/test/lib/completions/expand.exp index de1b7f6d..d5cd6b17 100644 --- a/test/lib/completions/expand.exp +++ b/test/lib/completions/expand.exp @@ -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 diff --git a/test/lib/completions/fold.exp b/test/lib/completions/fold.exp index 673fe214..a5230b03 100644 --- a/test/lib/completions/fold.exp +++ b/test/lib/completions/fold.exp @@ -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 diff --git a/test/lib/completions/gprof.exp b/test/lib/completions/gprof.exp index b436b9d1..592786af 100644 --- a/test/lib/completions/gprof.exp +++ b/test/lib/completions/gprof.exp @@ -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 diff --git a/test/lib/completions/head.exp b/test/lib/completions/head.exp index 9782f5ef..0d4f6a20 100644 --- a/test/lib/completions/head.exp +++ b/test/lib/completions/head.exp @@ -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 diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp index 82e898c8..db2d41d3 100644 --- a/test/lib/completions/ls.exp +++ b/test/lib/completions/ls.exp @@ -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 diff --git a/test/lib/completions/m4.exp b/test/lib/completions/m4.exp index 6ed4344c..2cc884b3 100644 --- a/test/lib/completions/m4.exp +++ b/test/lib/completions/m4.exp @@ -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 diff --git a/test/lib/completions/sed.exp b/test/lib/completions/sed.exp index 05841070..8764cfb8 100644 --- a/test/lib/completions/sed.exp +++ b/test/lib/completions/sed.exp @@ -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 diff --git a/test/lib/completions/split.exp b/test/lib/completions/split.exp index 249ff9bc..b74da369 100644 --- a/test/lib/completions/split.exp +++ b/test/lib/completions/split.exp @@ -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 diff --git a/test/lib/completions/tail.exp b/test/lib/completions/tail.exp index fb8d89e3..c8a82d97 100644 --- a/test/lib/completions/tail.exp +++ b/test/lib/completions/tail.exp @@ -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 diff --git a/test/lib/completions/touch.exp b/test/lib/completions/touch.exp index d8b07ced..f0960ef7 100644 --- a/test/lib/completions/touch.exp +++ b/test/lib/completions/touch.exp @@ -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 diff --git a/test/lib/completions/tr.exp b/test/lib/completions/tr.exp index 87e93fad..68b11a36 100644 --- a/test/lib/completions/tr.exp +++ b/test/lib/completions/tr.exp @@ -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 diff --git a/test/lib/completions/uname.exp b/test/lib/completions/uname.exp index 8de0eeda..2179dafd 100644 --- a/test/lib/completions/uname.exp +++ b/test/lib/completions/uname.exp @@ -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 diff --git a/test/lib/completions/unexpand.exp b/test/lib/completions/unexpand.exp index ecb726fd..31822561 100644 --- a/test/lib/completions/unexpand.exp +++ b/test/lib/completions/unexpand.exp @@ -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 diff --git a/test/lib/completions/uniq.exp b/test/lib/completions/uniq.exp index 6b915596..20dbcfac 100644 --- a/test/lib/completions/uniq.exp +++ b/test/lib/completions/uniq.exp @@ -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 diff --git a/test/lib/completions/units.exp b/test/lib/completions/units.exp index b4c52b03..a40b5f3f 100644 --- a/test/lib/completions/units.exp +++ b/test/lib/completions/units.exp @@ -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 diff --git a/test/lib/completions/wc.exp b/test/lib/completions/wc.exp index d4e04ca2..8ad2bf8d 100644 --- a/test/lib/completions/wc.exp +++ b/test/lib/completions/wc.exp @@ -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 diff --git a/test/lib/completions/who.exp b/test/lib/completions/who.exp index be3ed288..73928ef7 100644 --- a/test/lib/completions/who.exp +++ b/test/lib/completions/who.exp @@ -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 diff --git a/test/lib/library.exp b/test/lib/library.exp index fab33bff..60062ccd 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -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 -- cgit v1.2.1