Skip to content

Commit

Permalink
removed test cases with unstable libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikrant2691 committed Mar 22, 2024
1 parent 0b4993d commit 9f0caf4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
18 changes: 3 additions & 15 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,9 @@ fn test_cp_arg_interactive_update_overwrite_older() {
// -u -i *WILL* show the prompt to validate the override.
// Therefore, the error code depends on the prompt response.
let (at, mut ucmd) = at_and_ucmd!();
at.touch_with_file_date("b","202403211030");
at.touch_with_file_date("a","202403211031");
at.touch("b");
std::thread::sleep(Duration::from_secs(1));
at.touch("a");
ucmd.args(&["-i", "-u", "a", "b"])
.pipe_in("N\n")
.fails()
Expand All @@ -531,19 +532,6 @@ fn test_cp_arg_interactive_update_overwrite_older() {
.stderr_is("cp: overwrite 'b'? ");
}

#[test]
#[cfg(not(any(target_os = "android", target_os = "freebsd")))]
fn test_cp_arg_interactive_update_with_create_dates_equal() {
// -u -i *WILL NOT* show the prompt to validate the override.
let (at, mut ucmd) = at_and_ucmd!();
// Create files with the same creation date
at.touch_with_file_date("b","202403211030");
at.touch_with_file_date("a","202403211030");
ucmd.args(&["-i", "-u", "a", "b"])
.pipe_in("N\n")
.succeeds().no_stdout();
}

#[test]
#[cfg(not(target_os = "android"))]
fn test_cp_arg_interactive_verbose() {
Expand Down
26 changes: 2 additions & 24 deletions tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#![allow(dead_code)]

use chrono::{NaiveDateTime, Utc, DateTime};
#[cfg(unix)]
use nix::pty::OpenptyResult;
use pretty_assertions::assert_eq;
Expand All @@ -22,7 +21,7 @@ use std::collections::VecDeque;
#[cfg(not(windows))]
use std::ffi::CString;
use std::ffi::{OsStr, OsString};
use std::fs::{self, hard_link, remove_file, File, OpenOptions, FileTimes};
use std::fs::{self, hard_link, remove_file, File, OpenOptions};
use std::io::{self, BufWriter, Read, Result, Write};
#[cfg(unix)]
use std::os::fd::OwnedFd;
Expand All @@ -41,7 +40,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::rc::Rc;
use std::sync::mpsc::{self, RecvTimeoutError};
use std::thread::{sleep, JoinHandle};
use std::time::{Duration, Instant, SystemTime};
use std::time::{Duration, Instant};
use std::{env, hint, mem, thread};
use tempfile::{Builder, TempDir};

Expand Down Expand Up @@ -958,27 +957,6 @@ impl AtPath {
File::create(self.plus(file)).unwrap();
}

pub fn touch_with_file_date<P: AsRef<Path>>(&self, file: P, time: &str) {
let file = file.as_ref();
log_info("touch", self.plus_as_string(file));
let file_time = Self::parse_str_time_to_system_time(time);
let times = FileTimes::new()
.set_accessed(file_time)
.set_modified(file_time);
File::create(self.plus(file))
.unwrap()
.set_times(times)
.unwrap();
}

fn parse_str_time_to_system_time(time: &str) -> SystemTime {
// Parse the time string (YYYYMMDDhhmm) to a DateTime<Utc>
let naive_date_time = NaiveDateTime::parse_from_str(time, "%Y%m%d%H%M").unwrap();
let date_time: DateTime<Utc> = DateTime::<Utc>::from_naive_utc_and_offset(naive_date_time,Utc);
// Convert the DateTime<Utc> to a SystemTime
date_time.into()
}

#[cfg(not(windows))]
pub fn mkfifo(&self, fifo: &str) {
let full_path = self.plus_as_string(fifo);
Expand Down

0 comments on commit 9f0caf4

Please sign in to comment.