coreutils
coreutils copied to clipboard
feat: `coreutils shred --random-source`
Closes #5711
i know it is a draft but could you please add tests ? :) thanks
Hello @sylvestre I was getting to that 😄
Hey @cakebaker I have implemented the basic functionality to read some random bytes from the file. Are we supposed to print them on the terminal ? The command doesn't seem to do this at the moment
it should behave like GNU $ /usr/bin/shred --random-source=myfile a doesn't return anything
GNU testsuite comparison:
GNU test failed: tests/shred/shred-exact. tests/shred/shred-exact is passing on 'main'. Maybe you have to rebase?
to reproduce the issue: bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/shred/shred-exact
Currently, I'm getting this error when trying to run the command. Any tips on how to debug @sylvestre ?
The hello.txt
file is a dummy file I placed in the root of the repo
could you please replace your screenshot by copy and paste of the text? screenshots are terrible for accessibility and search thanks
/usr/bin/shred --random-source hello.txt a
/usr/bin/shred --random-source hello.txt
this is probably an argument issue with clap
I hope I'm understanding this correctly, but --random-source
should have .require_equals(true)
for this to work properly. (Another thing that will be solved by my new argument parser! 😄)
GNU testsuite comparison:
GNU test failed: tests/shred/shred-exact. tests/shred/shred-exact is passing on 'main'. Maybe you have to rebase?
The command seems to work after pulling from the upstream:main
branch. @sylvestre
@tertsdiepraam I don't think requires_equals
is necessary as the file path is the only necessary input of the function. If not, please explain how it would be necessary in this case 🙂
Sorry, I've misunderstood your previous explanation :)
I guess you saw that the test is failing, right?
The test I implemented in test_shred.rs
is passing. I don't know how to debug the GNU failing tests in the CI @sylvestre
I think the extra argument in this case would be the random seed @tertsdiepraam
Before the GNU tests, the rust test suite is broken: https://github.com/uutils/coreutils/actions/runs/7458371831/job/20292245014?pr=5746
Example:
--- TRY 3 STDERR: coreutils::tests test_shred::test_shred_remove_wipe ---
thread 'test_shred::test_shred_remove_wipe' panicked at 'Command was expected to succeed.
stdout =
stderr = thread 'main' panicked at 'cannot sample empty range', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:134:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
', tests/by-util/test_shred.rs:70:41
stack backtrace:
0: rust_begin_unwind
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
1: core::panicking::panic_fmt
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
2: tests::common::util::CmdResult::success
at ./tests/common/util.rs:388:9
3: tests::common::util::UCommand::succeeds
at ./tests/common/util.rs:1568:9
4: tests::test_shred::test_shred_remove_wipe
at ./tests/by-util/test_shred.rs:70:5
5: tests::test_shred::test_shred_remove_wipe::{{closure}}
at ./tests/by-util/test_shred.rs:64:29
6: core::ops::function::FnOnce::call_once
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
cargo test --features unix test_shred
should fail on your system
I think the problems are also rooted in the fact that I'm on Windows 😅