From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Introduce rust_at_least helper proc
Date: Wed, 1 Mar 2023 13:25:38 -0700 [thread overview]
Message-ID: <20230301202538.3291371-1-tromey@adacore.com> (raw)
This adds a 'rust_at_least' helper proc, for checking the version of
the Rust compiler in use. It then changes various tests to use this
with 'require'.
---
gdb/testsuite/gdb.rust/rawids.exp | 8 +-------
gdb/testsuite/gdb.rust/unicode.exp | 8 +-------
gdb/testsuite/gdb.rust/unsized.exp | 5 +----
gdb/testsuite/lib/rust-support.exp | 11 +++++++++++
4 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp
index 976b723833e..8b7db877328 100644
--- a/gdb/testsuite/gdb.rust/rawids.exp
+++ b/gdb/testsuite/gdb.rust/rawids.exp
@@ -16,13 +16,7 @@
# Test raw identifiers.
load_lib rust-support.exp
-require allow_rust_tests
-
-set v [split [rust_compiler_version] .]
-if {[lindex $v 0] == 1 && [lindex $v 1] < 30} {
- untested "raw identifiers require rust 1.30 or greater"
- return -1
-}
+require allow_rust_tests {rust_at_least 1 30}
standard_testfile .rs
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp
index 2b4766b5553..c2bc0ef960f 100644
--- a/gdb/testsuite/gdb.rust/unicode.exp
+++ b/gdb/testsuite/gdb.rust/unicode.exp
@@ -16,14 +16,8 @@
# Test raw identifiers.
load_lib rust-support.exp
-require allow_rust_tests
-
# Non-ASCII identifiers were allowed starting in 1.53.
-set v [split [rust_compiler_version] .]
-if {[lindex $v 0] == 1 && [lindex $v 1] < 53} {
- untested "this test requires rust 1.53 or greater"
- return -1
-}
+require allow_rust_tests {rust_at_least 1 53}
# Enable basic use of UTF-8. LC_ALL gets reset for each testfile.
setenv LC_ALL C.UTF-8
diff --git a/gdb/testsuite/gdb.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp
index f81be8a3078..b3bd2d7d1c5 100644
--- a/gdb/testsuite/gdb.rust/unsized.exp
+++ b/gdb/testsuite/gdb.rust/unsized.exp
@@ -31,10 +31,7 @@ if {![runto ${srcfile}:$line]} {
gdb_test "ptype us" " = .*V<\\\[u8\\\]>.*"
-set v [split [rust_compiler_version] .]
-# The necessary debuginfo generation landed in 1.60, but had a bug
-# that was fixed in 1.61.
-if {[lindex $v 0] > 1 || [lindex $v 1] >= 61} {
+if {[rust_at_least 1 61]} {
gdb_test "print us2" " = .*Box<.*> \\\[1, 2, 3\\\]"
gdb_test "ptype us2" "type = .*"
}
diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp
index df517647ce9..c4a403732dc 100644
--- a/gdb/testsuite/lib/rust-support.exp
+++ b/gdb/testsuite/lib/rust-support.exp
@@ -112,3 +112,14 @@ gdb_caching_proc rust_compiler_version {
}
return 0.0
}
+
+# A helper that checks that the rust compiler is at least MAJOR.MINOR.
+# This is handy for use with 'require'.
+proc rust_at_least {major minor} {
+ set v [split [rust_compiler_version] .]
+ if {[lindex $v 0] < $major
+ || ([lindex $v 0] == $major && [lindex $v 1] < $minor)} {
+ return 0
+ }
+ return 1
+}
--
2.39.1
next reply other threads:[~2023-03-01 20:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 20:25 Tom Tromey [this message]
2023-03-03 18:38 ` Tom Tromey
2023-03-10 16:20 ` Tom de Vries
2023-03-10 16:56 ` Tom Tromey
2023-03-14 14:01 ` Tom Tromey
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=20230301202538.3291371-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@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: link
Be 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).