Skip to content

Commit 17a3142

Browse files
author
Joseph Rafael Ferrer
committed
Mark test_cp_proc_short_read as linux only
1 parent b684971 commit 17a3142

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

tree/tests/cp/mod.rs

+34-33
Original file line numberDiff line numberDiff line change
@@ -583,39 +583,6 @@ fn test_cp_preserve_slink_time() {
583583
fs::remove_dir_all(test_dir).unwrap();
584584
}
585585

586-
// Port of coreutils/tests/cp/proc-short-read.sh
587-
#[test]
588-
fn test_cp_proc_short_read() {
589-
let test_dir = &format!("{}/test_cp_proc_short_read", env!("CARGO_TARGET_TMPDIR"));
590-
let cpuinfo = "/proc/cpuinfo"; // TODO: Check if this exists in CI
591-
let out = &format!("{test_dir}/1");
592-
593-
fs::create_dir(test_dir).unwrap();
594-
595-
cp_test(&[cpuinfo, out], "", "", 0);
596-
597-
let mut original = String::new();
598-
let mut file = fs::File::open(cpuinfo).unwrap();
599-
file.read_to_string(&mut original).unwrap();
600-
601-
let mut copy = String::new();
602-
let mut file = fs::File::open(out).unwrap();
603-
file.read_to_string(&mut copy).unwrap();
604-
605-
let lines_original: Vec<_> = original.lines().collect();
606-
let lines_copy: Vec<_> = copy.lines().collect();
607-
608-
assert_eq!(lines_original.len(), lines_copy.len());
609-
for (line_original, line_copy) in lines_original.iter().zip(lines_copy.iter()) {
610-
if line_original.contains("MHz") || line_original.to_lowercase().contains("bogomips") {
611-
continue;
612-
}
613-
assert_eq!(line_original, line_copy);
614-
}
615-
616-
fs::remove_dir_all(test_dir).unwrap();
617-
}
618-
619586
// Port of coreutils/tests/cp/r-vs-symlink.sh
620587
#[test]
621588
fn test_cp_r_vs_symlink() {
@@ -833,6 +800,40 @@ fn test_cp_part_symlink() {
833800
}
834801
}
835802

803+
// Port of coreutils/tests/cp/proc-short-read.sh
804+
#[test]
805+
#[cfg_attr(not(target_os = "linux"), ignore)]
806+
fn test_cp_proc_short_read() {
807+
let test_dir = &format!("{}/test_cp_proc_short_read", env!("CARGO_TARGET_TMPDIR"));
808+
let cpuinfo = "/proc/cpuinfo";
809+
let out = &format!("{test_dir}/1");
810+
811+
fs::create_dir(test_dir).unwrap();
812+
813+
cp_test(&[cpuinfo, out], "", "", 0);
814+
815+
let mut original = String::new();
816+
let mut file = fs::File::open(cpuinfo).unwrap();
817+
file.read_to_string(&mut original).unwrap();
818+
819+
let mut copy = String::new();
820+
let mut file = fs::File::open(out).unwrap();
821+
file.read_to_string(&mut copy).unwrap();
822+
823+
let lines_original: Vec<_> = original.lines().collect();
824+
let lines_copy: Vec<_> = copy.lines().collect();
825+
826+
assert_eq!(lines_original.len(), lines_copy.len());
827+
for (line_original, line_copy) in lines_original.iter().zip(lines_copy.iter()) {
828+
if line_original.contains("MHz") || line_original.to_lowercase().contains("bogomips") {
829+
continue;
830+
}
831+
assert_eq!(line_original, line_copy);
832+
}
833+
834+
fs::remove_dir_all(test_dir).unwrap();
835+
}
836+
836837
// Port of coreutils/tests/cp/special-bits.sh
837838
//
838839
// This test needs root access and a non-root username passed in the

0 commit comments

Comments
 (0)