Skip to content

Commit 2a541dd

Browse files
committed
style: use one variant of target_family conditional compilation
#[cfg(unix)] and #[cfg(target_family = "unix")] are equivalent per the [docs](https://doc.rust-lang.org/reference/conditional-compilation.html#unix-and-windows). Let's stick to the most explicit of them.
1 parent 285e3cc commit 2a541dd

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

agent-control/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ opentelemetry-appender-tracing = { version = "0.31.1", features = [
7272
] }
7373
async-trait = "0.1.89"
7474

75-
[target.'cfg(unix)'.dependencies]
75+
[target.'cfg(target_family = "unix")'.dependencies]
7676
nix = { workspace = true, features = ["signal", "user", "hostname"] }
7777

78-
[target.'cfg(windows)'.dependencies]
79-
80-
8178
[dev-dependencies]
8279
assert_cmd = { workspace = true }
8380
predicates = { workspace = true }

agent-control/src/sub_agent/on_host/command/command_os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl CommandOSStarted {
124124
}
125125
}
126126

127-
#[cfg(unix)]
127+
#[cfg(target_family = "unix")]
128128
mod unix {
129129
use crate::sub_agent::on_host::command::{command_os::CommandOSStarted, error::CommandError};
130130

@@ -163,7 +163,7 @@ mod unix {
163163
}
164164

165165
//TODO Properly design unix/windows shutdown when Windows support is added
166-
#[cfg(windows)]
166+
#[cfg(target_family = "windows")]
167167
mod windows {
168168
use crate::sub_agent::on_host::command::{command_os::CommandOSStarted, error::CommandError};
169169

agent-control/tests/on_host/cli.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn print_debug_info() -> Result<(), Box<dyn std::error::Error>> {
4545
Ok(())
4646
}
4747

48-
#[cfg(unix)]
48+
#[cfg(target_family = "unix")]
4949
#[test]
5050
fn does_not_run_if_no_root() -> Result<(), Box<dyn std::error::Error>> {
5151
let dir = TempDir::new()?;
@@ -58,7 +58,7 @@ fn does_not_run_if_no_root() -> Result<(), Box<dyn std::error::Error>> {
5858
Ok(())
5959
}
6060

61-
#[cfg(unix)]
61+
#[cfg(target_family = "unix")]
6262
#[test]
6363
fn basic_startup() -> Result<(), Box<dyn std::error::Error>> {
6464
use std::time::Duration;
@@ -108,7 +108,7 @@ logs:
108108
Ok(())
109109
}
110110

111-
#[cfg(unix)]
111+
#[cfg(target_family = "unix")]
112112
#[test]
113113
fn custom_logging_format() -> Result<(), Box<dyn std::error::Error>> {
114114
use std::time::Duration;
@@ -158,7 +158,7 @@ server:
158158
Ok(())
159159
}
160160

161-
#[cfg(unix)]
161+
#[cfg(target_family = "unix")]
162162
#[test]
163163
#[ignore = "requires root"]
164164
fn custom_directory_overrides_as_root() -> Result<(), Box<dyn std::error::Error>> {
@@ -234,7 +234,7 @@ server:
234234
Ok(())
235235
}
236236

237-
#[cfg(unix)]
237+
#[cfg(target_family = "unix")]
238238
#[test]
239239
fn runs_with_no_config() -> Result<(), Box<dyn std::error::Error>> {
240240
use std::{env, time::Duration};

0 commit comments

Comments
 (0)