Skip to content

Run the unit tests on Linux, macOS and Windows - #99

Merged
Arcadia-1 merged 1 commit into
mainfrom
cross-platform-unit-tests
Sep 17, 2026
Merged

Arcadia-1 merged 1 commit into
mainfrom
cross-platform-unit-tests

Conversation

@Arcadia-1

Copy link
Copy Markdown
Owner

The crash: python/tests/unit/test_matlab_test_runner.py faked Windows with monkeypatch.setattr(runner.os, "name", "nt"). runner.os is the global os module, so pathlib also switched to WindowsPath, which cannot be instantiated on macOS or Linux. The next Path(...) raised. pytest then crashed with an INTERNALERROR while formatting that failure, which stopped the whole tests/unit run.

The fix:

  • matlab/tests/run_matlab_tests.py gets _is_windows(), and its two os.name == "nt" checks use it.
  • The tests patch runner._is_windows instead of os.name, so the Windows branch is exercised on every platform.
  • Two new tests cover the Windows path on any OS:
    • install candidates under %ProgramFiles%\MATLAB come newest release first;
    • .cmd/.bat files are accepted, and .exe files only with a real PE signature.

CI: until now CI ran only tests/unit/models, spectrum and oversampling, and only on Ubuntu. A new unit-tests job runs all of tests/unit on ubuntu-latest, macos-latest and windows-latest (fail-fast: false). The three partial steps are removed from the examples job, and the example runs are unchanged.

Tested: locally on macOS (Python 3.11), pytest tests/unit gives 892 passed, 1 xfailed; before this change it aborted. Windows is checked only by this PR's CI.

🤖 Generated with Claude Code

test_matlab_test_runner faked Windows by setting os.name to "nt". That also
switches pathlib to WindowsPath, which cannot be created anywhere else, so on
macOS and Linux the next Path() raised, and pytest crashed while reporting it,
taking the whole unit run down with it. The runner now asks _is_windows(),
which the tests patch instead, and two new tests cover the Windows install
search and the Windows executable check on any platform.

CI ran only the models, spectrum and oversampling unit tests, on Ubuntu. It now
runs all of tests/unit on Ubuntu, macOS and Windows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Arcadia-1
Arcadia-1 merged commit 8d62fb1 into main Sep 17, 2026
4 checks passed
@Arcadia-1
Arcadia-1 deleted the cross-platform-unit-tests branch September 17, 2026 10:37
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.

1 participant