cp: Fix broken symlinks to parent-dir
According to the GNU cp official documentation, a symlink is only created if all source paths are absolute, unless the destination files are in the current directory.
This fix solves this GNU cp incompatibility by:
- Adding verifications when handling symlinks, to ensure that a symlink with relative path are only created if the destination is within the current directory.
- Adding unit tests to cover this modifications, and ensure the behavior is correctly align with GNU documentation.
Fixes #6385.
GNU testsuite comparison:
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
GNU testsuite comparison:
Congrats! The gnu test tests/timeout/timeout is no longer failing!
GNU testsuite comparison:
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
CI still says the new test is broken, and at first glance the error message seems reasonable.
CI still says the new test is broken, and at first glance the error message seems reasonable.
The error caused by the backslash in Windows was solved, but there are still 4 tests failing only in Windows, I'll try to figure out why of those failures.
@luigieli do you have an update on this? thanks
@sylvestre Sorry for disappearing, I was really busy due to college, so I couldn't exhaust my debugging options and the bugs in Windows are still persisting. Would it be okay if I bring you a more detailed update on this by Monday?
As I promised, I tried to debug the Windows errors. I used a virtual machine with Windows 11 in it to try reproducing the errors, but it was unsuccessful, for some reason when I cargo test in the VM, almost no tests were made, after activating developer mode in Windows, I could indeed run the tests, but all of them passed, even the ones that are failing in the CI. I'm not so used to windows, so I would appreciate any ideas on how to proceed.
Fails on Windows on:
--- TRY 3 STDERR: coreutils::tests test_cp::test_symlink_mode_overwrite ---
thread 'test_cp::test_symlink_mode_overwrite' panicked at tests\by-util\test_cp.rs:5908:14:
assertion failed: `(left == right)`
Diff < left / right > :
<cp: .\t: can make relative symbolic links only in current directory
<cp: .\t: can make relative symbolic links only in current directory
>cp: will not overwrite just-created '.\t' with 'b\t'
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
1: core::panicking::panic_fmt
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
2: tests::common::util::CmdResult::stderr_is<ref$<str$> >
at .\tests\common\util.rs:586
3: tests::common::util::CmdResult::stderr_only<ref$<str$> >
at .\tests\common\util.rs:642
4: tests::test_cp::test_symlink_mode_overwrite
at .\tests\by-util\test_cp.rs:5903
5: tests::test_cp::test_symlink_mode_overwrite::closure$0
at .\tests\by-util\test_cp.rs:5885
6: core::ops::function::FnOnce::call_once<tests::test_cp::test_symlink_mode_overwrite::closure_env$0,tuple$<> >
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\ops\function.rs:250
7: core::ops::function::FnOnce::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@luigieli it is still marked as draft, are you still working on it? thanks
@sylvestre Yes, I'm still trying to debug and solve the fails on Windows. I'll bring news as soon as possible. Appreciate the waiting. Thanks!
ok, thanks :)
please reopen when ready!