Skip to content

Commit be00b37

Browse files
authored
buf_copy.rs: don't test a trivial io::copy wrapper (#12344)
Co-authored-by: oech3 <>
1 parent c90f1ea commit be00b37

1 file changed

Lines changed: 1 addition & 28 deletions

File tree

src/uucore/src/lib/features/buf_copy.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ pub mod other;
2020
pub use other::copy_stream;
2121

2222
#[cfg(test)]
23+
#[cfg(any(target_os = "linux", target_os = "android"))] // copy_stream is a thin wrapper for io::copy. nothing to test...
2324
mod tests {
2425
use super::*;
2526
use std::fs::File;
2627
use tempfile::tempdir;
2728

28-
#[cfg(target_os = "linux")]
2929
use {
3030
std::fs::OpenOptions,
3131
std::{
@@ -36,7 +36,6 @@ mod tests {
3636

3737
use std::io::{Read, Write};
3838

39-
#[cfg(target_os = "linux")]
4039
fn new_temp_file() -> File {
4140
let temp_dir = tempdir().unwrap();
4241
OpenOptions::new()
@@ -49,7 +48,6 @@ mod tests {
4948
}
5049

5150
#[test]
52-
#[cfg(unix)]
5351
fn test_copy_stream() {
5452
let mut dest_file = new_temp_file();
5553

@@ -71,29 +69,4 @@ mod tests {
7169

7270
assert_eq!(buf, data);
7371
}
74-
75-
#[test]
76-
#[cfg(not(unix))]
77-
// Test for non-unix platforms. We use regular files instead.
78-
fn test_copy_stream() {
79-
let temp_dir = tempdir().unwrap();
80-
let src_path = temp_dir.path().join("src.txt");
81-
let dest_path = temp_dir.path().join("dest.txt");
82-
83-
let mut src_file = File::create(&src_path).unwrap();
84-
let mut dest_file = File::create(&dest_path).unwrap();
85-
86-
let data = b"Hello, world!";
87-
src_file.write_all(data).unwrap();
88-
src_file.sync_all().unwrap();
89-
90-
let mut src_file = File::open(&src_path).unwrap();
91-
copy_stream(&mut src_file, &mut dest_file).unwrap();
92-
93-
let mut dest_file = File::open(&dest_path).unwrap();
94-
let mut buf = Vec::new();
95-
dest_file.read_to_end(&mut buf).unwrap();
96-
97-
assert_eq!(buf, data);
98-
}
9972
}

0 commit comments

Comments
 (0)