diff --git a/capnpc/src/lib.rs b/capnpc/src/lib.rs index 2a388029a..f2973179e 100644 --- a/capnpc/src/lib.rs +++ b/capnpc/src/lib.rs @@ -324,17 +324,7 @@ impl CompilerCommand { #[test] #[cfg_attr(miri, ignore)] fn compiler_command_new_no_out_dir() { + std::env::remove_var("OUT_DIR"); let error = CompilerCommand::new().run().unwrap_err().description; assert!(error.starts_with("Could not access `OUT_DIR` environment variable")); } - -#[test] -#[cfg_attr(miri, ignore)] -fn compiler_command_with_output_path_no_out_dir() { - let error = CompilerCommand::new() - .output_path("foo") - .run() - .unwrap_err() - .description; - assert!(error.starts_with("Error while trying to execute `capnp compile`")); -} diff --git a/capnpc/test/build.rs b/capnpc/test/build.rs index 290b114e0..be0672b97 100644 --- a/capnpc/test/build.rs +++ b/capnpc/test/build.rs @@ -22,4 +22,15 @@ fn main() { ]) .run() .expect("compiling schema"); + + let mut output_path = + std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR env var is not set")); + + // `capnp compile` will create this directory + output_path.push("inner-output-path"); + capnpc::CompilerCommand::new() + .file("test-output-path.capnp") + .output_path(output_path) + .run() + .expect("compiling schema") } diff --git a/capnpc/test/test-output-path.capnp b/capnpc/test/test-output-path.capnp new file mode 100644 index 000000000..f88075c5b --- /dev/null +++ b/capnpc/test/test-output-path.capnp @@ -0,0 +1,9 @@ +# Schema to use to test `CompilerCommand::output_path()`. + +@0xbc9d501a1b13e0e9; + +struct Foo {} + +struct Bar { + foo @0 : Foo; +} diff --git a/capnpc/test/test.rs b/capnpc/test/test.rs index 1eeae226d..236eddcc8 100644 --- a/capnpc/test/test.rs +++ b/capnpc/test/test.rs @@ -71,6 +71,13 @@ pub mod test_in_src_prefix_dir_capnp { include!(concat!(env!("OUT_DIR"), "/test_in_src_prefix_dir_capnp.rs")); } +pub mod test_output_path_capnp { + include!(concat!( + env!("OUT_DIR"), + "/inner-output-path/test_output_path_capnp.rs" + )); +} + #[cfg(test)] mod test_util;