Skip to content

Move getopts out of extra #12007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@
# automatically generated for all stage/host/target combinations.
################################################################################

TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid serialize sync
TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
uuid serialize sync getopts
HOST_CRATES := syntax rustc rustdoc
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc

DEPS_std := native:rustrt
DEPS_extra := std serialize sync term
DEPS_extra := std term sync serialize getopts
DEPS_green := std
DEPS_rustuv := std native:uv native:uv_support
DEPS_native := std
DEPS_syntax := std extra term serialize
DEPS_rustc := syntax native:rustllvm flate arena serialize sync
DEPS_rustdoc := rustc native:sundown serialize sync
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts
DEPS_rustdoc := rustc native:sundown serialize sync getopts
DEPS_flate := std native:miniz
DEPS_arena := std extra
DEPS_glob := std
Expand All @@ -70,8 +71,9 @@ DEPS_term := std
DEPS_semver := std
DEPS_uuid := std serialize
DEPS_sync := std
DEPS_getopts := std

TOOL_DEPS_compiletest := extra green rustuv
TOOL_DEPS_compiletest := extra green rustuv getopts
TOOL_DEPS_rustdoc := rustdoc green rustuv
TOOL_DEPS_rustc := rustc green rustuv
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
Expand Down
12 changes: 6 additions & 6 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#[deny(warnings)];

extern mod extra;
extern mod getopts;

use std::os;
use std::io;
use std::io::fs;

use extra::getopts;
use extra::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
1 change: 1 addition & 0 deletions src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ li {list-style-type: none; }

* [The `arena` allocation library](arena/index.html)
* [The `flate` compression library](flate/index.html)
* [The `getopts` argument parsing library](getopts/index.html)
* [The `glob` file path matching library](glob/index.html)
* [The `semver` version collation library](semver/index.html)
* [The `serialize` value encoding/decoding library](serialize/index.html)
Expand Down
1 change: 0 additions & 1 deletion src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub mod lru_cache;
// And ... other stuff

pub mod url;
pub mod getopts;
pub mod json;
pub mod tempfile;
pub mod time;
Expand Down
27 changes: 13 additions & 14 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
// simplest interface possible for representing and running tests
// while providing a base that other test frameworks may build off of.

extern mod getopts;
extern mod term;

use getopts;
use getopts::groups;
use json::ToJson;
use json;
use serialize::Decodable;
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
Loading