Merge pull request #147 from cakebaker/tests_fix_unused_import_warnings

tests: fix "unused import" warnings on Windows
This commit is contained in:
Sylvestre Ledru
2024-11-08 14:47:08 +01:00
committed by GitHub
2 changed files with 8 additions and 9 deletions

View File

@@ -4,11 +4,11 @@
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (words) symdir somefakedir // spell-checker:ignore (words) symdir somefakedir
#[cfg(unix)]
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
#[cfg(unix)]
use regex::Regex; use regex::Regex;
use std::fs;
use std::io::Write;
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
@@ -93,19 +93,18 @@ fn test_timestamp_format_iso() {
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn test_short_invalid_utmp_file() { fn test_short_invalid_utmp_file() {
let filepath = "/tmp/testfile"; let (at, mut ucmd) = at_and_ucmd!();
let testfile = fs::File::create(filepath); let file = "testfile";
// Random bytes // Random bytes
let data: Vec<u8> = vec![ let data = [
4, 5, 6, 16, 8, 13, 2, 12, 5, 3, 11, 5, 1, 13, 1, 1, 0, 9, 5, 5, 2, 8, 4, 4, 5, 6, 16, 8, 13, 2, 12, 5, 3, 11, 5, 1, 13, 1, 1, 0, 9, 5, 5, 2, 8, 4,
]; ];
let _ = testfile.unwrap().write_all(&data); at.write_bytes(file, &data);
let regex = Regex::new(r"\n\S*\sbegins\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*[0-9][0-9]?\s*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\s*[0-9]*") let regex = Regex::new(r"\n\S*\sbegins\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*[0-9][0-9]?\s*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\s*[0-9]*")
.unwrap(); .unwrap();
new_ucmd!() ucmd.arg(format!("--file={file}"))
.arg(format!("--file={filepath}"))
.succeeds() .succeeds()
.stdout_matches(&regex); .stdout_matches(&regex);
} }

View File

@@ -161,7 +161,7 @@ mod unix {
#[cfg(not(target_family = "unix"))] #[cfg(not(target_family = "unix"))]
mod non_unix { mod non_unix {
use crate::common::util::{TestScenario, UCommand}; use crate::common::util::TestScenario;
#[test] #[test]
fn unsupported_platforms() { fn unsupported_platforms() {