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

// run-pass UI test header does not work with extern crate #3924

Closed
phansch opened this issue Apr 7, 2019 · 2 comments
Closed

// run-pass UI test header does not work with extern crate #3924

phansch opened this issue Apr 7, 2019 · 2 comments

Comments

@phansch
Copy link
Member

phansch commented Apr 7, 2019

I'm trying to create a failing test for #3741 where I have to depend on an external proc-macro crate. The test itself looks like this:

// aux-build:proc_macro_crash.rs
// run-pass

#![feature(proc_macro_hygiene)]

extern crate proc_macro_crash;
use proc_macro_crash::macro_test;

fn main() {
    macro_test!(2);
}

In tests/ui/crashes/auxiliary/proc_macro_crash.rs I have:

// no-prefer-dynamic

#![feature(repr128)]
#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use std::iter::FromIterator;

#[proc_macro]
pub fn macro_test(input_stream: TokenStream) -> TokenStream {
    let first_token = input_stream.into_iter().next().unwrap();
    let span = first_token.span();

    TokenStream::from_iter(vec![
        TokenTree::Ident(Ident::new("fn", Span::call_site())),
        TokenTree::Ident(Ident::new("code", Span::call_site())),
        TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
        TokenTree::Group(Group::new(Delimiter::Brace, {
            let mut clause = Group::new(Delimiter::Brace, TokenStream::new());
            clause.set_span(span);

            TokenStream::from_iter(vec![
                TokenTree::Ident(Ident::new("if", Span::call_site())),
                TokenTree::Ident(Ident::new("true", Span::call_site())),
                TokenTree::Group(clause.clone()),
                TokenTree::Ident(Ident::new("else", Span::call_site())),
                TokenTree::Group(clause.clone()),
            ])
        })),
    ])
}

However, when I run the test using TESTNAME=ui/crashes/ice-3741 cargo uitest, I get the following error:

thread '[ui] ui/crashes/ice-3741.rs' panicked at 'failed to exec `"/home/phansch/code/rust-clippy/target/debug/test_build_base/crashes/ice-3741.stage-id"`: Os {
 code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:997:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.                   
stack backtrace:                                     
   <snip unwind stuff>                                                  
   7: core::panicking::panic_fmt            
             at src/libcore/panicking.rs:85                                                    
   8: core::result::unwrap_failed                                        
             at /rustc/dec0a98c4b392b5fd153ba8b944c496218717813/src/libcore/macros.rs:18 
   9: core::result::Result<T,E>::expect
             at /rustc/dec0a98c4b392b5fd153ba8b944c496218717813/src/libcore/result.rs:825
  10: compiletest_rs::runtest::TestCx::compose_and_run
             at /home/phansch/.cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.3.19/src/runtest.rs:1359
  11: compiletest_rs::runtest::TestCx::exec_compiled_test                              
             at /home/phansch/.cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.3.19/src/runtest.rs:1228
  12: compiletest_rs::runtest::TestCx::run_ui_test
             at /home/phansch/.cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.3.19/src/runtest.rs:2312

The test passes without run-pass and also works when no extern crate is used, so maybe the auxiliary dependency is not passed through to the rustc command triggered by compiletest?

cc @oli-obk because you mentioned once on Discord that you think this can probably be fixed in Clippy?

@phansch
Copy link
Member Author

phansch commented Apr 7, 2019

I can confirm that it works in a default compiletest setup, so this probably not an issue in compiletest-rs but in Clippy.

@phansch
Copy link
Member Author

phansch commented Apr 7, 2019

Oh, I think this may be because the test doesn't even compile, because it's not meant to compile currently. If it's doesn't compile, using run-pass rightfully says that the compiled file could not be found.

@phansch phansch closed this as completed Apr 7, 2019
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

1 participant