Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo miri test no longer correctly detects tests #479

Closed
apoelstra opened this issue Oct 15, 2018 · 8 comments
Closed

cargo miri test no longer correctly detects tests #479

apoelstra opened this issue Oct 15, 2018 · 8 comments
Labels
C-bug Category: This is a bug.

Comments

@apoelstra
Copy link
Contributor

Since rust-lang/rust#53410 the #[test] attribute has become a macro and is not visible in the HIR as an attribute. This means that the code detecting test cases never triggers so any #[test]-labeled functions are ignored.

CI passes because the effect of this is that the tests simply aren't run, so of course they don't fail :).

I am investigating the effects of the compiler PR. Empirically it looks like functions that used to have a test attribute in the HIR now have a main attribute, but I'm not sure if that's happening on purpose and if that's the correct way for us to detect test cases now.

@apoelstra
Copy link
Contributor Author

After running with #482 I see that unit tests in libraries don't have the main attribute on them. In fact they have no attributes at all :(

@RalfJung
Copy link
Member

Somehow the test binary has to work, find the tests, run them. How does it do that?

@apoelstra
Copy link
Contributor Author

It looks like it looks for the rustc_test_marker attribute but for some reason in my debug dumps I didn't see this.Maybe it's on a different item than the function itself or something? Maybe it's lost going from AST -> HIR (doesn't sound plausible). I will investigate.

@apoelstra
Copy link
Contributor Author

Ah, yep, the rustc_test_marker attribute is applied to a new item with type that looks like Const(type(test::TestDescAndFn), BodyId { node_id: NodeId(16081) }), rather than something like Fn(FnDecl).

@apoelstra
Copy link
Contributor Author

The TestDescAndFn type is defined here: https://github.com/rust-lang/rust/blob/master/src/libtest/lib.rs#L239-L243

Its second field is an enum, which for ordinary test cases is equal to TestFn::StaticTestFn(func), and we want to run the MIR of func. But I don't know how to extract it from any of these data structures without nesting a dozen if-statements pulling everything apart.

@RalfJung RalfJung added the C-bug Category: This is a bug. label Nov 17, 2018
@RalfJung
Copy link
Member

rust-lang/rust#56243 makes some progress towards this: We still run into rust-lang/rust#54957, but other than that, we can actually run the libtest harness in miri.

@Gankra
Copy link
Contributor

Gankra commented Nov 27, 2018

Can you just disable the btree-breaking check for a bit?

@RalfJung
Copy link
Member

That would mean disabling Stacked Borrows. One can run with -Zmiri-disable-validation to achieve that, but then also miri checks way fewer things than it should check.

I can try disabling it inside the BTree module (there's a whiteliist), but that could fail to work because it means references created by BTree are not properly tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants