Skip to content

Fix race in test_lookup_path[config-cppcheck.cfg] - #9074

Open
pfultz2 wants to merge 1 commit into
cppcheck-opensource:mainfrom
pfultz2:lookup-tests-data-race
Open

pfultz2 wants to merge 1 commit into
cppcheck-opensource:mainfrom
pfultz2:lookup-tests-data-race

Conversation

@pfultz2

@pfultz2 pfultz2 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

test_lookup_path[config-cppcheck.cfg] writes cppcheck.cfg next to the shared cppcheck executable and removes it after the run. Since test/cli runs with -n auto, tests running in parallel can see that file. In https://github.com/cppcheck-opensource/cppcheck/actions/runs/45492568404/job/138794456108 helloworld_test.py::test_addon_absolute_path found the file, but it was removed before it could be opened, so it failed with could not load cppcheck.cfg - could not open file.

@pfultz2
pfultz2 requested a review from danmar November 25, 2026 21:40
@danmar

danmar commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

test_lookup_path[config-cppcheck.cfg] fails on both Windows release jobs (windows-2022 and windows-2025). The failure looks deterministic, not flaky:

expected: looking for '<tmpdir>/bin/cppcheck.cfg'
actual:   looking for 'D:/a/cppcheck/cppcheck/cppcheck.cfg'
          no configuration found

The test starts the original cppcheck.exe instead of the copy in <tmpdir>/bin. I think this is because on Windows, subprocess.Popen with a bare cppcheck goes through CreateProcess. It searches the parent process's own directories (including its current directory, D:\a\cppcheck\cppcheck, which contains cppcheck.exe) before any PATH, and it doesn't use the env/cwd passed to the child. So adding <tmpdir>/bin to the front of PATH has no effect there.

A possible fix: pass the full path of the copied executable as cppcheck_exe (at least on Windows) instead of relying on the PATH lookup.

Logs: https://github.com/cppcheck-opensource/cppcheck/actions/runs/45706442310/job/144259399218

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants