gquintard/varnish-rs

Running VTC tests from workspace

Closed this issue · 4 comments

Hey,

thanks for this awesome crate. I am developing a couple of VMODs using this project and would like to keep them in a single repository. My layout is as follows:

Cargo.toml # contains "workspace.members"

vmod-sample/
  Cargo.toml
  src/lib.rs
  tests/test01.vtc
  vmod.vcc

my lib.rs looks simple like this:

use varnish::vcl::ctx::Ctx;

// this import is only needed for tests
#[cfg(test)]
use varnish::vcl::ctx::TestCtx;

// import the generated boilerplate
varnish::boilerplate!();

// run tests. parameter is always the filename without extension in tests/
varnish::vtc!(test01);

However, when running cargo test --all I get the following error message:

---- test_sanity stdout ----
thread 'test_sanity' panicked at 'couldn't find libvmod_sample.so in /mountpoint/target/debug/deps:/mountpoint/target/debug:/root/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib:/root/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib', vmod-sample/src/lib.rs:24:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Is there something I am missing to make VTC tests work with cargo workspaces or is it just a limitation of this crate? I have tried moving all VTC tests into a top-level tests folder but still get the same error.

Thanks!

Hi @thomasklinger1234 , thanks for using varnish-rs!

It looks like you are panicking here, so the panic message is pretty straightforward: we have no shared object in sight! That's a bit strange because varnish-rs itself uses workspaces without issues.

I can think of two main reasons for that:

  • you goofed, and forgot to build before testing (we need the so to exist before passing it to varnishtest)
  • I goofed, and I'm not looking into all the spots I should, but I'm seeing /mountpoint/target/debug/deps:/mountpoint/target/debug in the path list so that looks fairly ok.

Could you try running something like find target/ -name libvmod_sample.so to see if you have the vmod build, and if so, where it is?

Alternatively, I can look at the repository, if you have it published. Otherwise I'll create a minimal reproducer later this week to test on my own.

By the way, I wanted to thank you for vmod-uuid, and wished to make sure you knew it was showcased here

@gquintard thanks for the quick reply!

Hi @thomasklinger1234 , thanks for using varnish-rs!

It looks like you are panicking here, so the panic message is pretty straightforward: we have no shared object in sight! That's a bit strange because varnish-rs itself uses workspaces without issues.

This issue can be closed now.

I can think of two main reasons for that:

  • you goofed, and forgot to build before testing (we need the so to exist before passing it to varnishtest)
  • I goofed, and I'm not looking into all the spots I should, but I'm seeing /mountpoint/target/debug/deps:/mountpoint/target/debug in the path list so that looks fairly ok.

Turns out: I goofed. After looking at the examples I found out that I explicitly need to run cargo build first and then run cargo test. Somehow, I assumed that running cargo test will also build everything prior to testing but this is not the case.

By the way, I wanted to thank you for vmod-uuid, and wished to make sure you knew it was showcased here

Good to know!

Ah, I should probably make that clearer, I'll reopen this issue until I have a better error message in there

added some explanation both in docs and in error message, please let me know if you think that it's not sufficient