From b60e93715fa589c63f2680c59380a7dabc7ddf92 Mon Sep 17 00:00:00 2001 From: S John CD Date: Thu, 16 May 2024 11:56:22 -0700 Subject: [PATCH] fix: tests when running on Windows --- TODO.md | 2 ++ deps/tests/associated_types.rs | 3 +++ deps/tests/async_traits2.rs | 3 +++ deps/tests/error-file.rs | 11 ++++++----- deps/tests/macros.rs | 2 ++ deps/tests/piped.rs | 10 +++++----- deps/tests/tar-compress.rs | 11 ++++++----- deps/tests/traits2.rs | 3 +++ 8 files changed, 30 insertions(+), 15 deletions(-) diff --git a/TODO.md b/TODO.md index 370ae740..457afa47 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,7 @@ # TODO +- fix leaky tests when using nextest on Windows + - review each .md file in turn [Introduction](src/index.md) polish the intro diff --git a/deps/tests/associated_types.rs b/deps/tests/associated_types.rs index 0f327736..09677137 100644 --- a/deps/tests/associated_types.rs +++ b/deps/tests/associated_types.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + trait Iterator { type Item; // <-- associated type // in Impl, use e.g. `Iterator` @@ -12,5 +14,6 @@ trait Add { fn add(self, rhs: Rhs) -> Self::Output; } +// TODO #[test] fn test() {} diff --git a/deps/tests/async_traits2.rs b/deps/tests/async_traits2.rs index 076675ec..065eb3ee 100644 --- a/deps/tests/async_traits2.rs +++ b/deps/tests/async_traits2.rs @@ -1,3 +1,6 @@ +// TODO +#![allow(dead_code)] + trait Container { fn items(&self) -> impl Iterator; // <-- return Impl in a trait } diff --git a/deps/tests/error-file.rs b/deps/tests/error-file.rs index 2fb7dfaf..35a3b640 100644 --- a/deps/tests/error-file.rs +++ b/deps/tests/error-file.rs @@ -1,10 +1,11 @@ -use std::fs::File; -use std::io::Error; -use std::process::Command; -use std::process::Stdio; - #[test] +#[cfg(target_family = "unix")] fn test() -> Result<(), Error> { + use std::fs::File; + use std::io::Error; + use std::process::Command; + use std::process::Stdio; + let outputs = File::create("out.txt")?; let errors = outputs.try_clone()?; diff --git a/deps/tests/macros.rs b/deps/tests/macros.rs index d791df86..c1765d9b 100644 --- a/deps/tests/macros.rs +++ b/deps/tests/macros.rs @@ -1,4 +1,6 @@ #![allow(clippy::useless_vec)] +#![allow(dead_code)] +// TODO ^ #[test] fn test() { diff --git a/deps/tests/piped.rs b/deps/tests/piped.rs index dc61a9d3..365154c2 100644 --- a/deps/tests/piped.rs +++ b/deps/tests/piped.rs @@ -1,10 +1,10 @@ -use std::process::Command; -use std::process::Stdio; - -use anyhow::Result; - #[test] +#[cfg(target_family = "unix")] fn test() -> Result<()> { + use std::process::Command; + use std::process::Stdio; + use anyhow::Result; + let directory = std::env::current_dir()?; let mut du_output_child = Command::new("du") .arg("-ah") diff --git a/deps/tests/tar-compress.rs b/deps/tests/tar-compress.rs index 00d2ccc2..4c934988 100644 --- a/deps/tests/tar-compress.rs +++ b/deps/tests/tar-compress.rs @@ -1,10 +1,11 @@ -use std::fs::File; - -use flate2::write::GzEncoder; -use flate2::Compression; - #[test] +#[cfg(target_family = "unix")] fn test() -> Result<(), std::io::Error> { + use std::fs::File; + + use flate2::write::GzEncoder; + use flate2::Compression; + let tar_gz = File::create("archive.tar.gz")?; let enc = GzEncoder::new(tar_gz, Compression::default()); let mut tar = tar::Builder::new(enc); diff --git a/deps/tests/traits2.rs b/deps/tests/traits2.rs index 7bbae2bb..22b35190 100644 --- a/deps/tests/traits2.rs +++ b/deps/tests/traits2.rs @@ -1,3 +1,6 @@ +// TODO +#![allow(dead_code)] + trait Summary { fn summarize_author(&self) -> String;