[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New API call: "testsuite has api call"

From: Jacob Bachmeyer
Subject: New API call: "testsuite has api call"
Date: Wed, 03 Jun 2020 18:29:01 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20090807 MultiZilla/ SeaMonkey/1.1.17 Mnenhy/

While planning support for the new XML output, I realized that the "testsuite file" API was introduced after 1.6.2, which means that checking for the existence of "testsuite" itself is sufficient to indicate that it is available, but "testsuite" throws an error if given an unrecognized subcommand. I also realized that a feature test for new API calls would be helpful in allowing testsuites to "gracefully degrade" when run on older versions of DejaGnu. Getting this in for 1.6.3 is a priority, since it will avoid a "gap" where the "testsuite" command exists but the API feature test does not.

The proposed form is simple:  testsuite has api call <api call as words>
As an example [testsuite has api call testsuite file] returns 1 as does [testsuite has api call testsuite has api call].

Test scripts are expected to use this call along the lines of:
   if { [testsuite has api call some new command] } {
       some new command and its args

Partial patch for discussion: (note to maintainers: do not apply this patch from email; it is incomplete and the actual submission with NEWS and ChangeLog updates (and tests! -- I had to amend the commit locally after realizing I forgot to add the new file!) will be pushed to the repository later after possible revisions from the discussion)

diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index bb386e8..012ac0e 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -3234,6 +3234,21 @@ implied by the returned value will exist upon return.  
directories are created in the object tree if needed.  An error is
raised if an implied directory does not exist in the source tree.

+@subsubheading testsuite has api call
+The @code{testsuite has api call} command is a feature test and
+returns a boolean value indicating if a subcommand under a multiplex
+point is available.  This API call is needed because only the
+multiplex points themselves are visible to the Tcl info command.
+@t{  @b{testsuite has api call} @i{name}... }
+@end quotation
+Any number of words are joined together into a single name, beginning
+with a multiplex entry point and forming the full name of an API call
+as documented in this manual.
@node Procedures For Remote Communication, connprocs, Core Internal Procedures, 
Built-in Procedures
@section Procedures For Remote Communication

diff --git a/lib/framework.exp b/lib/framework.exp
index e6ce197..729c403 100644
--- a/lib/framework.exp
+++ b/lib/framework.exp
@@ -1019,10 +1019,13 @@ proc incr_count { name args } {
proc testsuite { subcommand args } {
    if { $subcommand eq "file" } {
       testsuite_file $args
+    } elseif { $subcommand eq "has" } {
+       testsuite_has $args
    } else {
       error "unknown \"testsuite\" command: testsuite $subcommand $args"
+namespace eval ::dejagnu {}

# Return a full file name in or near the testsuite
@@ -1075,3 +1078,22 @@ proc testsuite_file { argv } {
    verbose "leaving testsuite file: $result" 3
    return $result
+array set ::dejagnu::apilist { {testsuite file} 1 }
+# Feature test
+proc testsuite_has { argv } {
+    verbose "entering testsuite has $argv" 3
+    set argc [llength $argv]
+    if { [lrange $argv 0 1] eq "api call" } {
+       set call [lrange $argv 2 end]
+       set result [info exists ::dejagnu::apilist($call)]
+    } else {
+       error "unknown feature test:  testsuite has $argv"
+    }
+    verbose "leaving testsuite has: $result" 3
+    return $result
+array set ::dejagnu::apilist { {testsuite has api call} 1 }

-- Jacob

reply via email to

[Prev in Thread] Current Thread [Next in Thread]