Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Filesystem functions behave differently in unit tests #7824

Open
rzblue opened this issue Feb 25, 2025 · 0 comments
Open

C++ Filesystem functions behave differently in unit tests #7824

rzblue opened this issue Feb 25, 2025 · 0 comments
Labels
component: wpilibc WPILib C++ type: bug Something isn't working.

Comments

@rzblue
Copy link
Member

rzblue commented Feb 25, 2025

In sim, GetLaunchDirectory, GetOperatingDirectory, and GetDeployDirectory return correctly:

launch: c:\Path\To\Project
operating: c:\Path\To\Project
deploy: c:\Path\To\Project\src\main\deploy

In unit tests, they return directories in the build directory:

launch: c:\Path\To\Project\build\test-results\frcUserProgramTest\windowsx86-64\release
operating: c:\Path\To\Project\build\test-results\frcUserProgramTest\windowsx86-64\release
deploy: c:\Path\To\Project\build\test-results\frcUserProgramTest\windowsx86-64\release\src\main\deploy

Looks like gradle sets the working directory to \build\test-results\frcUserProgramTest\{platform}\{buildType}.

Setting the working directory to the 5th parent directory in unit tests appears to work as a workaround:

std::error_code ec;
std::filesystem::current_path(std::filesystem::current_path().parent_path().parent_path().parent_path().parent_path().parent_path(), ec);
@rzblue rzblue added type: bug Something isn't working. component: wpilibc WPILib C++ labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpilibc WPILib C++ type: bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant