Closed zjp-CN closed 2 years ago
I believe you are meant to use expect!
inside tests, not the main executable. cargo run
doesn't set an env var expect!
needs, only cargo test
does.
@bjorn3
Probably not I guess.
I put expect!
in a simple main.rs generated by cargo new
, and it can automatically update the result with env set up.
And I turn the main function that I link into a test function, the same error pops up.
The error happens at https://github.com/rust-analyzer/expect-test/blob/9d2aa5d01b485c432b0b16c6ea6a540fcc04b5c2/src/lib.rs#L539, which could fail if to_abs_ws_path
returns an incorrect path.
Thank you for pointing that out! I should have run the command with RUST_BACKTRACE=full
:)
I've read to_abs_ws_path
and used
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
in .cargo/config.toml
, and expect!
goes well.
The source file is here:
When I create a new cargo bin project, expect-test can update the result successfully. But for this it can't.
I tried to debug it, and I got: