Skip to content

Commit

Permalink
[datatest-stable] support --format terse
Browse files Browse the repository at this point in the history
Support the terse format while listing tests, since that's what the test
runner uses.

Closes: aptos-labs#7932
  • Loading branch information
sunshowers authored and bors-libra committed Mar 16, 2021
1 parent 426bc19 commit 48d3f7f
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions common/datatest-stable/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
sync::mpsc::{channel, Sender},
thread,
};
use structopt::StructOpt;
use structopt::{clap::arg_enum, StructOpt};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};

#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -68,8 +68,12 @@ struct TestOpts {
/// NO-OP: unsupported option, exists for compatibility with the default test harness
color: Option<String>,
#[structopt(long)]
/// NO-OP: unsupported option, exists for compatibility with the default test harness
format: Option<String>,
/// Configure formatting of output:
/// pretty = Print verbose output;
/// terse = Display one character per test;
/// (json is unsupported, exists for compatibility with the default test harness)
#[structopt(possible_values = &Format::variants(), default_value, case_insensitive = true)]
format: Format,
#[structopt(long)]
/// NO-OP: unsupported option, exists for compatibility with the default test harness
report_time: Option<String>,
Expand All @@ -78,6 +82,21 @@ struct TestOpts {
ensure_time: bool,
}

arg_enum! {
#[derive(Debug, Eq, PartialEq)]
enum Format {
Pretty,
Terse,
Json,
}
}

impl Default for Format {
fn default() -> Self {
Format::Pretty
}
}

pub fn runner(reqs: &[Requirements]) {
let options = TestOpts::from_args();

Expand All @@ -88,8 +107,10 @@ pub fn runner(reqs: &[Requirements]) {
println!("{}: test", test.name);
}

println!();
println!("{} tests, 0 benchmarks", tests.len());
if options.format == Format::Pretty {
println!();
println!("{} tests, 0 benchmarks", tests.len());
}
return;
}

Expand Down

0 comments on commit 48d3f7f

Please sign in to comment.