Skip to content

Commit 51c1c64

Browse files
committed
fix: protect Unix-specific imports with cfg attributes
- Add #[cfg(unix)] to std::os::unix::fs::PermissionsExt imports - Protect Unix-specific test functions with #[cfg(unix)] - Fixes compilation on Windows by conditionally compiling Unix-only code - Resolves GitHub Actions workflow failure on Windows runners Affected files: - src/e2e/tasks/setup_ssh_key.rs - src/infrastructure/tofu/template/renderer/mod.rs - src/infrastructure/ansible/template/renderer/inventory.rs - src/domain/template/embedded.rs All tests pass on Unix systems and code now compiles cross-platform.
1 parent c1888b2 commit 51c1c64

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

src/domain/template/embedded.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl TemplateManager {
225225
#[cfg(test)]
226226
mod tests {
227227
use super::*;
228+
#[cfg(unix)]
228229
use std::os::unix::fs::PermissionsExt;
229230
use tempfile::TempDir;
230231

src/e2e/tasks/setup_ssh_key.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! to prevent SSH client warnings and ensure secure key handling.
1717
1818
use anyhow::{Context, Result};
19+
#[cfg(unix)]
1920
use std::os::unix::fs::PermissionsExt;
2021
use tempfile::TempDir;
2122
use tracing::info;

src/infrastructure/ansible/template/renderer/inventory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ mod tests {
388388
));
389389
}
390390

391+
#[cfg(unix)]
391392
#[test]
392393
fn it_should_fail_when_output_directory_is_readonly() {
393394
let temp_dir = TempDir::new().expect("Failed to create temp directory");

src/infrastructure/tofu/template/renderer/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ mod tests {
511511
}
512512

513513
// Error Handling Tests
514+
#[cfg(unix)]
514515
#[tokio::test]
515516
async fn it_should_fail_when_directory_creation_denied() {
516517
// Create a read-only directory to simulate permission denied
@@ -593,6 +594,7 @@ mod tests {
593594
}
594595
}
595596

597+
#[cfg(unix)]
596598
#[tokio::test]
597599
async fn it_should_fail_when_file_copy_permission_denied() {
598600
let temp_dir = tempfile::TempDir::new().expect("Failed to create temp directory");

0 commit comments

Comments
 (0)