forked from rust-lang/cargo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor cargo_test into an ops module
The logic for doc tests will get a little complex, so this is moved to aseparate module instead of inside the executable.
- Loading branch information
1 parent
23bb49c
commit 505593a
Showing
4 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use core::Source; | ||
use sources::PathSource; | ||
use ops; | ||
use util::{process, CargoResult, ProcessError}; | ||
|
||
pub fn run_tests(manifest_path: &Path, | ||
options: &mut ops::CompileOptions, | ||
args: &[String]) -> CargoResult<Option<ProcessError>> { | ||
let mut source = PathSource::for_path(&manifest_path.dir_path()); | ||
try!(source.update()); | ||
let package = try!(source.get_root_package()); | ||
|
||
try!(ops::compile(manifest_path, options)); | ||
|
||
let mut exes = package.get_targets().iter().filter_map(|target| { | ||
if !target.get_profile().is_test() { return None } | ||
let root = package.get_root().join("target"); | ||
let root = match target.get_profile().get_dest() { | ||
Some(dest) => root.join(dest), | ||
None => root, | ||
}; | ||
Some(root.join(target.file_stem())) | ||
}); | ||
|
||
for exe in exes { | ||
match process(exe).args(args).exec() { | ||
Ok(()) => {} | ||
Err(e) => return Ok(Some(e)) | ||
} | ||
} | ||
|
||
Ok(None) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters