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. 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. Hope this is helpful Dave