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;
15 use error::CommandResult;
19 use std::old_io::{Command, File};
24 pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
26 Some(box Test as 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 = os::getcwd().unwrap();
39 let src = cwd.clone();
41 let summary = File::open(&src.join("SUMMARY.md"));
42 match book::parse_summary(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.output[]),
54 String::from_utf8_lossy(&output.error[]))[]);
55 return Err(box "Some tests failed." as Box<Error>);
60 let message = format!("Could not execute `rustdoc`: {}", e);
61 return Err(box message as Box<Error>);
70 return Err(box "There was an error." as Box<Error>);