[UNVERIFIED-needs-MATLAB] test: skip MATLAB runtime tests when no MATLAB is installed#76
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
Conversation
The runtime ODE-solving block in test/runtests.jl unconditionally called solve(prob, MATLABDiffEq.ode45()), which opens a MATLAB engine session. When no MATLAB is installed (e.g. CI without a license), MATLAB.jl is built with dummy deps (libmx_size == 0) and __init__ never binds the engine function pointers, so get_default_msession() -> MSession() -> ccall(eng_open[], ...) throws `UndefRefError: access to undefined reference`. This errored the whole test suite even though the interface and static-analysis tests passed. Gate the runtime tests on MATLAB.libmx_size > 0 (the same flag MATLAB.jl uses to decide whether to load the native libraries). When MATLAB is present the tests run for real with added @test assertions on the returned solution; when absent they are skipped with an informative @info message. The non-MATLAB interface/JET tests always run. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
On
master,test/runtests.jl(lines 12-44) unconditionally ran the runtime ODE-solving tests:solvereaches__solveatsrc/MATLABDiffEq.jl:118, which callsput_variable(get_default_msession(), ...).get_default_msession()constructs aMATLAB.MSession, which doesccall(eng_open[], ...)(MATLAB/engine.jl:48).When no MATLAB is installed (every CI runner here, since there is no MATLAB license), MATLAB.jl is built with dummy deps (
libmx_size == 0, the documented CI/AutoMerge path in MATLAB.jl'sdeps/build.jl). Withlibmx_size == 0, MATLAB.jl's__init__deliberately skips binding all the engine/mxarray function-pointerRefs (if libmx_size > 0 ... end). Soeng_open[]is an unassignedRef{Ptr{Cvoid}}, and dereferencing it throws:This is not a MATLAB.jl API regression and not a ModelingToolkit v11 glue bug: the
modelingtoolkitize+build_function(::MATLABTarget())code generation at lines 107-115 runs fine on ModelingToolkit v11.26.8 / Symbolics v7.26.0. The failure is solely that the suite tries to open a MATLAB engine that does not exist.Fix
Gate the runtime ODE-solving tests on a real MATLAB being present, using
MATLAB.libmx_size > 0— the exact flag MATLAB.jl itself uses to decide whether to load its native libraries. When MATLAB is present the tests run for real (now with explicit@testassertions on the returned solution, which the old code lacked). When absent, they are skipped with an informative@infomessage. The MATLAB-free interface and JET/static-analysis tests always run.No assertions were loosened, skipped,
@test_broken-ed, or wrapped in error-swallowingtry/catch. The runtime tests are gated on a genuine environment-capability flag, not silenced.What was verified
Reproduced and fixed locally with an isolated depot on Julia 1.10.11, with
CI=trueso MATLAB.jl builds the dummy deps exactly as on CI (no MATLAB on the machine).master(reproduction): suite errors attest/runtests.jl:20withUndefRefError(matches the failing CI logs). Interface (40/40) and Static Analysis (38/38) testsets passed before the error.What could NOT be verified
There is no MATLAB on this machine, so the
HAS_MATLAB == truebranch (the actual ODE solves and their new assertions) was not executed. That path is unchanged in behavior from the original tests aside from the added@tests; it still needs a run on a machine with a MATLAB license to confirm end-to-end. Marking this PRUNVERIFIED-needs-MATLABfor that reason.Runic: ran the Runic.jl formatter on
test/runtests.jl(already formatted, no changes).🤖 Generated with Claude Code