Conditionally skip blocks
talex5 opened this issue · comments
I'd like to skip certain blocks/sections, where the test is performed at runtime. For example, when running on macos in the opam sandbox we can't run any tests that use the network, and when running in a Docker container we might not be able to use IPv6.
Is there a good way to do this already?
If not, what's the best way to implement this? Perhaps if a block raises Mdx_skip
then it could just be ignored?
You mean, only correct the block unless it raises Mdx_skip? I wonder if this isn't adding functionality to MDX that would better be solved on another level, e.g. do not run the MDX test via dune in some conditions.
Yes. For example, oUnit has a skip_if
function that raises a special exception (https://github.com/gildor478/ounit/blob/master/src/lib/ounit2/advanced/oUnitAssert.ml#L37), and crowbar has a similar guard
function (https://github.com/stedolan/crowbar/blob/0cbe3ea7e990a7d233360e6a74b1cb5e712501ad/src/crowbar.ml#L93).
I don't think it can be solved easily with dune. For example, most of the Eio README file should still be tested by opam-repo-ci, just not the parts using the network when run on macos within the opam sandbox.