[RFA 3/4] Update tests following changes to "help" and "apropos"

Tom Tromey tom@tromey.com
Fri May 31 20:34:00 GMT 2019


>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:

Philippe> Factorizes the testing of the help output, by having a single place
Philippe> that defines the common help trailer and/or prefix messages.

Philippe> -test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"}
Philippe> +test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"} {}

Wow, test_class_help is ugly!

Or more precisely, help_test_raw is pretty bad, following the "args"
convention that is confusing:

    proc help_test_raw { gdb_command expected_lines args } {
        set message $gdb_command
        if [llength $args]>0 then {
            set message [lindex $args 0]
        } 

It seems like it would be way better to just have an optional argument
there.

Anyway, could the new argument to test_class_help be optional?  Then
some of the changes, like the one above, would not be needed.  It could
also change from using args to using an optional final param:

    proc test_class_help {command_class expected_initial_lines {list_of_commands {}} {test_name {}}} {

Then at the end instead of eval it could just make a direct call:

-    eval [list help_test_raw "help ${command_class}" $l_entire_body] $args
+    help_test_raw "help ${command_class}" $l_entire_body $test_name

To make this work, the help_test_raw change would have to be made.

Philippe> +# Like test_class_help but specialised to test "help user-defined".
Philippe> +proc test_user_defined_class_help { list_of_commands args } {
Philippe> +    test_class_help "user-defined" {
Philippe> +	"User-defined commands\.[\r\n]+"
Philippe> +	"The commands in this class are those defined by the user\.[\r\n]+"
Philippe> +	"Use the \"define\" command to define a command\.[\r\n]+"
Philippe> +    } $list_of_commands [list $args]
Philippe> +    # Unclear why, but if [list $args] is rather $args, the above is tested
Philippe> +    # but gives no PASS message (but gives a FAIL message if it fails) ???

With those changes you could make an optional name parameter here,
and then remove the [list] and the comment.

Tom



More information about the Gdb-patches mailing list