diff options
| author | kennytm <kennytm@gmail.com> | 2017-05-21 00:35:53 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2017-06-02 01:14:25 +0800 |
| commit | 1a1ea253f2b92179333e0042d63dcfca45a947f0 (patch) | |
| tree | 7f915be5655bb469d8fc4d2eefccad1a87cfc404 /src | |
| parent | 57356b36fc42f527406371585bdca1a83da8d2f1 (diff) | |
| download | rust-1a1ea253f2b92179333e0042d63dcfca45a947f0.tar.gz rust-1a1ea253f2b92179333e0042d63dcfca45a947f0.zip | |
Added --color flag to compiletest.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 5 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index df41e786be5..92f6f36d69d 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -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, @@ -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>, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 6fc7f9f07ac..1bb0b765f9f 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -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; @@ -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"), @@ -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")), @@ -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(), @@ -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, |
