compiletest: show usage/help when passed no args

instead of this panic:
```
thread '<main>' panicked at 'index out of bounds: the len is 1 but the
index is 1', src/libcollections/vec.rs:1110
```

It still panics, just like `-h` does, so it should be okay in this
regard.
This commit is contained in:
Emanuel Czirai 2015-10-25 11:48:56 +01:00
parent 04e497c005
commit 351efd55e9

View File

@ -92,7 +92,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
optflag("h", "help", "show this message"));
let (argv0, args_) = args.split_first().unwrap();
if args[1] == "-h" || args[1] == "--help" {
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(&message, &groups));
println!("");