mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Check licenses
This commit is contained in:
parent
139214d8ca
commit
239a6012eb
3 changed files with 44 additions and 4 deletions
|
@ -20,7 +20,7 @@ use walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
codegen::Mode,
|
codegen::Mode,
|
||||||
not_bash::{fs2, pushd, pushenv, rm_rf, run},
|
not_bash::{fs2, pushd, pushenv, rm_rf},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use anyhow::{bail, Context as _, Result};
|
pub use anyhow::{bail, Context as _, Result};
|
||||||
|
|
|
@ -54,7 +54,8 @@ pub mod fs2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! _run {
|
#[macro_export]
|
||||||
|
macro_rules! run {
|
||||||
($($expr:expr),*) => {
|
($($expr:expr),*) => {
|
||||||
run!($($expr),*; echo = true)
|
run!($($expr),*; echo = true)
|
||||||
};
|
};
|
||||||
|
@ -65,7 +66,7 @@ macro_rules! _run {
|
||||||
$crate::not_bash::run_process(format!($($expr),*), false, Some($stdin))
|
$crate::not_bash::run_process(format!($($expr),*), false, Some($stdin))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub(crate) use _run as run;
|
pub use crate::run;
|
||||||
|
|
||||||
pub struct Pushd {
|
pub struct Pushd {
|
||||||
_p: (),
|
_p: (),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
|
|
||||||
use xtask::{
|
use xtask::{
|
||||||
codegen::{self, Mode},
|
codegen::{self, Mode},
|
||||||
not_bash::fs2,
|
not_bash::{fs2, run},
|
||||||
project_root, run_rustfmt, rust_files,
|
project_root, run_rustfmt, rust_files,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,6 +49,45 @@ fn rust_files_are_tidy() {
|
||||||
tidy_docs.finish();
|
tidy_docs.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_licenses() {
|
||||||
|
let expected = "
|
||||||
|
0BSD OR MIT OR Apache-2.0
|
||||||
|
Apache-2.0
|
||||||
|
Apache-2.0 / MIT
|
||||||
|
Apache-2.0 OR BSL-1.0
|
||||||
|
Apache-2.0 OR MIT
|
||||||
|
Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
|
||||||
|
Apache-2.0/MIT
|
||||||
|
BSD-2-Clause
|
||||||
|
BSD-3-Clause
|
||||||
|
CC0-1.0
|
||||||
|
ISC
|
||||||
|
MIT
|
||||||
|
MIT / Apache-2.0
|
||||||
|
MIT OR Apache-2.0
|
||||||
|
MIT/Apache-2.0
|
||||||
|
MIT/Apache-2.0 AND BSD-2-Clause
|
||||||
|
Unlicense OR MIT
|
||||||
|
Unlicense/MIT
|
||||||
|
Zlib
|
||||||
|
"
|
||||||
|
.lines()
|
||||||
|
.filter(|it| !it.is_empty())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap();
|
||||||
|
let mut licenses = meta
|
||||||
|
.split(|c| c == ',' || c == '{' || c == '}')
|
||||||
|
.filter(|it| it.contains(r#""license""#))
|
||||||
|
.map(|it| it.trim())
|
||||||
|
.map(|it| it[r#""license":"#.len()..].trim_matches('"'))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
licenses.sort();
|
||||||
|
licenses.dedup();
|
||||||
|
assert_eq!(licenses, expected);
|
||||||
|
}
|
||||||
|
|
||||||
fn check_todo(path: &Path, text: &str) {
|
fn check_todo(path: &Path, text: &str) {
|
||||||
let need_todo = &[
|
let need_todo = &[
|
||||||
// This file itself obviously needs to use todo (<- like this!).
|
// This file itself obviously needs to use todo (<- like this!).
|
||||||
|
|
Loading…
Reference in a new issue