Hi all. In my spare time I've been thinking about how to update
cargo miri for the new test framework. We had been scanning functions for #[test] attributes and then running them, but now #[test] is a macro that puts a pointer to the actual test inside a
test::TestDescAndFn structure. see https://github.com/solson/miri/issues/479 . This means for miri to run it, it needs to pull the struct apart to find the function pointer then run that. with the existing APIs that i'm aware of, this is pretty difficult to do programmatically without deeply-nested matches or something
I wonder if I should work on some enormous syntax ext to allow creating (or manipulating, or matching)
Mir objects from a DSL, or if that's overkill. is there a simpler way?
Well.. we have https://github.com/solson/miri/issues/196#issuecomment-308560942 which suggests to give us the ability to generate MIR from code. An initial version could be a convenience function that takes a string and produces MIR that we then can interpret to take apart these constants in the desired way
Thanks Oli! If there are other uses for an ast-to-mir converter then I'll hack on it this weekend and see where I get
alternatively, why can't we compile the thing that would usually inspect the
TestDescAndFn and run that? I mean, rustc produces a binary interpreting that stuff, so there's MIR for it somewhere
We could - the thing is that it runs every test function in a row (like the old test runner) so it would be harder to emit the "Running test::whatever" diagnostics.
Well, the program itself will output diagnostics; but it would be harder for us to introspect and determine which test we were in the middle of
we'll need a libstd with MIR
but then printing to stdout/stderr should work
What about multithreading?
that won't work, but does that happen by default?