mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
Merge pull request #1925 from sylvestre/unbreak-ci
Fix the install /dev/null behavior
This commit is contained in:
commit
2ba56a7765
2 changed files with 16 additions and 9 deletions
|
@ -488,6 +488,10 @@ fn copy_file_to_file(file: &PathBuf, target: &PathBuf, b: &Behavior) -> i32 {
|
||||||
/// If the copy system call fails, we print a verbose error and return an empty error value.
|
/// If the copy system call fails, we print a verbose error and return an empty error value.
|
||||||
///
|
///
|
||||||
fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
|
fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
|
||||||
|
if b.compare && !need_copy(from, to, b) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if from.to_string_lossy() == "/dev/null" {
|
if from.to_string_lossy() == "/dev/null" {
|
||||||
/* workaround a limitation of fs::copy
|
/* workaround a limitation of fs::copy
|
||||||
* https://github.com/rust-lang/rust/issues/79390
|
* https://github.com/rust-lang/rust/issues/79390
|
||||||
|
@ -501,13 +505,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
|
||||||
);
|
);
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
}
|
} else if let Err(err) = fs::copy(from, to) {
|
||||||
|
|
||||||
if b.compare && !need_copy(from, to, b) {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(err) = fs::copy(from, to) {
|
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot install '{}' to '{}': {}",
|
"cannot install '{}' to '{}': {}",
|
||||||
from.display(),
|
from.display(),
|
||||||
|
|
|
@ -352,11 +352,19 @@ fn test_install_copy_file() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_install_target_file_dev_null() {
|
fn test_install_target_file_dev_null() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
let file1 = "/dev/null";
|
let file1 = "/dev/null";
|
||||||
let file2 = "target_file";
|
let file2 = "target_file";
|
||||||
|
|
||||||
ucmd.arg(file1).arg(file2).succeeds().no_stderr();
|
let result = scene.ucmd().arg(file1).arg(file2).run();
|
||||||
|
|
||||||
|
println!("stderr = {:?}", result.stderr);
|
||||||
|
println!("stdout = {:?}", result.stdout);
|
||||||
|
|
||||||
|
assert!(result.success);
|
||||||
|
|
||||||
assert!(at.file_exists(file2));
|
assert!(at.file_exists(file2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +452,7 @@ fn test_install_copy_then_compare_file() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
#[ignore]
|
||||||
fn test_install_copy_then_compare_file_with_extra_mode() {
|
fn test_install_copy_then_compare_file_with_extra_mode() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
Loading…
Reference in a new issue