1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
pub mod vcl {
pub mod convert;
pub mod ctx;
pub mod helpers;
pub mod http;
pub mod vpriv;
pub mod ws;
}
pub mod vmodtool;
#[macro_export]
macro_rules! vtc {
( $name:ident ) => {
#[test]
fn $name() {
use std::io::{self, Write};
use std::process::Command;
let target = if cfg!(debug_assertions) {
"debug"
} else {
"release"
};
let cmd = Command::new("varnishtest")
.arg(concat!("tests/", stringify!($name), ".vtc"))
.arg("-D")
.arg(
String::from("vmod=")
+ std::env::current_dir().unwrap().to_str().unwrap()
+ "/target/"
+ target
+ "/lib"
+ &std::env::var("CARGO_PKG_NAME").unwrap()
+ ".so",
)
.output()
.unwrap();
if !cmd.status.success() {
io::stdout().write_all(&cmd.stdout).unwrap();
panic!(concat!("tests/", stringify!($name), ".vtc failed"));
}
}
};
}
#[macro_export]
macro_rules! boilerplate {
() => {
#[allow(non_upper_case_globals)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(unused_imports)]
#[allow(dead_code)]
mod generated {
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
}
};
}