Skip to content

The decision is made at compile time rather than run time #18

Description

@mina86
$ cat src/lib.rs
#[test_with::env(SOME_VAR)]
fn test() {
    panic!("WUT");
}
$ cargo test --tests
   Compiling a v0.1.0 (/tmp/a)
    Finished test [unoptimized] target(s) in 0.23s
     Running unittests (target/debug/deps/a-07e254e8b610defe)

running 1 test
test test ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s

$ : This should fail but it does not:
$ SOME_VAR=should_panic cargo test --tests
    Finished test [unoptimized] target(s) in 0.03s
     Running unittests (target/debug/deps/a-07e254e8b610defe)

running 1 test
test test ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s

$ touch src/lib.rs
$ SOME_VAR=should_panic cargo test --tests
   Compiling a v0.1.0 (/tmp/a)
    Finished test [unoptimized] target(s) in 0.19s
     Running unittests (target/debug/deps/a-07e254e8b610defe)

running 1 test
test test ... FAILED

failures:

---- test stdout ----
thread 'test' panicked at 'WUT', src/lib.rs:3:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'

$ : This should succeed but fails:
$ cargo test --tests
    Finished test [unoptimized] target(s) in 0.03s
     Running unittests (target/debug/deps/a-07e254e8b610defe)

running 1 test
test test ... FAILED

failures:

---- test stdout ----
thread 'test' panicked at 'WUT', src/lib.rs:3:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingIssue can not be solved now

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions