Skip to content

Commit

Permalink
getopts: replaced base functions with those from group
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcterus committed Feb 6, 2014
1 parent 9752c63 commit c09ca94
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 505 deletions.
10 changes: 5 additions & 5 deletions src/compiletest/compiletest.rs
Expand Up @@ -20,7 +20,7 @@ use std::os;
use std::io;
use std::io::fs;

use getopts::groups::{optopt, optflag, reqopt};
use getopts::{optopt, optflag, reqopt};
use extra::test;

use common::config;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn main() {

pub fn parse_config(args: ~[~str]) -> config {

let groups : ~[getopts::groups::OptGroup] =
let groups : ~[getopts::OptGroup] =
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
Expand Down Expand Up @@ -85,20 +85,20 @@ pub fn parse_config(args: ~[~str]) -> config {
let args_ = args.tail();
if args[1] == ~"-h" || args[1] == ~"--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::groups::usage(message, groups));
println!("{}", getopts::usage(message, groups));
println!("");
fail!()
}

let matches =
&match getopts::groups::getopts(args_, groups) {
&match getopts::getopts(args_, groups) {
Ok(m) => m,
Err(f) => fail!("{}", f.to_err_msg())
};

if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::groups::usage(message, groups));
println!("{}", getopts::usage(message, groups));
println!("");
fail!()
}
Expand Down
25 changes: 12 additions & 13 deletions src/libextra/test.rs
Expand Up @@ -17,7 +17,6 @@

extern mod term;

use getopts::groups;
use getopts;
use json::ToJson;
use json;
Expand Down Expand Up @@ -209,29 +208,29 @@ pub struct TestOpts {
/// Result of parsing the options.
pub type OptRes = Result<TestOpts, ~str>;

fn optgroups() -> ~[getopts::groups::OptGroup] {
~[groups::optflag("", "ignored", "Run ignored tests"),
groups::optflag("", "test", "Run tests and not benchmarks"),
groups::optflag("", "bench", "Run benchmarks instead of tests"),
groups::optflag("h", "help", "Display this message (longer with --help)"),
groups::optopt("", "save-metrics", "Location to save bench metrics",
fn optgroups() -> ~[getopts::OptGroup] {
~[getopts::optflag("", "ignored", "Run ignored tests"),
getopts::optflag("", "test", "Run tests and not benchmarks"),
getopts::optflag("", "bench", "Run benchmarks instead of tests"),
getopts::optflag("h", "help", "Display this message (longer with --help)"),
getopts::optopt("", "save-metrics", "Location to save bench metrics",
"PATH"),
groups::optopt("", "ratchet-metrics",
getopts::optopt("", "ratchet-metrics",
"Location to load and save metrics from. The metrics \
loaded are cause benchmarks to fail if they run too \
slowly", "PATH"),
groups::optopt("", "ratchet-noise-percent",
getopts::optopt("", "ratchet-noise-percent",
"Tests within N% of the recorded metrics will be \
considered as passing", "PERCENTAGE"),
groups::optopt("", "logfile", "Write logs to the specified file instead \
getopts::optopt("", "logfile", "Write logs to the specified file instead \
of stdout", "PATH"),
groups::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
"A.B")]
}

fn usage(binary: &str, helpstr: &str) {
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
println!("{}", groups::usage(message, optgroups()));
println!("{}", getopts::usage(message, optgroups()));
println!("");
if helpstr == "help" {
println!("{}", "\
Expand Down Expand Up @@ -261,7 +260,7 @@ Test Attributes:
pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
let args_ = args.tail();
let matches =
match groups::getopts(args_, optgroups()) {
match getopts::getopts(args_, optgroups()) {
Ok(m) => m,
Err(f) => return Some(Err(f.to_err_msg()))
};
Expand Down

0 comments on commit c09ca94

Please sign in to comment.