Skip to content

Commit

Permalink
Merge branch 'issue_57'
Browse files Browse the repository at this point in the history
Fixes #57
  • Loading branch information
xd009642 committed Oct 17, 2017
2 parents 488c205 + d9e1b74 commit 240268f
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 10 deletions.
120 changes: 114 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fallible-iterator = "0.1.3"
memmap = "0.5.2"
object = "0.4"
rustc-demangle = "0.1.4"
cargo = "0.21.1"
cargo = "0.22"
clap = "2"
serde = "1.0.2"
serde_json = "1.0.2"
Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub struct Config {
pub features: Vec<String>,
/// Packages to include when building the target project
pub packages: Vec<String>,
/// Packages to exclude from testing
pub exclude: Vec<String>,
/// Varargs to be forwarded to the test executables.
pub varargs: Vec<String>,
}
Expand Down Expand Up @@ -114,6 +116,10 @@ impl Config {
Some(v) => v,
None => vec![],
};
let exclude: Vec<String> = match args.values_of_lossy("exclude") {
Some(v) => v,
None => vec![],
};
let varargs: Vec<String> = match args.values_of_lossy("args") {
Some(v) => v,
None => vec![],
Expand All @@ -133,6 +139,7 @@ impl Config {
forward_signals: forward,
features: features,
packages: packages,
exclude: exclude,
varargs: varargs
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,22 @@ pub fn launch_tarpaulin(config: &Config) -> Result<Vec<TracerData>, i32> {
flag_quiet,
&None,
false,
false);
false,
&[]);

let workspace = Workspace::new(config.manifest.as_path(), &cargo_config).map_err(|_| 1i32)?;

setup_environment(&cargo_config);

let mut copt = ops::CompileOptions::default(&cargo_config, ops::CompileMode::Test);
copt.features = config.features.as_slice();
copt.spec = ops::Packages::Packages(config.packages.as_slice());
copt.spec = match ops::Packages::from_flags(workspace.is_virtual(), true, &config.exclude, &config.packages) {
Ok(spec) => spec,
Err(e) => {
println!("Error getting Packages from workspace {}", e);
return Err(-1)
}
};
if config.verbose {
println!("Running Tarpaulin");
}
Expand Down Expand Up @@ -450,6 +457,10 @@ fn execute_test(test: &Path, ignored: bool, config: &Config) {
Err(e) => println!("ASLR disable failed: {}", e),
}
request_trace().expect("Failed to trace");
println!("running {}", test.display());
if let Some(parent) = config.manifest.parent() {
let _ = env::set_current_dir(parent);
}

let mut envars: Vec<CString> = vec![CString::new("RUST_TEST_THREADS=1").unwrap()];
for (key, value) in env::vars() {
Expand Down
Loading

0 comments on commit 240268f

Please sign in to comment.