Run 'cargo run' only once

This commit is contained in:
sharkdp 2018-11-02 18:33:06 +01:00 committed by David Peter
parent 278d841408
commit c6a526f99c
3 changed files with 15 additions and 1 deletions

1
Cargo.lock generated
View File

@ -66,6 +66,7 @@ dependencies = [
"directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"escargot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -49,6 +49,7 @@ features = []
[dev-dependencies] [dev-dependencies]
tempdir = "0.3" tempdir = "0.3"
assert_cmd = "0.10.1" assert_cmd = "0.10.1"
escargot = "0.3.1"
[build-dependencies] [build-dependencies]
clap = "2.32" clap = "2.32"

View File

@ -1,10 +1,22 @@
extern crate assert_cmd; extern crate assert_cmd;
extern crate escargot;
#[macro_use]
extern crate lazy_static;
use assert_cmd::prelude::*; use assert_cmd::prelude::*;
use escargot::CargoRun;
use std::process::Command; use std::process::Command;
lazy_static! {
static ref CARGO_RUN: CargoRun = escargot::CargoBuild::new()
.bin("bat")
.current_release()
.run()
.unwrap();
}
fn bat_with_config() -> Command { fn bat_with_config() -> Command {
let mut cmd = Command::main_binary().unwrap(); let mut cmd = CARGO_RUN.command();
cmd.current_dir("tests/examples"); cmd.current_dir("tests/examples");
cmd.env_remove("PAGER"); cmd.env_remove("PAGER");
cmd.env_remove("BAT_PAGER"); cmd.env_remove("BAT_PAGER");