Skip to content

Commit 977b3db

Browse files
committed
more output_path() test in capnpc-test, and make it actually test something interesting
1 parent caedfcb commit 977b3db

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

capnpc/src/lib.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,7 @@ impl CompilerCommand {
324324
#[test]
325325
#[cfg_attr(miri, ignore)]
326326
fn compiler_command_new_no_out_dir() {
327+
std::env::remove_var("OUT_DIR");
327328
let error = CompilerCommand::new().run().unwrap_err().description;
328329
assert!(error.starts_with("Could not access `OUT_DIR` environment variable"));
329330
}
330-
331-
#[test]
332-
#[cfg_attr(miri, ignore)]
333-
fn compiler_command_with_output_path_no_out_dir() {
334-
let error = CompilerCommand::new()
335-
.output_path("foo")
336-
.run()
337-
.unwrap_err()
338-
.description;
339-
assert!(error.starts_with("Error while trying to execute `capnp compile`"));
340-
}

capnpc/test/build.rs

+11
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,15 @@ fn main() {
2222
])
2323
.run()
2424
.expect("compiling schema");
25+
26+
let mut output_path =
27+
std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR env var is not set"));
28+
29+
// `capnp compile` will create this directory
30+
output_path.push("inner-output-path");
31+
capnpc::CompilerCommand::new()
32+
.file("test-output-path.capnp")
33+
.output_path(output_path)
34+
.run()
35+
.expect("compiling schema")
2536
}

capnpc/test/test-output-path.capnp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Schema to use to test `CompilerCommand::output_path()`.
2+
3+
@0xbc9d501a1b13e0e9;
4+
5+
struct Foo {}
6+
7+
struct Bar {
8+
foo @0 : Foo;
9+
}

capnpc/test/test.rs

+7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ pub mod test_in_src_prefix_dir_capnp {
7171
include!(concat!(env!("OUT_DIR"), "/test_in_src_prefix_dir_capnp.rs"));
7272
}
7373

74+
pub mod test_output_path_capnp {
75+
include!(concat!(
76+
env!("OUT_DIR"),
77+
"/inner-output-path/test_output_path_capnp.rs"
78+
));
79+
}
80+
7481
#[cfg(test)]
7582
mod test_util;
7683

0 commit comments

Comments
 (0)