Skip to content

Commit 680925e

Browse files
committed
auto merge of #12007 : Arcterus/rust/libgetopts, r=cmr
Should help towards finishing #8784.
2 parents 66b9c35 + 968ce53 commit 680925e

File tree

13 files changed

+558
-806
lines changed

13 files changed

+558
-806
lines changed

mk/crates.mk

+7-5
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@
4949
# automatically generated for all stage/host/target combinations.
5050
################################################################################
5151

52-
TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid serialize sync
52+
TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
53+
uuid serialize sync getopts
5354
HOST_CRATES := syntax rustc rustdoc
5455
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5556
TOOLS := compiletest rustdoc rustc
5657

5758
DEPS_std := native:rustrt
58-
DEPS_extra := std serialize sync term
59+
DEPS_extra := std term sync serialize getopts
5960
DEPS_green := std
6061
DEPS_rustuv := std native:uv native:uv_support
6162
DEPS_native := std
6263
DEPS_syntax := std extra term serialize
63-
DEPS_rustc := syntax native:rustllvm flate arena serialize sync
64-
DEPS_rustdoc := rustc native:sundown serialize sync
64+
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts
65+
DEPS_rustdoc := rustc native:sundown serialize sync getopts
6566
DEPS_flate := std native:miniz
6667
DEPS_arena := std extra
6768
DEPS_glob := std
@@ -70,8 +71,9 @@ DEPS_term := std
7071
DEPS_semver := std
7172
DEPS_uuid := std serialize
7273
DEPS_sync := std
74+
DEPS_getopts := std
7375

74-
TOOL_DEPS_compiletest := extra green rustuv
76+
TOOL_DEPS_compiletest := extra green rustuv getopts
7577
TOOL_DEPS_rustdoc := rustdoc green rustuv
7678
TOOL_DEPS_rustc := rustc green rustuv
7779
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs

src/compiletest/compiletest.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#[deny(warnings)];
1515

1616
extern mod extra;
17+
extern mod getopts;
1718

1819
use std::os;
1920
use std::io;
2021
use std::io::fs;
2122

22-
use extra::getopts;
23-
use extra::getopts::groups::{optopt, optflag, reqopt};
23+
use getopts::{optopt, optflag, reqopt};
2424
use extra::test;
2525

2626
use common::config;
@@ -49,7 +49,7 @@ pub fn main() {
4949

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

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

9393
let matches =
94-
&match getopts::groups::getopts(args_, groups) {
94+
&match getopts::getopts(args_, groups) {
9595
Ok(m) => m,
9696
Err(f) => fail!("{}", f.to_err_msg())
9797
};
9898

9999
if matches.opt_present("h") || matches.opt_present("help") {
100100
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
101-
println!("{}", getopts::groups::usage(message, groups));
101+
println!("{}", getopts::usage(message, groups));
102102
println!("");
103103
fail!()
104104
}

src/doc/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ li {list-style-type: none; }
3939

4040
* [The `arena` allocation library](arena/index.html)
4141
* [The `flate` compression library](flate/index.html)
42+
* [The `getopts` argument parsing library](getopts/index.html)
4243
* [The `glob` file path matching library](glob/index.html)
4344
* [The `semver` version collation library](semver/index.html)
4445
* [The `serialize` value encoding/decoding library](serialize/index.html)

src/libextra/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ pub mod lru_cache;
7373
// And ... other stuff
7474

7575
pub mod url;
76-
pub mod getopts;
7776
pub mod json;
7877
pub mod tempfile;
7978
pub mod time;

src/libextra/test.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
// simplest interface possible for representing and running tests
1616
// while providing a base that other test frameworks may build off of.
1717

18+
extern mod getopts;
1819
extern mod term;
1920

20-
use getopts;
21-
use getopts::groups;
2221
use json::ToJson;
2322
use json;
2423
use serialize::Decodable;
@@ -209,29 +208,29 @@ pub struct TestOpts {
209208
/// Result of parsing the options.
210209
pub type OptRes = Result<TestOpts, ~str>;
211210

212-
fn optgroups() -> ~[getopts::groups::OptGroup] {
213-
~[groups::optflag("", "ignored", "Run ignored tests"),
214-
groups::optflag("", "test", "Run tests and not benchmarks"),
215-
groups::optflag("", "bench", "Run benchmarks instead of tests"),
216-
groups::optflag("h", "help", "Display this message (longer with --help)"),
217-
groups::optopt("", "save-metrics", "Location to save bench metrics",
211+
fn optgroups() -> ~[getopts::OptGroup] {
212+
~[getopts::optflag("", "ignored", "Run ignored tests"),
213+
getopts::optflag("", "test", "Run tests and not benchmarks"),
214+
getopts::optflag("", "bench", "Run benchmarks instead of tests"),
215+
getopts::optflag("h", "help", "Display this message (longer with --help)"),
216+
getopts::optopt("", "save-metrics", "Location to save bench metrics",
218217
"PATH"),
219-
groups::optopt("", "ratchet-metrics",
218+
getopts::optopt("", "ratchet-metrics",
220219
"Location to load and save metrics from. The metrics \
221220
loaded are cause benchmarks to fail if they run too \
222221
slowly", "PATH"),
223-
groups::optopt("", "ratchet-noise-percent",
222+
getopts::optopt("", "ratchet-noise-percent",
224223
"Tests within N% of the recorded metrics will be \
225224
considered as passing", "PERCENTAGE"),
226-
groups::optopt("", "logfile", "Write logs to the specified file instead \
225+
getopts::optopt("", "logfile", "Write logs to the specified file instead \
227226
of stdout", "PATH"),
228-
groups::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
227+
getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
229228
"A.B")]
230229
}
231230

232231
fn usage(binary: &str, helpstr: &str) {
233232
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
234-
println!("{}", groups::usage(message, optgroups()));
233+
println!("{}", getopts::usage(message, optgroups()));
235234
println!("");
236235
if helpstr == "help" {
237236
println!("{}", "\
@@ -261,7 +260,7 @@ Test Attributes:
261260
pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
262261
let args_ = args.tail();
263262
let matches =
264-
match groups::getopts(args_, optgroups()) {
263+
match getopts::getopts(args_, optgroups()) {
265264
Ok(m) => m,
266265
Err(f) => return Some(Err(f.to_err_msg()))
267266
};

0 commit comments

Comments
 (0)