public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: handle errors better in test_compiler_info Date: Thu, 9 Jun 2022 13:41:30 +0000 (GMT) [thread overview] Message-ID: <20220609134130.E732B383A33D@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0e471fde0742bbbc8e34f0d082d1b35c19aee96f commit 0e471fde0742bbbc8e34f0d082d1b35c19aee96f Author: Andrew Burgess <aburgess@redhat.com> Date: Wed Jun 8 14:04:36 2022 +0100 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. Diff: --- gdb/testsuite/lib/gdb.exp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e530ba05a61..e28c33e8455 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -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] {
reply other threads:[~2022-06-09 13:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220609134130.E732B383A33D@sourceware.org \ --to=aburgess@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).