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

Provide mechanism to disable test execution #19

Closed
davidbarsky opened this issue Jul 4, 2019 · 3 comments
Closed

Provide mechanism to disable test execution #19

davidbarsky opened this issue Jul 4, 2019 · 3 comments
Labels
out of scope Ideas to consider for someone building a more fully featured ui testing library

Comments

@davidbarsky
Copy link

Hi! I'm using Trybuild to test some procedural macros in the AWS Lambda Runtime for Rust, and I'm really liking it!

I do have a question, though: there any way to disable TestCases::pass from running the code under test/providing a mechanism to only check for compiler errors?

At runtime, the macro I'm testing with Trybuild makes several assumptions about its environment that include a running server + several environment variables. This results in tests failing with a server connection error, rather than passing due to correct usage of the macro. More concretely, it'd be really handy for my use case if run_test would pass check rather than run to Cargo.

Thanks again for this crate! It's really nice to use, and the test reports are beautifully rendered.

@dtolnay
Copy link
Owner

dtolnay commented Jul 4, 2019

Could you move the main function out of the root module and provide an empty main instead? If not, I think you may be able to bypass main as the entry point by adding:

#![feature(start)]

#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
    0
}

@davidbarsky
Copy link
Author

Could you move the main function out of the root module and provide an empty main instead?

Not really; the procedural macro I'm testing (#[lambda]) is intended to be invoked in normal usage as:

#![feature(async_await)]

use lambda::{lambda, Error};

#[lambda]
#[runtime::main]
async fn main(s: String) -> Result<String, Error> {
    Ok(s)
}

If not, I think you may be able to bypass main as the entry point by adding: [code redacted]

Thanks! That did the trick with:

#![feature(async_await, start)]

use lambda::{lambda, Error};

#[lambda]
#[runtime::main]
async fn main(s: String) -> Result<String, Error> {
    Ok(s)
}

#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
    0
}

Bit curious—why does Trybuild execute the procedural macro instead of only building?

@slinkydeveloper
Copy link

slinkydeveloper commented Jan 24, 2020

I had the same problem (i was generating the main method too), fixed adding start method.

@dtolnay dtolnay added the wontfix This will not be worked on label Mar 5, 2023
@dtolnay dtolnay closed this as completed Mar 5, 2023
@dtolnay dtolnay added out of scope Ideas to consider for someone building a more fully featured ui testing library and removed wontfix This will not be worked on labels Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
out of scope Ideas to consider for someone building a more fully featured ui testing library
Projects
None yet
Development

No branches or pull requests

3 participants