Skip to content

Commit e69623b

Browse files
committed
Conditional compile for Unix, prevent windows CI failure
1 parent ba1f01f commit e69623b

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

vdev/src/testing/integration.rs

+26-20
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,32 @@ impl Compose {
155155
Ok(true) => {
156156
#[cfg(unix)]
157157
let mut config = ComposeConfig::parse(&original_path)?;
158+
let temp_file: NamedTempFile;
158159

159-
// Inject the networks block
160-
config.networks.insert(
161-
"default".to_string(),
162-
BTreeMap::from_iter([("name".to_string(), network.clone())]),
163-
);
164-
165-
// Create a named tempfile, there may be resource leakage here in case of SIGINT
166-
// Tried tempfile::tempfile() but this returns a File object without a usable path
167-
// https://docs.rs/tempfile/latest/tempfile/#resource-leaking
168-
let temp_file = Builder::new()
169-
.prefix("compose-temp-")
170-
.suffix(".yaml")
171-
.tempfile_in(&test_dir)
172-
.with_context(|| "Failed to create temporary compose file")?;
173-
174-
fs::write(
175-
temp_file.path(),
176-
serde_yaml::to_string(&config)
177-
.with_context(|| "Failed to serialize modified compose.yml".to_string())?,
178-
)?;
160+
#[cfg(unix)]
161+
{
162+
// Inject the networks block
163+
config.networks.insert(
164+
"default".to_string(),
165+
BTreeMap::from_iter([("name".to_string(), network.clone())]),
166+
);
167+
168+
// Create a named tempfile, there may be resource leakage here in case of SIGINT
169+
// Tried tempfile::tempfile() but this returns a File object without a usable path
170+
// https://docs.rs/tempfile/latest/tempfile/#resource-leaking
171+
temp_file = Builder::new()
172+
.prefix("compose-temp-")
173+
.suffix(".yaml")
174+
.tempfile_in(&test_dir)
175+
.with_context(|| "Failed to create temporary compose file")?;
176+
177+
fs::write(
178+
temp_file.path(),
179+
serde_yaml::to_string(&config).with_context(|| {
180+
"Failed to serialize modified compose.yml".to_string()
181+
})?,
182+
)?;
183+
}
179184

180185
Ok(Some(Self {
181186
original_path,
@@ -184,6 +189,7 @@ impl Compose {
184189
#[cfg(unix)]
185190
config,
186191
network,
192+
#[cfg(unix)]
187193
temp_file,
188194
}))
189195
}

0 commit comments

Comments
 (0)