From 1f0a716bad24164f663d5a0311527a3658d51932 Mon Sep 17 00:00:00 2001 From: Florent 'Skia' Jacquet Date: Wed, 5 Nov 2025 16:39:10 +0100 Subject: [PATCH 1/2] Fix typos --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 40fa446..4541265 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use std::fs::{File, metadata}; use std::path::Path; use std::process::Command; -/// tail a file or execite the fallback command +/// tail a file or execute the fallback command /// /// Attempts to tail a file. If the file doesn't exist or can't be read, /// runs the specified fallback command instead passing the specified file. @@ -14,7 +14,7 @@ use std::process::Command; /// Examples: /// tailor file.txt touch # tail file.txt, or touch file.txt /// tailor file.txt chmod 755 # tail file.txt, or chmod 755 file.txt -/// tailor config.json cp config.template.json # tail file.txt, or cp config.template.json config.json +/// tailor config.json cp config.template.json # tail config.json, or cp config.template.json config.json #[derive(Parser, Debug)] #[command(version, about, long_about, verbatim_doc_comment)] struct Args { From dc6a9ecafec722050d7eaf7842e11d2fb8d0e4e6 Mon Sep 17 00:00:00 2001 From: Florent 'Skia' Jacquet Date: Wed, 5 Nov 2025 16:39:35 +0100 Subject: [PATCH 2/2] tests: fix this too opinionated test suite to work on my machine Before those fixes, running the test suite resulted in the following errors: ``` running 9 tests test tests::test_can_tail_file_with_directory ... ok test tests::test_can_tail_file_with_nonexistent_file ... FAILED test tests::test_can_tail_file_with_existing_file ... ok test tests::test_can_tail_file_with_unreadable_file ... ok test tests::test_run_command_nonexistent_command ... ok test tests::test_run_command_success ... ok test tests::test_run_command_with_args ... ok test tests::test_main_fails_without_fallback_command ... FAILED test tests::test_run_command_calling_tailor_again ... ok failures: ---- tests::test_can_tail_file_with_nonexistent_file stdout ---- thread 'tests::test_can_tail_file_with_nonexistent_file' panicked at src/main.rs:114:9: Should not be able to tail a nonexistent file note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- tests::test_main_fails_without_fallback_command stdout ---- thread 'tests::test_main_fails_without_fallback_command' panicked at /home/skia/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: Unexpected success command=`"/home/skia/workspace/ubuntu/tailor/target/debug/tailor" "/tmp/nonexistent_file_12345"` code=0 stdout="" stderr="" failures: tests::test_can_tail_file_with_nonexistent_file tests::test_main_fails_without_fallback_command test result: FAILED. 7 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s ``` I believe this is because the test suite is too opinionated, and relies on an arbitrary file not existing. I happened to use that important file in my personal workflow, hence the test suite broke. Thankfully, I'm a nice contributor and was able to use my skills to fix this. It now passes on my machine. Thank you. --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4541265..23ff801 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,7 +110,10 @@ mod tests { #[test] fn test_can_tail_file_with_nonexistent_file() { - let result = can_tail_file("/tmp/nonexistent_file_12345").unwrap(); + let temp_file = NamedTempFile::new().unwrap(); + let file_path = temp_file.path().to_str().unwrap(); + std::fs::remove_file(file_path).unwrap(); + let result = can_tail_file(file_path).unwrap(); assert!(!result, "Should not be able to tail a nonexistent file"); } @@ -212,8 +215,11 @@ mod tests { #[test] fn test_main_fails_without_fallback_command() { + let temp_file = NamedTempFile::new().unwrap(); + let file_path = temp_file.path().to_str().unwrap(); + std::fs::remove_file(file_path).unwrap(); let mut cmd = Command::cargo_bin("tailor").unwrap(); - cmd.arg("/tmp/nonexistent_file_12345") + cmd.arg(file_path) .assert() .failure() .stderr(contains("no fallback command"));