gdb/testsuite: handle errors better in test_compiler_info

Now that get_compiler_info might actually fail (if the language is not
handled), then we should try to handle this failure better in
test_compiler_info.

After this commit, if get_compiler_info fails then we will return a
suitable result depending on how the user called test_compiler_info.

If the user does something like:

  set version [test_compiler_info "" "unknown-language"]

Then test_compiler_info will return an empty string.  My assumption is
that the user will be trying to match 'version' against something, and
the empty string hopefully will not match.

If the user does something like:

  if { [test_compiler_info "some_pattern" "unknown-language"] } {
    ....
  }

Then test_compiler_info will return false which seems the obvious
choice.

There should be no change in the test results after this commit.
This commit is contained in:
Andrew Burgess
2022-06-08 14:04:36 +01:00
parent 08b326ee0a
commit 0e471fde07

View File

@ -4199,7 +4199,17 @@ proc get_compiler_info {{language "c"}} {
proc test_compiler_info { {compiler ""} {language "c"} } {
global compiler_info
get_compiler_info $language
if [get_compiler_info $language] {
# An error will already have been printed in this case. Just
# return a suitable result depending on how the user called
# this function.
if [string match "" $compiler] {
return ""
} else {
return false
}
}
# If no arg, return the compiler_info string.
if [string match "" $compiler] {