From 1f8b18b99437dafac6ef242e817c41bf3e201654 Mon Sep 17 00:00:00 2001 From: J Robert Ray Date: Mon, 2 Dec 2024 15:48:59 -0800 Subject: [PATCH] Resolve compile errors in tests on Windows Signed-off-by: J Robert Ray --- crates/spfs/src/bootstrap_test.rs | 2 ++ crates/spfs/src/runtime/storage_test.rs | 2 ++ crates/spfs/src/storage/repository_test.rs | 5 +++++ crates/spfs/src/storage/tag_test.rs | 2 ++ 4 files changed, 11 insertions(+) diff --git a/crates/spfs/src/bootstrap_test.rs b/crates/spfs/src/bootstrap_test.rs index a039d9d77c..e9d96004f1 100644 --- a/crates/spfs/src/bootstrap_test.rs +++ b/crates/spfs/src/bootstrap_test.rs @@ -75,11 +75,13 @@ async fn test_shell_initialization_startup_scripts( std::env::set_var("SHELL", &shell_path); match crate::Shell::find_best(None).unwrap() { + #[cfg(unix)] crate::Shell::Bash(_) if shell == "tcsh" => { // Test will fail because we weren't able to // find the shell we are trying to test return; } + #[cfg(unix)] crate::Shell::Tcsh(_) if shell == "bash" => { // Test will fail because we weren't able to // find the shell we are trying to test diff --git a/crates/spfs/src/runtime/storage_test.rs b/crates/spfs/src/runtime/storage_test.rs index 2693950fe4..c507812164 100644 --- a/crates/spfs/src/runtime/storage_test.rs +++ b/crates/spfs/src/runtime/storage_test.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // https://github.com/spkenv/spk +#[cfg(unix)] use std::os::unix::fs::PermissionsExt; use futures::TryStreamExt; @@ -583,6 +584,7 @@ async fn test_runtime_ensure_extra_bind_mount_locations_exist(tmpdir: tempfile:: assert!(runtime.prepare_live_layers().await.is_ok()) } +#[cfg(unix)] #[rstest] fn test_makedirs_dont_change_existing(tmpdir: tempfile::TempDir) { let chkdir = tmpdir.path().join("my_dir"); diff --git a/crates/spfs/src/storage/repository_test.rs b/crates/spfs/src/storage/repository_test.rs index 33d24c74ba..2a0c9add51 100644 --- a/crates/spfs/src/storage/repository_test.rs +++ b/crates/spfs/src/storage/repository_test.rs @@ -4,7 +4,9 @@ use std::collections::HashSet; use std::iter::FromIterator; +#[cfg(unix)] use std::os::unix::fs::{MetadataExt, PermissionsExt}; +#[cfg(unix)] use std::sync::Arc; use rstest::rstest; @@ -12,6 +14,7 @@ use rstest::rstest; use super::Ref; use crate::encoding::prelude::*; use crate::fixtures::*; +#[cfg(unix)] use crate::storage::fs; use crate::storage::prelude::*; use crate::tracking::TagSpec; @@ -58,6 +61,7 @@ async fn test_find_aliases( assert_eq!(actual, expected); } +#[cfg(unix)] #[rstest] #[tokio::test] async fn test_commit_mode_fs(tmpdir: tempfile::TempDir) { @@ -109,6 +113,7 @@ async fn test_commit_mode_fs(tmpdir: tempfile::TempDir) { ) } +#[cfg(unix)] #[rstest] #[case::fs(tmprepo("fs"))] #[case::tar(tmprepo("tar"))] diff --git a/crates/spfs/src/storage/tag_test.rs b/crates/spfs/src/storage/tag_test.rs index df96af8dee..b4a112efe4 100644 --- a/crates/spfs/src/storage/tag_test.rs +++ b/crates/spfs/src/storage/tag_test.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // https://github.com/spkenv/spk +#[cfg(unix)] use std::os::unix::fs::MetadataExt; use chrono::prelude::*; @@ -107,6 +108,7 @@ async fn test_tag_no_duplication( ); } +#[cfg(unix)] #[rstest] #[tokio::test] async fn test_tag_permissions(tmpdir: tempfile::TempDir) {