Skip to content

Commit

Permalink
Parse version numbers optionally without the patch version specified
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Nov 12, 2020
1 parent 71f09c5 commit 00f48fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dist/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static TOOLCHAIN_CHANNELS: &[&str] = &[
"nightly",
"beta",
"stable",
// Allow from 1.0.0 through to 9.999.99
r"\d{1}\.\d{1,3}\.\d{1,2}",
// Allow from 1.0.0 through to 9.999.99 with optional patch version
r"\d{1}\.\d{1,3}(?:\.\d{1,2})?",
];

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -951,6 +951,7 @@ mod tests {
("nightly", ("nightly", None, None)),
("beta", ("beta", None, None)),
("stable", ("stable", None, None)),
("0.0", ("0.0", None, None)),
("0.0.0", ("0.0.0", None, None)),
("0.0.0--", ("0.0.0", None, Some("-"))), // possibly a bug?
("9.999.99", ("9.999.99", None, None)),
Expand Down Expand Up @@ -986,7 +987,7 @@ mod tests {
assert_eq!(parsed.unwrap(), expected, "input: `{}`", input);
}

let failure_cases = vec!["anything", "00.0000.000", "3", "3.4", "", "--", "0.0.0-"];
let failure_cases = vec!["anything", "00.0000.000", "3", "", "--", "0.0.0-"];

for input in failure_cases {
let parsed = input.parse::<ParsedToolchainDesc>();
Expand Down

0 comments on commit 00f48fe

Please sign in to comment.