diff options
author | CohenArthur <arthur.cohen@epita.fr> | 2021-10-19 10:46:45 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@epita.fr> | 2022-02-05 16:02:47 +0100 |
commit | 2b1345a73654cf5b2b13e334813ee97016ba5d1a (patch) | |
tree | bda96cd6477b3050f15283220cff1de675fc39c4 /gcc | |
parent | 83bfbf0746c87b641754697a3c8e9f7a7cb08aa9 (diff) | |
download | gcc-2b1345a73654cf5b2b13e334813ee97016ba5d1a.zip gcc-2b1345a73654cf5b2b13e334813ee97016ba5d1a.tar.gz gcc-2b1345a73654cf5b2b13e334813ee97016ba5d1a.tar.bz2 |
selftest: Enable unit testing for the rust frontend
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/Make-lang.in | 13 | ||||
-rw-r--r-- | 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 659c5b9..d2f7962 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 a0f14d4..fbab9b1 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; |