Skip to content

Commit caedfcb

Browse files
dzfranklindwrensha
authored andcommitted
Read OUT_DIR at compile time not runtime in test
Without this change the test intermittently failed on my computer depending on the order I ran other tests in. OUT_DIR is documented as something you should read at compilation time.
1 parent ae45f7d commit caedfcb

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

capnpc/test/test.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2056,11 +2056,8 @@ mod tests {
20562056
use capnp::serialize;
20572057
use std::fs;
20582058

2059-
let raw_code_gen_request = fs::read(
2060-
std::env::var("OUT_DIR").expect("OUT_DIR env var is not set")
2061-
+ "/raw_code_gen_request.bin",
2062-
)
2063-
.expect("Failed to open raw code gen request file");
2059+
let raw_code_gen_request = fs::read(concat!(env!("OUT_DIR"), "/raw_code_gen_request.bin"))
2060+
.expect("Failed to open raw code gen request file");
20642061

20652062
let reader =
20662063
serialize::read_message(raw_code_gen_request.as_slice(), ReaderOptions::new()).unwrap();

0 commit comments

Comments
 (0)