Skip to content

Conversation

@foreverallama
Copy link
Contributor

Added a try-catch block for load_subsys!() and load_mcos_object(). Any errors caught will log a warning and return raw metadata instead. This could work as a fix towards #219

Added test cases for both v7 and v7.3 formats:

  • corrupted_subsystem.mat contains an unsupported FileWrapper version (v5) which should throw an error.
  • corrupted_mcos_object_metadata.mat contains an object ID that does not exist in subsystem which should lead to a BoundsError.

It would be a good idea to test for the specific warning message but I couldn't figure out how to do that with @test_logs

@matthijscox
Copy link
Member

Second argument in the test logs tuple should be the message:

julia> @test_logs (:warn,) begin @warn "boo" end

julia> @test_logs (:warn,"boo") begin @warn "boo" end

julia> @test_logs (:warn,"moo") begin @warn "boo" end
Log Test Failed at REPL[7]:1

@foreverallama
Copy link
Contributor Author

I think that looks for an exact match? I'm logging the actual error as well with the warning message. Should I paste the whole error message or can I look for a partial match instead?

@matthijscox
Copy link
Member

matthijscox commented Dec 10, 2025

I normally indeed just match the whole warning message... never tried to insert a regex. Should work according to docstring of @test_logs: "Regexs in the pattern will match string or Symbol fields using occursin."

Seems so:

julia> @test_logs (:warn,r"^bo") begin @warn "boo" end

julia> @test_logs (:warn,r"^mo") begin @warn "boo" end
Log Test Failed at REPL[11]:1

@foreverallama
Copy link
Contributor Author

The regex worked, thanks!

@matthijscox
Copy link
Member

okay, looks good, merging

@matthijscox matthijscox merged commit f845dee into JuliaIO:master Dec 10, 2025
8 checks passed
@foreverallama foreverallama deleted the skipmcos branch December 10, 2025 17:16
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