mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
eb184d7711
This basically rewrites every integration test. We reduce the amount of magic involved here in terms of which arguments are being passed to ripgrep processes. To make up for the boiler plate saved by the magic, we make the Dir (formerly WorkDir) type a bit nicer to use, along with a new TestCommand that wraps a std::process::Command. In exchange, we get tests that are easier to read and write. We also run every test with the `--pcre2` flag to make sure that works, when PCRE2 is available.
62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
#[macro_export]
|
|
macro_rules! rgtest {
|
|
($name:ident, $fun:expr) => {
|
|
#[test]
|
|
fn $name() {
|
|
let (dir, cmd) = ::util::setup(stringify!($name));
|
|
$fun(dir, cmd);
|
|
|
|
if cfg!(feature = "pcre2") {
|
|
let (dir, cmd) = ::util::setup_pcre2(stringify!($name));
|
|
$fun(dir, cmd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! eqnice {
|
|
($expected:expr, $got:expr) => {
|
|
let expected = &*$expected;
|
|
let got = &*$got;
|
|
if expected != got {
|
|
panic!("
|
|
printed outputs differ!
|
|
|
|
expected:
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
{}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
got:
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
{}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
", expected, got);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! eqnice_repr {
|
|
($expected:expr, $got:expr) => {
|
|
let expected = &*$expected;
|
|
let got = &*$got;
|
|
if expected != got {
|
|
panic!("
|
|
printed outputs differ!
|
|
|
|
expected:
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
{:?}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
got:
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
{:?}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
", expected, got);
|
|
}
|
|
}
|
|
}
|