From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/sysinfo/tests/code_checkers/headers.rs | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 vendor/sysinfo/tests/code_checkers/headers.rs (limited to 'vendor/sysinfo/tests/code_checkers/headers.rs') diff --git a/vendor/sysinfo/tests/code_checkers/headers.rs b/vendor/sysinfo/tests/code_checkers/headers.rs new file mode 100644 index 000000000..ac7a34ddb --- /dev/null +++ b/vendor/sysinfo/tests/code_checkers/headers.rs @@ -0,0 +1,59 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use super::utils::{show_error, TestResult}; +use std::path::Path; + +pub fn check_license_header(content: &str, p: &Path) -> TestResult { + let mut lines = content.lines(); + let next = lines.next(); + let header = "// Take a look at the license at the top of the repository in the LICENSE file."; + + match next { + Some(s) if s == header => { + let next = lines.next(); + match next { + Some("") => TestResult { + nb_tests: 1, + nb_errors: 0, + }, + Some(s) => { + show_error( + p, + &format!("Expected empty line after license header, found `{}`", s), + ); + TestResult { + nb_tests: 1, + nb_errors: 1, + } + } + None => { + show_error(p, "This file should very likely not exist..."); + TestResult { + nb_tests: 1, + nb_errors: 1, + } + } + } + } + Some(s) => { + show_error( + p, + &format!( + "Expected license header at the top of the file (`{}`), found: `{}`", + header, s + ), + ); + TestResult { + nb_tests: 1, + nb_errors: 1, + } + } + None => { + show_error(p, "This (empty?) file should very likely not exist..."); + TestResult { + nb_tests: 1, + nb_errors: 1, + } + } + } +} -- cgit v1.2.3