Skip to content

Commit 3796f79

Browse files
authored
Merge pull request #147 from cakebaker/tests_fix_unused_import_warnings
tests: fix "unused import" warnings on Windows
2 parents 1471205 + ea8f471 commit 3796f79

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

tests/by-util/test_last.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) symdir somefakedir
66

7+
#[cfg(unix)]
78
use crate::common::util::TestScenario;
89

10+
#[cfg(unix)]
911
use regex::Regex;
10-
use std::fs;
11-
use std::io::Write;
1212

1313
#[test]
1414
#[cfg(unix)]
@@ -93,19 +93,18 @@ fn test_timestamp_format_iso() {
9393
#[test]
9494
#[cfg(unix)]
9595
fn test_short_invalid_utmp_file() {
96-
let filepath = "/tmp/testfile";
97-
let testfile = fs::File::create(filepath);
96+
let (at, mut ucmd) = at_and_ucmd!();
97+
let file = "testfile";
9898
// Random bytes
99-
let data: Vec<u8> = vec![
99+
let data = [
100100
4, 5, 6, 16, 8, 13, 2, 12, 5, 3, 11, 5, 1, 13, 1, 1, 0, 9, 5, 5, 2, 8, 4,
101101
];
102-
let _ = testfile.unwrap().write_all(&data);
102+
at.write_bytes(file, &data);
103103

104104
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]*")
105105
.unwrap();
106106

107-
new_ucmd!()
108-
.arg(format!("--file={filepath}"))
107+
ucmd.arg(format!("--file={file}"))
109108
.succeeds()
110109
.stdout_matches(&regex);
111110
}

tests/by-util/test_setsid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod unix {
161161

162162
#[cfg(not(target_family = "unix"))]
163163
mod non_unix {
164-
use crate::common::util::{TestScenario, UCommand};
164+
use crate::common::util::TestScenario;
165165

166166
#[test]
167167
fn unsupported_platforms() {

0 commit comments

Comments
 (0)