diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-14 16:14:29 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-14 16:14:29 +0100 |
commit | 5d17dfee2f042e33672c17710eaa2d36278599a3 (patch) | |
tree | 7153af51229c91857c1ec366f605a7f303ec74c8 /xtask/tests/tidy.rs | |
parent | 139214d8ca9b42a3966b45decd820d11cc056714 (diff) | |
parent | 239a6012eb97e4ec74ad975266436d6eb4ec9bec (diff) |
Merge #5376
5376: Check licenses r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask/tests/tidy.rs')
-rw-r--r-- | xtask/tests/tidy.rs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index fcfad609d..72088e414 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -5,7 +5,7 @@ use std::{ | |||
5 | 5 | ||
6 | use xtask::{ | 6 | use xtask::{ |
7 | codegen::{self, Mode}, | 7 | codegen::{self, Mode}, |
8 | not_bash::fs2, | 8 | not_bash::{fs2, run}, |
9 | project_root, run_rustfmt, rust_files, | 9 | project_root, run_rustfmt, rust_files, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -49,6 +49,45 @@ fn rust_files_are_tidy() { | |||
49 | tidy_docs.finish(); | 49 | tidy_docs.finish(); |
50 | } | 50 | } |
51 | 51 | ||
52 | #[test] | ||
53 | fn check_licenses() { | ||
54 | let expected = " | ||
55 | 0BSD OR MIT OR Apache-2.0 | ||
56 | Apache-2.0 | ||
57 | Apache-2.0 / MIT | ||
58 | Apache-2.0 OR BSL-1.0 | ||
59 | Apache-2.0 OR MIT | ||
60 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | ||
61 | Apache-2.0/MIT | ||
62 | BSD-2-Clause | ||
63 | BSD-3-Clause | ||
64 | CC0-1.0 | ||
65 | ISC | ||
66 | MIT | ||
67 | MIT / Apache-2.0 | ||
68 | MIT OR Apache-2.0 | ||
69 | MIT/Apache-2.0 | ||
70 | MIT/Apache-2.0 AND BSD-2-Clause | ||
71 | Unlicense OR MIT | ||
72 | Unlicense/MIT | ||
73 | Zlib | ||
74 | " | ||
75 | .lines() | ||
76 | .filter(|it| !it.is_empty()) | ||
77 | .collect::<Vec<_>>(); | ||
78 | |||
79 | let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); | ||
80 | let mut licenses = meta | ||
81 | .split(|c| c == ',' || c == '{' || c == '}') | ||
82 | .filter(|it| it.contains(r#""license""#)) | ||
83 | .map(|it| it.trim()) | ||
84 | .map(|it| it[r#""license":"#.len()..].trim_matches('"')) | ||
85 | .collect::<Vec<_>>(); | ||
86 | licenses.sort(); | ||
87 | licenses.dedup(); | ||
88 | assert_eq!(licenses, expected); | ||
89 | } | ||
90 | |||
52 | fn check_todo(path: &Path, text: &str) { | 91 | fn check_todo(path: &Path, text: &str) { |
53 | let need_todo = &[ | 92 | let need_todo = &[ |
54 | // This file itself obviously needs to use todo (<- like this!). | 93 | // This file itself obviously needs to use todo (<- like this!). |