From a33b386330c3312a7ccbde932789667aebea2d19 Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Mon, 26 Aug 2024 13:36:38 -0400 Subject: [PATCH 1/3] Replace tempdir with tempfile Signed-off-by: Lann Martin --- Cargo.lock | 80 ++++---------------- crates/factor-key-value/Cargo.toml | 2 +- crates/factor-key-value/tests/factor_test.rs | 8 +- 3 files changed, 19 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92c6a8ed63..75c0efb31c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2564,12 +2564,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures" version = "0.3.30" @@ -5842,19 +5836,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -5899,21 +5880,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -6000,15 +5966,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "reborrow" version = "0.5.5" @@ -6167,15 +6124,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "reqwest" version = "0.11.27" @@ -7363,7 +7311,7 @@ dependencies = [ "spin-factors-test", "spin-key-value", "spin-world", - "tempdir", + "tempfile", "tokio", "toml 0.8.14", ] @@ -8369,26 +8317,17 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231" -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand 2.0.2", + "once_cell", "rustix 0.38.32", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -10413,6 +10352,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" diff --git a/crates/factor-key-value/Cargo.toml b/crates/factor-key-value/Cargo.toml index cab19b014f..64df403528 100644 --- a/crates/factor-key-value/Cargo.toml +++ b/crates/factor-key-value/Cargo.toml @@ -18,7 +18,7 @@ spin-factors-test = { path = "../factors-test" } tokio = { version = "1", features = ["macros", "rt"] } spin-factor-key-value-spin = { path = "../factor-key-value-spin" } spin-factor-key-value-redis = { path = "../factor-key-value-redis" } -tempdir = "0.3" +tempfile = "3.12.0" [lints] diff --git a/crates/factor-key-value/tests/factor_test.rs b/crates/factor-key-value/tests/factor_test.rs index 1b0facbf67..890e95ca9c 100644 --- a/crates/factor-key-value/tests/factor_test.rs +++ b/crates/factor-key-value/tests/factor_test.rs @@ -101,7 +101,7 @@ async fn custom_spin_key_value_works() -> anyhow::Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn custom_spin_key_value_works_with_absolute_path() -> anyhow::Result<()> { - let tmp_dir = tempdir::TempDir::new("example")?; + let tmp_dir = tempfile::TempDir::with_prefix("example")?; let db_path = tmp_dir.path().join("foo/custom.db"); // Check that the db does not exist yet - it will exist by the end of the test assert!(!db_path.exists()); @@ -132,7 +132,7 @@ async fn custom_spin_key_value_works_with_absolute_path() -> anyhow::Result<()> #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn custom_spin_key_value_works_with_relative_path() -> anyhow::Result<()> { - let tmp_dir = tempdir::TempDir::new("example")?; + let tmp_dir = tempfile::TempDir::with_prefix("example")?; let db_path = tmp_dir.path().join("custom.db"); // Check that the db does not exist yet - it will exist by the end of the test assert!(!db_path.exists()); @@ -176,7 +176,7 @@ async fn custom_redis_key_value_works() -> anyhow::Result<()> { #[tokio::test] async fn misconfigured_spin_key_value_fails() -> anyhow::Result<()> { - let tmp_dir = tempdir::TempDir::new("example")?; + let tmp_dir = tempfile::TempDir::with_prefix("example")?; let runtime_config = toml::toml! { [key_value_store.custom] type = "spin" @@ -198,7 +198,7 @@ async fn misconfigured_spin_key_value_fails() -> anyhow::Result<()> { // TODO(rylev): consider removing this test as it is really only a consequence of // toml deserialization and not a feature of the key-value store. async fn multiple_custom_key_value_uses_second_store() -> anyhow::Result<()> { - let tmp_dir = tempdir::TempDir::new("example")?; + let tmp_dir = tempfile::TempDir::with_prefix("example")?; let db_path = tmp_dir.path().join("custom.db"); // Check that the db does not exist yet - it will exist by the end of the test assert!(!db_path.exists()); From ef5be9350ce83737d931383cfc3728d15b1bde75 Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Mon, 26 Aug 2024 13:40:05 -0400 Subject: [PATCH 2/3] Fix formatting Signed-off-by: Lann Martin --- crates/trigger/src/lib.rs | 5 +---- tests/integration.rs | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/crates/trigger/src/lib.rs b/crates/trigger/src/lib.rs index 0fde4a0219..0cc119f16c 100644 --- a/crates/trigger/src/lib.rs +++ b/crates/trigger/src/lib.rs @@ -53,10 +53,7 @@ pub trait Trigger: Sized + Send { } /// Run this trigger. - fn run( - self, - trigger_app: TriggerApp, - ) -> impl Future> + Send; + fn run(self, trigger_app: TriggerApp) -> impl Future> + Send; /// Returns a list of host requirements supported by this trigger specifically. /// diff --git a/tests/integration.rs b/tests/integration.rs index 2c4b8ad04c..9ada8bb9dd 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -422,11 +422,7 @@ Caused by: ) }; ensure_success("/hello", 200, "I'm a teapot")?; - ensure_success( - "/hello/wildcards/should/be/handled", - 200, - "I'm a teapot", - )?; + ensure_success("/hello/wildcards/should/be/handled", 200, "I'm a teapot")?; ensure_success("/thisshouldfail", 404, "")?; ensure_success("/hello/test-placement", 200, "text for test")?; Ok(()) From 3e6708dbf6a0e6958584c23b39eacce2086a7706 Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Mon, 26 Aug 2024 13:47:39 -0400 Subject: [PATCH 3/3] Fix-a-lint Signed-off-by: Lann Martin --- crates/trigger/src/cli.rs | 2 +- examples/spin-timer/Cargo.lock | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/trigger/src/cli.rs b/crates/trigger/src/cli.rs index cd492a31d9..8dce80e1cb 100644 --- a/crates/trigger/src/cli.rs +++ b/crates/trigger/src/cli.rs @@ -312,7 +312,7 @@ impl TriggerAppBuilder { let use_gpu = true; let state_dir = match options.state_dir { // Make sure `--state-dir=""` unsets the state dir - Some(s) if s.trim().is_empty() => None, + Some("") => None, Some(s) => Some(PathBuf::from(s)), // Default to `.spin/` in the local app dir None => options.local_app_dir.map(|d| Path::new(d).join(".spin")), diff --git a/examples/spin-timer/Cargo.lock b/examples/spin-timer/Cargo.lock index c46d338394..79231a9838 100644 --- a/examples/spin-timer/Cargo.lock +++ b/examples/spin-timer/Cargo.lock @@ -615,14 +615,6 @@ dependencies = [ "winx", ] -[[package]] -name = "cargo-target-dep" -version = "0.1.0" -source = "git+https://github.com/fermyon/cargo-target-dep?rev=482f269eceb7b1a7e8fc618bf8c082dd24979cf1#482f269eceb7b1a7e8fc618bf8c082dd24979cf1" -dependencies = [ - "glob", -] - [[package]] name = "cc" version = "1.0.99" @@ -4034,7 +4026,6 @@ name = "spin-factors" version = "2.8.0-pre0" dependencies = [ "anyhow", - "cargo-target-dep", "serde", "spin-app", "spin-factors-derive",