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

Any plans to support "compile-fail" tests? #521

Closed
japaric opened this issue Sep 6, 2014 · 10 comments
Closed

Any plans to support "compile-fail" tests? #521

japaric opened this issue Sep 6, 2014 · 10 comments

Comments

@japaric
Copy link
Member

japaric commented Sep 6, 2014

Like the ones in the rust repository

These kind of tests are useful if you are creating data structures from scratch (with raw pointers in it) and you want to make sure you added the proper markers (ContravariantLifetime!) to them. For example:

let outlive = {
    let v = vec![0i, 1, 2, 3, 4];
    v.step_slice(0, 3, 2)  //~ ERROR: `v` does not live long enough
};

Could be a compile-fail test that checks that a view doesn't outlives its "parent".

Also, this feature would help to build rust with cargo.

So, is anything like this in scope for cargo?

(Slighty on topic: Anyone knows if the rust test suite checks that the //~ ERROR: patterns match the compiler output on each test, or simply checks that the compilation failed?)

@sfackler
Copy link
Member

sfackler commented Sep 6, 2014

It checks the text of the //~ ERROR patterns.

cc rust-lang/rust#12335

@japaric
Copy link
Member Author

japaric commented Sep 6, 2014

I didn't know about compiletest. I finally got it to work (after figuring out what flags it needed), and it's really nice. I'd be great if cargo could use it (i.e. feed it with the proper flags) to check compile-fail tests under a tests/compile-fail directory.

@tomjakubowski
Copy link
Contributor

This is also nice to have to writing compiler plugins / syntax extensions.

@alexcrichton
Copy link
Member

I've personally always wanted these as well! (and I know many others have as well). I think the easiest way forward on this is something like rust-lang/rust#12335 (as @sfackler mentioned).

@sfackler
Copy link
Member

sfackler commented Sep 7, 2014

@alexcrichton do you think the right way forward there would be to distribute compiletest through the main rustc distribution? We could also potentially mirror it in a separate repo and have that pulled in via cargo.

@sfackler
Copy link
Member

sfackler commented Sep 7, 2014

(I ask because it seems like a bit of a niche thing to install everywhere that rustc is).

@alexcrichton
Copy link
Member

We probably don't want to distribute it into everyone's PATH, but if it were distributed into lib/rustlib/bin or something like that it may not be so bad to ship by default.

@alexcrichton
Copy link
Member

I'd rather not pull it in specially into cargo because it's dynamically linked and for now tied to exactly one rustc distribution.

@andrew-d
Copy link

andrew-d commented Sep 8, 2014

Funny enough, I was just getting this to work yesterday. Here's what I ended up with. Would agree that this would be very nice to include in Cargo.

@alexcrichton
Copy link
Member

Closing in favor of rust-lang/rust#12335 as this will pretty much hinge on that if we're going to take this route.

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

No branches or pull requests

5 participants