On 27-02-2020 17:02, Pedro Alves wrote: > On 2/21/20 3:35 PM, Tom de Vries wrote: > >> I think we don't want to integrate -lbl in the user_code parsing, because: >> ... >> gdb_test_multiple "command" "testname" { >> -re "bla" { >> } >> -lbl >> } >> ... >> and: >> ... >> gdb_test_multiple "command" "testname" { >> -lbl >> -re "bla" { >> } >> } >> ... >> will have the same effect, which is likely to cause confusion. > > Well: > > gdb_test_multiple "command" "testname" { > -re "bar" { > } > -timeout 60 > } > > and: > > gdb_test_multiple "command" "testname" { > -timeout 60 > -re "bla" { > } > } > > also have the same effect. So there's precedent and it goes > all the way back to expect. > Hm, I see. >> [gdb/testsuite] Add -lbl option in gdb_test_multiple >> >> Add gdb_test_multiple option -lbl, that adds a regexp after the user code that >> reads one line, and discards it: >> ... >> -re "\r\n\[^\r\n\]*(?=\r\n)" { >> exp_continue >> } >> ... >> >> In order to be able to write: >> ... >> gdb_test_multiple "command" "testname" { >> ... >> } -lbl >> ... >> as opposed to having to insert the "" for the prompt_regexp arguments: >> ... >> gdb_test_multiple "command" "testname" { >> ... >> } "" -lbl >> ... >> rewrite the promp_regexp argument usage into: >> ... >> gdb_test_multiple "command" "testname" { >> ... >> } -prompt $prompt_regexp >> ... > > Honestly, to me, this: > > gdb_test_multiple "command" "testname" { > ... > } -lbl -prompt $prompt_regexp > > looks a bit harder to grok than: > > gdb_test_multiple "command" "testname" { > -lbl > -prompt $prompt_regexp > ... > } > > ... because those options appear at the end, after the regexes. > > Alternatively, if you don't like the -lbl within the {} block, and if > we're going to use "-" options, how about supporting them before > the {} user code block, so that the user code block is always > at the end? Like: > > gdb_test_multiple "command" "testname" -lbl { > ... > } > > gdb_test_multiple "command" "testname" -prompt $prompt_regexp { > ... > } > > That should be doable with: > > -proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > +proc gdb_test_multiple { command message args } { > > and then walking the $args list, processing "-" arguments, and interpreting > the first non-"-" argument as the user code block (and erroring out if there > are more arguments). I think the gdb_test_multiple code would look quite similar > to your patch, except that the user_code parameter would no longer be a parameter, > instead it would be a local variable set to the first non-"-" element of $args. Yes, I like that suggestion. Implemented and attached below. OK for trunk. Thanks, - Tom