Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Feature/86/run using active compilation profile #97

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ impl default::Default for Assert {
/// Defaults to asserting _successful_ execution.
fn default() -> Self {
Assert {
cmd: vec!["cargo", "run", "--quiet", "--"]
.into_iter()
cmd: vec![
"cargo",
"run",
#[cfg(not(debug_assertions))]
"--release",
"--quiet",
"--",
].into_iter()
.map(OsString::from)
.collect(),
env: Environment::inherit(),
Expand Down Expand Up @@ -61,6 +67,8 @@ impl Assert {
cmd: vec![
OsStr::new("cargo"),
OsStr::new("run"),
#[cfg(not(debug_assertions))]
OsStr::new("--release"),
OsStr::new("--quiet"),
OsStr::new("--bin"),
name.as_ref(),
Expand Down Expand Up @@ -530,6 +538,52 @@ mod test {
Assert::command(&["printenv"])
}

#[test]
fn main_binary_default_uses_active_profile() {
let assert = Assert::main_binary();

let expected = if cfg!(debug_assertions) {
OsString::from("cargo run --quiet -- ")
} else {
OsString::from("cargo run --release --quiet -- ")
};

assert_eq!(
expected,
assert
.cmd
.into_iter()
.fold(OsString::from(""), |mut cmd, token| {
cmd.push(token);
cmd.push(" ");
cmd
})
);
}

#[test]
fn cargo_binary_default_uses_active_profile() {
let assert = Assert::cargo_binary("hello");

let expected = if cfg!(debug_assertions) {
OsString::from("cargo run --quiet --bin hello -- ")
} else {
OsString::from("cargo run --release --quiet --bin hello -- ")
};

assert_eq!(
expected,
assert
.cmd
.into_iter()
.fold(OsString::from(""), |mut cmd, token| {
cmd.push(token);
cmd.push(" ");
cmd
})
);
}

#[test]
fn take_ownership() {
let x = Environment::inherit();
Expand Down
2 changes: 1 addition & 1 deletion src/bin/assert_fixture.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate failure;

use std::env;
use std::io;
use std::io::Write;
use std::env;
use std::process;

use failure::ResultExt;
Expand Down
2 changes: 1 addition & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::rc;
use difference::Changeset;
use failure;

use errors::*;
use diff;
use errors::*;

#[derive(Clone, PartialEq, Eq)]
pub enum Content {
Expand Down