Skip to content

test code that is a library instead of a bin #210

@TomzBench

Description

@TomzBench

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    out of scopeIdeas to consider for someone building a more fully featured ui testing library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions