dtolnay/trybuild

test code that is a library instead of a bin

TomzBench opened this issue · 1 comments

hello,

i am using this library to test generated code but not via proc macros. just a library that outputs regular rust. My generated code is a library (therefore, no fn main() {}). My tests fail unless i stub in a fn main() {} somewhere to my generated code. but this is not ideal. For clearer picture, below is an example test case...

#[test]
fn test_render_lib() {
    let runner = trybuild::TestCases::new();
    render_lib("__generated__/default.rs", Options::default());
    runner.pass("__generated__/default.rs");
}

So you see, I do not write my actual files that I am testing, but I generate them. And rust is compiling this generated code as a binary. Is there a way to make the test case compile as a library?

I would prefer not to support this in this library.