Conversation
|
Great start. Could you please add tests? |
Yes, any advice? |
|
And also, more unit tests would be better. If it cannot run on Windows, you can disable it for Windows simply. eg. #[cfg(target_os = "linux")]
#[test]
fn test_something() {
...
}At least you can write unit tests about parsing arguments? |
|
Could you please fix the CI failures? |
|
I think this file will help you to be compatible with macOS and other *NIX implementations. https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/features/signals.rs The Windows implementation much different with *NIX implementation, so you can simply disable it. #[cfg(target_family = "unix")]#[cfg(target_family = "unix")]
fn do_something(){}
#[cfg(not(target_family = "unix"))]
fn do_something(){} |
|
Behavior seems doesn't match |
| #[cfg(unix)] | ||
| let sig_num = if let Some(signal) = obs_signal { | ||
| signal | ||
| } else if let Some(signal) = matches.get_one::<String>("signal") { | ||
| parse_signal_value(signal)? | ||
| } else { | ||
| 15_usize //SIGTERM | ||
| }; | ||
|
|
||
| #[cfg(unix)] | ||
| let sig_name = signal_name_by_value(sig_num); | ||
| // Signal does not support converting from EXIT | ||
| // Instead, nix::signal::kill expects Option::None to properly handle EXIT | ||
| #[cfg(unix)] | ||
| let sig: Option<Signal> = if sig_name.is_some_and(|name| name == "EXIT") { | ||
| None | ||
| } else { | ||
| let sig = (sig_num as i32) | ||
| .try_into() | ||
| .map_err(|e| std::io::Error::from_raw_os_error(e as i32))?; | ||
| Some(sig) | ||
| }; |
| #[cfg(unix)] | ||
| let echo = matches.get_flag("echo"); | ||
| #[cfg(unix)] | ||
| kill(&pids, sig, echo); |
There was a problem hiding this comment.
same, or a function
|
fells confusing, the implementation should be correct but the behavior not. could you give some help? @sylvestre @cakebaker |
do you have details ? |
Here's the details |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. |
#27