Skip to content

Commit

Permalink
Handle llvm_version with suffix like "12.0.0libcxx"
Browse files Browse the repository at this point in the history
  • Loading branch information
12101111 committed Mar 26, 2021
1 parent 0ced530 commit 656f6ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,11 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> {
}

pub fn extract_llvm_version(version: &str) -> Option<u32> {
let version_without_suffix = version.trim_end_matches("git").split('-').next().unwrap();
let pat = |c: char| !c.is_ascii_digit() && c != '.';
let version_without_suffix = match version.find(pat) {
Some(pos) => &version[..pos],
None => version,
};
let components: Vec<u32> = version_without_suffix
.split('.')
.map(|s| s.parse().expect("Malformed version component"))
Expand Down
4 changes: 4 additions & 0 deletions src/tools/compiletest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ fn test_extract_llvm_version() {
assert_eq!(extract_llvm_version("9.0.1-rust-1.43.0-dev"), Some(90001));
assert_eq!(extract_llvm_version("9.3.1-rust-1.43.0-dev"), Some(90301));
assert_eq!(extract_llvm_version("10.0.0-rust"), Some(100000));
assert_eq!(extract_llvm_version("11.1.0"), Some(110100));
assert_eq!(extract_llvm_version("12.0.0libcxx"), Some(120000));
assert_eq!(extract_llvm_version("12.0.0-rc3"), Some(120000));
assert_eq!(extract_llvm_version("13.0.0git"), Some(130000));
}

0 comments on commit 656f6ac

Please sign in to comment.