Skip to content

run_tests.py fails on windows, but running tests individually works #453

Open

Description

@kaosmaja

Platform: Windows
In README.md, the instructions say to use python3 run_tests.py --output ./test --dir ./build/cpp --config test_args.json

But this fails on windows, here is a minimal example:

> python run_tests.py --output .\test\ --dir .\build\cpp\0_Introduction\clock\Release\ --config test_args.json
Detected 1 GPU(s).
Found 1 executables
Running tests with up to 1 parallel tasks
-----------------------------------------

Starting clock.exe
    Command (clock.exe ): ./clock.exe
Error running clock.exe : [WinError 2] The system cannot find the file specified
Progress: 1/1 runs completed.

Test Summary:
Ran 1 test runs for 1 executables.
Failed runs (1):
  clock.exe : Error: [WinError 2] The system cannot find the file specified (code -1)

versus:

> .\build\cpp\0_Introduction\clock\Release\clock.exe
CUDA Clock sample
GPU Device 0: with compute capability 7.5 and Number of SMs 16

Average clocks/block = 1531.671875

Activity

  1. Gauravkachwaha commented on Nov 13, 2026

    @Gauravkachwaha

    Proposed fix for running CUDA samples on Windows

    The runner finds clock.exe correctly, but fails when it tries to start it. Since the same executable runs successfully when called directly, the failure points to how run_tests.py launches the sample.

    The current code builds the command as ./clock.exe and passes the executable's directory as cwd. On Windows, with the default shell=False, cwd sets the child process's working directory but does not change where Python looks for the executable. This explains the [WinError 2] failure when running the script from the repository root.

    The Python subprocess documentation describes this behavior and recommends using a fully qualified executable path.

    Suggested change

    I suggest resolving the executable to an absolute path and using that path as the first command argument:

    --- a/run_tests.py
    +++ b/run_tests.py
    @@ -95,2 +95,2 @@
    -    exe_path = str(executable)
    +    exe_path = os.path.abspath(executable)
         exe_name = executable.name
    @@ -101 +101 @@
    -        cmd = [f"./{exe_name}"]
    +        cmd = [exe_path]

    Keep the existing cwd=os.path.dirname(exe_path) so samples can still load resources relative to their executable directory. The command should also remain a list, which lets Python handle paths containing spaces.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions