public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] selftest: Enable unit testing for the rust frontend
@ 2022-06-08 12:04 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:04 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2b1345a73654cf5b2b13e334813ee97016ba5d1a
commit 2b1345a73654cf5b2b13e334813ee97016ba5d1a
Author: CohenArthur <arthur.cohen@epita.fr>
Date: Tue Oct 19 10:46:45 2021 +0200
selftest: Enable unit testing for the rust frontend
Diff:
---
gcc/rust/Make-lang.in | 13 ++++++++++---
gcc/rust/rust-lang.cc | 24 ++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 659c5b9a1a1..d2f796269f9 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -209,8 +209,16 @@ rust.uninstall:
-rm -f $(RUST_ALL_OBJS)
# ^those two are a maybe
-# No rust-specific selftests
-selftest-rust:
+# Enable selftests for the rust frontend
+selftest-rust: s-selftest-rust
+
+RUST_SELFTEST_FLAGS = -xrs $(SELFTEST_FLAGS)
+RUST_SELFTEST_DEPS = rust1$(exeext) $(SELFTEST_DEPS)
+
+# Run the rust selftests
+s-selftest-rust: $(RUST_SELFTEST_DEPS)
+ $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS)
+ $(STAMP) $@
# Install info documentation for the front end, if it is present in the source directory. This target
# should have dependencies on info files that should be installed.
@@ -319,4 +327,3 @@ rust/%.o: rust/typecheck/%.cc
rust/%.o: rust/lint/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
-
diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc
index a0f14d405aa..fbab9b1d778 100644
--- a/gcc/rust/rust-lang.cc
+++ b/gcc/rust/rust-lang.cc
@@ -32,6 +32,7 @@
#include "convert.h"
#include "langhooks.h"
#include "langhooks-def.h"
+#include "selftest.h"
#include <mpfr.h>
// note: header files must be in this order or else forward declarations don't
@@ -434,6 +435,29 @@ rust_localize_identifier (const char *ident)
#define LANG_HOOKS_GIMPLIFY_EXPR grs_langhook_gimplify_expr
#define LANG_HOOKS_EH_PERSONALITY grs_langhook_eh_personality
+#if CHECKING_P
+
+#undef LANG_HOOKS_RUN_LANG_SELFTESTS
+#define LANG_HOOKS_RUN_LANG_SELFTESTS selftest::run_rust_tests
+
+namespace selftest {
+
+static void
+simple_assert ()
+{
+ ASSERT_TRUE (true);
+}
+
+void
+run_rust_tests ()
+{
+ // Call tests for the rust frontend here
+ simple_assert ();
+}
+} // namespace selftest
+
+#endif /* !CHECKING_P */
+
// Expands all LANG_HOOKS_x of GCC
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:04 [gcc/devel/rust/master] selftest: Enable unit testing for the rust frontend Thomas Schwinge
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).