Skip to content

Fix run_tests.py failing on Windows due to relative executable paths - #464

Open
rjmcgee53192 wants to merge 1 commit into
NVIDIA:masterfrom
rjmcgee53192:contrib/fix-453
Open

rjmcgee53192 wants to merge 1 commit into
NVIDIA:masterfrom
rjmcgee53192:contrib/fix-453

Conversation

@rjmcgee53192

Copy link
Copy Markdown

Fix run_tests.py failing on Windows due to relative executable paths (fixes #453)

Problem

On Windows, run_tests.py builds the test command as a POSIX-style
relative path:

cmd = [f"./{exe_name}"]   # e.g. "./clock.exe"

That relative path does not resolve on Windows, so every test fails —
while running the same binaries individually (e.g. double-clicking or
typing the name in a shell) works fine. Reported in issue #453.

Fix

  • Added build_test_command() in run_tests.py, which constructs the
    command from the executable's absolute, OS-native path via
    pathlib (str(Path(executable).resolve())). This resolves correctly
    on every platform.
  • run_single_test_instance() now uses this helper for the argv, and the
    cwd it passes to subprocess.run is also absolute (the executable's
    own directory, as before — unchanged behavior, since some samples
    depend on relative asset paths).
  • Argument forwarding (args, global_args) and the status mapping
    (Passed / Waived / Failed / Timeout / Error) are unchanged.

Tests

New unit test module test_run_tests.py (no GPU, toolkit, or build
required — runs anywhere with Python 3):

$ python3 -m unittest test_run_tests -v
...
Ran 11 tests in 0.044s
OK

Coverage: absolute-path construction (absolute and relative inputs),
no ./ prefix regression check, string/Path inputs, subprocess receiving
the absolute path with the executable's directory as cwd, argument
forwarding, status-code mapping, timeout, and unexpected-error handling.

Honest note

This was developed on Linux — on-Windows execution of the harness was
not possible on this machine, so the fix is verified by unit tests and
code review, not by a Windows run. A maintainer running
python run_tests.py --output ./test --dir ./build/cpp --config test_args.json
on Windows would be the real confirmation that #453 is closed.

Invoke each test executable via its absolute, OS-native path instead of a
POSIX-style relative path ('./name.exe'), which does not resolve on
Windows. The executable is still run with its own directory as the working
directory. Adds unit tests covering the path-construction logic.
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.

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

1 participant