WPILib test folder not included as part of project?

Essentially what I think is happening is that the WPILib gradle/intellisense is somehow not processing files in the src/test/cpp folder. What first tipped me off to this is that for any files in this folder, intellisense reports it cannot open any WPILib specific files. It can find normal c++ files (although the browse path from the test folder finds them in the base /usr/include/c++/7 driectory, rather than in the one contained by wpilib/2022/roborio/arm-frc2022-linux-gnueabi (for context I am using linux). It can also include files from other parts of the project, such as Robot.h. Basically it behaves exactly as though I had opened another c++ folder in VSCode that isn’t part of a WPILib project.

Additionally, when I try to induce a compile time error (such as by setting an integer equal to a string, ./gradlew build compiles with no errors. The output of ./gradlew check does include frUserProgramTest:cpp as a source, but the output of ./gradlew build -console verbose does not. When I try ./gradlew check -console verbose, it shows frcUserProgramTest:cpp as a source but doesn’t look to check it as a task (see below).

When I try to build a specific file with ./gradlew --build-file src/test/cpp/main.cpp, I get a compiler error that says the ā€˜#’ character in #include is an ā€œunexpected characterā€. The line it errors on is the same as the first include statement, which does imply the test/cpp/main.cpp file is being, read, but clearly it is not being parsed correctly. I don’t know what to make of that, and gradle does say this feature is deprecated so maybe that’s the problem; I just figured I’d include this in case it means anything.

I have tried re-installing WPILib several times and still run into the same problem. I tried this on my teammate’s computer and he has the same issue as well.

If anyone knows anything about this issue, or if there’s something extra I’m supposed to do to set up the test environment that I don’t know about (I have enabled desktop support) please let me know!

Test sources are compiled and run on the local machine, so it will use the desktop compiler and include files rather than the ARM ones (which are used only to cross-compile the robot program that is deployed to the robot, not run locally). For intellisense, there is a setting in the bottom toolbar which is what toolchain/target is being used. You will need to switch that manually from ā€œlinuxathenaā€ to a different setting (probably linux desktop?) to get intellisense to pick up WPILib files.

Does your project have desktop support enabled?

As Peter said above, tests are only supported on desktop, and you don’t have desktop support enabled. Once you enable it, you get a prompt asking you if you want to refresh intellisense. Click yes to that. If you miss the prompt, or click no, theres a command in the command palette to refresh c++ intellisense. Once you do that, you’ll then have to change the mode by clicking the linuxathena button at the bottom and changing to linuxx64. You click the same button and select linuxathena to switch back to the roboRIO for intellisense.

Yes, changing the toolchain fixed it! Thank you so much :slight_smile:

Hey, I’m back. I’ve gotten a new Windows computer and am having a similar problem (files in test/cpp folder aren’t being built). I do have desktop support enabled, but this time I only have linuxathena toolchains to select from (debug/release, neither work). Is there a native windows c++ toolchain that I’m supposed to be able to find and add somehow? Or something else I’m supposed to do? Thanks so much.

Yes, you need to install Visual Studio 2019 or 2022 to build C++ for simulation on Windows.

1 Like

Must have missed this. Thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.