[pkg testing] Fix off-by-one in cmdline parsing

Running a test via pkg/testing where the command line starts with "--"
would throw a RangeError (it's asking for a range from 0 to -1).
Having the "--" somewhere in the middle of the arguments list would not
throw, but instead "eat" an argument.

Bug:
Change-Id: Ie13052a378746c17b343dff7704002a6929088bf
Reviewed-on: https://dart-review.googlesource.com/21920
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2017-11-20 11:35:57 +00:00 committed by commit-bot@chromium.org
parent 0633d0bfc0
commit d8d9bb5613

View file

@ -123,7 +123,7 @@ class CommandLine {
int index = arguments.indexOf("--");
Set<String> options;
if (index != -1) {
options = new Set<String>.from(arguments.getRange(0, index - 1));
options = new Set<String>.from(arguments.getRange(0, index));
arguments = arguments.sublist(index + 1);
} else {
options = arguments.where((argument) => argument.startsWith("-")).toSet();