1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Implementation of the `test` subcommand. Just a stub for now.
13 use subcommand::Subcommand;
14 use error::{err, CliResult, CommandResult};
20 use std::process::Command;
24 pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
32 impl Subcommand for Test {
33 fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
37 fn execute(&mut self, term: &mut Term) -> CommandResult<()> {
38 let cwd = env::current_dir().unwrap();
39 let src = cwd.clone();
41 let mut summary = try!(File::open(&src.join("SUMMARY.md")));
42 match book::parse_summary(&mut summary, &src) {
44 for (_, item) in book.iter() {
45 let output_result = Command::new("rustdoc")
51 if !output.status.success() {
52 term.err(&format!("{}\n{}",
53 String::from_utf8_lossy(&output.stdout),
54 String::from_utf8_lossy(&output.stderr)));
55 return Err(err("some tests failed"));
60 let message = format!("could not execute `rustdoc`: {}", e);
61 return Err(err(&message))
70 return Err(err("there was an error"))