Hi Dave, On 21/11/05 09:23AM, David Malcolm wrote: > On Fri, 2021-11-05 at 10:38 +0100, cohenarthur.dev via Gcc wrote: > > Hi everyone, > > > > We have been trying to enable the use of selftests for the rust > > frontend > > over at gccrs. While doing this, I have realized that a few tests from > > language-independant source files such as `opt-problem.c` and > > `diagnostic.c` actually rely on the compiler being a C one. > > > > For example, one test asserts multiple time that a dumped text actually > > contains the "int" keyword for type assertions, which is never present > > in gccrs's error messages. > > > > In order to enable the selftests, I have added the following line to > > our > > rust/Make-lang.in, amongs others: > > > > RUST_SELFTEST_FLAGS = -xr $(SELFTEST_FLAGS) > > > > Passing -xc instead enables the opt-problem and diagnostic tests to > > pass, but causes our tests to not run. Passing -xrs causes our tests to > > run, but the opt-problem and diagnostic selftests to fail. > > > > Any idea as to how to disable those tests? Or make it so that they are > > only ran when running C/C++ selftests? > > If a selftest should only be run for a given language, there's a > langhook called by selftest::run_tests: > > /* Run any lang-specific selftests. */ > lang_hooks.run_lang_selftests (); > > which e.g. the C frontend implements in gcc/c/c-lang.c as: > > #if CHECKING_P > #undef LANG_HOOKS_RUN_LANG_SELFTESTS > #define LANG_HOOKS_RUN_LANG_SELFTESTS selftest::run_c_tests > #endif /* #if CHECKING_P */ > > which currently merely calls > c_family_tests (); > which is defined in gcc/c-family/c-common.c > > So the invocation of c-family-specific tests could be moved to there > (or to the appropriate locations for C/C++ tests), splitting things up > as appropriate based on how much of each file's selftest suite is lang- > specific.
That's a very nice idea, thanks a lot. I did not think of it. > If it's just one assert within a larger selftest that's problematic, > maybe we can conditionalize it individually, though I'm not sure of a > good way to do that off the top of my head. It sadly is one assert through a big test, but I believe that the whole test is not really language specific: It tries to parse a `test.c` file, tries to assert some loop optimization failures, and so on. I personally think it should be moved to C and C++ specific tests. I'm assuming it was put those files so that both frontends would try and pass them, as no other frontend uses the selftest framework. Thanks a lot for the answer, this is very helpful