Skip to content

Commit

Permalink
Added --color flag to compiletest.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Jun 1, 2017
1 parent 57356b3 commit 1a1ea25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use std::fmt;
use std::str::FromStr;
use std::path::PathBuf;

use test::ColorConfig;

#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Mode {
CompileFail,
Expand Down Expand Up @@ -185,6 +187,9 @@ pub struct Config {
// Print one character per test instead of one line
pub quiet: bool,

// Whether to use colors in test.
pub color: ColorConfig,

// where to find the remote test client process, if we're using it
pub remote_test_client: Option<PathBuf>,

Expand Down
13 changes: 11 additions & 2 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use filetime::FileTime;
use getopts::{optopt, optflag, reqopt};
use common::Config;
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Mode};
use test::TestPaths;
use test::{TestPaths, ColorConfig};
use util::logv;

use self::header::EarlyProps;
Expand Down Expand Up @@ -90,6 +90,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS"),
optflag("", "verbose", "run tests verbosely, showing all output"),
optflag("", "quiet", "print one character per test instead of one line"),
optopt("", "color", "coloring: auto, always, never", "WHEN"),
optopt("", "logfile", "file to log test execution to", "FILE"),
optopt("", "target", "the target to build for", "TARGET"),
optopt("", "host", "the host to build for", "HOST"),
Expand Down Expand Up @@ -147,6 +148,13 @@ pub fn parse_config(args: Vec<String> ) -> Config {

let (gdb, gdb_version, gdb_native_rust) = analyze_gdb(matches.opt_str("gdb"));

let color = match matches.opt_str("color").as_ref().map(|x| &**x) {
Some("auto") | None => ColorConfig::AutoColor,
Some("always") => ColorConfig::AlwaysColor,
Some("never") => ColorConfig::NeverColor,
Some(x) => panic!("argument for --color must be auto, always, or never, but found `{}`", x),
};

Config {
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
Expand Down Expand Up @@ -185,6 +193,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
lldb_python_dir: matches.opt_str("lldb-python-dir"),
verbose: matches.opt_present("verbose"),
quiet: matches.opt_present("quiet"),
color: color,
remote_test_client: matches.opt_str("remote-test-client").map(PathBuf::from),

cc: matches.opt_str("cc").unwrap(),
Expand Down Expand Up @@ -332,7 +341,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
Ok(val) => &val != "0",
Err(_) => false
},
color: test::AutoColor,
color: config.color,
test_threads: None,
skip: vec![],
list: false,
Expand Down

0 comments on commit 1a1ea25

Please sign in to comment.