From a126631d2f378bd23f3719f555383d3aa2fa55cf Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 30 Oct 2023 10:34:44 -0700 Subject: [PATCH] Fix tests. --- Cargo.lock | 24 +++++++++++++++++++++++ Cargo.toml | 2 +- crates/node-depman/tests/download_test.rs | 22 ++++++++++----------- crates/node-depman/tests/metadata_test.rs | 2 +- crates/node-depman/tests/versions_test.rs | 20 +++++++++---------- crates/node/tests/download_test.rs | 24 +++++++++++------------ crates/node/tests/versions_test.rs | 2 +- 7 files changed, 60 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7297deb..43bc9e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2700,6 +2700,15 @@ dependencies = [ "dirs 4.0.0", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "similar" version = "2.2.1" @@ -3092,11 +3101,26 @@ dependencies = [ "bytes", "libc", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2 0.5.3", + "tokio-macros", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tokio-rustls" version = "0.24.1" diff --git a/Cargo.toml b/Cargo.toml index 168dd3e..8d9dab3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ regex = { version = "1.10.2", default-features = false } serde = "1.0.190" serde_json = "1.0.108" starbase_sandbox = "0.1.12" -tokio = "1.33.0" +tokio = { version = "1.33.0", features = ["full"] } version_spec = "0.1.3" [profile.release] diff --git a/crates/node-depman/tests/download_test.rs b/crates/node-depman/tests/download_test.rs index 13f2639..84171c2 100644 --- a/crates/node-depman/tests/download_test.rs +++ b/crates/node-depman/tests/download_test.rs @@ -20,7 +20,7 @@ mod npm { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "9.0.0".into(), + version: VersionSpec::parse("9.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -48,7 +48,7 @@ mod npm { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "9.0.0".into(), + version: VersionSpec::parse("9.0.0").unwrap(), ..Default::default() }, }) @@ -77,7 +77,7 @@ mod pnpm { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "8.0.0".into(), + version: VersionSpec::parse("8.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -105,7 +105,7 @@ mod pnpm { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "8.0.0".into(), + version: VersionSpec::parse("8.0.0").unwrap(), ..Default::default() }, }) @@ -134,7 +134,7 @@ mod yarn { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "1.22.0".into(), + version: VersionSpec::parse("1.22.0").unwrap(), ..Default::default() }, ..Default::default() @@ -162,7 +162,7 @@ mod yarn { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "1.22.0".into(), + version: VersionSpec::parse("1.22.0").unwrap(), ..Default::default() }, }) @@ -191,7 +191,7 @@ mod yarn_berry { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "3.6.1".into(), + version: VersionSpec::parse("3.6.1").unwrap(), ..Default::default() }, ..Default::default() @@ -220,7 +220,7 @@ mod yarn_berry { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "3.6.1".into(), + version: VersionSpec::parse("3.6.1").unwrap(), ..Default::default() }, }) @@ -254,7 +254,7 @@ fn locates_bin_from_package_json_bin() { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, }) @@ -284,7 +284,7 @@ fn locates_bin_from_package_json_bin() { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "9.0.0".into(), + version: VersionSpec::parse("9.0.0").unwrap(), ..Default::default() }, }) @@ -316,7 +316,7 @@ fn locates_bin_from_package_json_main() { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "8.0.0".into(), + version: VersionSpec::parse("8.0.0").unwrap(), ..Default::default() }, }) diff --git a/crates/node-depman/tests/metadata_test.rs b/crates/node-depman/tests/metadata_test.rs index f207dc7..34d027a 100644 --- a/crates/node-depman/tests/metadata_test.rs +++ b/crates/node-depman/tests/metadata_test.rs @@ -18,7 +18,7 @@ mod npm { ToolMetadataOutput { name: "npm".into(), type_of: PluginType::DependencyManager, - default_version: Some("bundled".into()), + default_version: Some(UnresolvedVersionSpec::Alias("bundled".into())), plugin_version: Some(env!("CARGO_PKG_VERSION").into()), ..ToolMetadataOutput::default() } diff --git a/crates/node-depman/tests/versions_test.rs b/crates/node-depman/tests/versions_test.rs index 81d7d76..7c08a99 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -35,7 +35,7 @@ mod npm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -51,7 +51,7 @@ mod npm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -67,7 +67,7 @@ mod npm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("latest".into()), + version: Some(UnresolvedVersionSpec::parse("latest").unwrap()), } ); } @@ -83,7 +83,7 @@ mod npm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -123,7 +123,7 @@ mod pnpm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -139,7 +139,7 @@ mod pnpm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("latest".into()), + version: Some(UnresolvedVersionSpec::parse("latest").unwrap()), } ); } @@ -155,7 +155,7 @@ mod pnpm { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -196,7 +196,7 @@ mod yarn { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } @@ -212,7 +212,7 @@ mod yarn { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("latest".into()), + version: Some(UnresolvedVersionSpec::parse("latest").unwrap()), } ); } @@ -228,7 +228,7 @@ mod yarn { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some("1.2.3".into()), + version: Some(UnresolvedVersionSpec::parse("1.2.3").unwrap()), } ); } diff --git a/crates/node/tests/download_test.rs b/crates/node/tests/download_test.rs index c435235..2eef31c 100644 --- a/crates/node/tests/download_test.rs +++ b/crates/node/tests/download_test.rs @@ -23,7 +23,7 @@ fn supports_linux_arm64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -53,7 +53,7 @@ fn supports_linux_arm() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -84,7 +84,7 @@ fn supports_linux_x64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -114,7 +114,7 @@ fn supports_linux_s390x() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -144,7 +144,7 @@ fn supports_linux_ppc64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -175,7 +175,7 @@ fn supports_macos_arm64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -206,7 +206,7 @@ fn supports_macos_x64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -236,7 +236,7 @@ fn supports_windows_arm64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -266,7 +266,7 @@ fn supports_windows_x64() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -296,7 +296,7 @@ fn supports_windows_x86() { assert_eq!( plugin.download_prebuilt(DownloadPrebuiltInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, ..Default::default() @@ -327,7 +327,7 @@ fn locates_unix_bin() { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, }) @@ -351,7 +351,7 @@ fn locates_windows_bin() { plugin .locate_bins(LocateBinsInput { context: ToolContext { - version: "20.0.0".into(), + version: VersionSpec::parse("20.0.0").unwrap(), ..Default::default() }, }) diff --git a/crates/node/tests/versions_test.rs b/crates/node/tests/versions_test.rs index 9eb7e7b..5afe245 100644 --- a/crates/node/tests/versions_test.rs +++ b/crates/node/tests/versions_test.rs @@ -61,7 +61,7 @@ fn parses_engines() { file: "package.json".into(), }), ParseVersionFileOutput { - version: Some(">=16".into()), + version: Some(UnresolvedVersionSpec::parse(">=16").unwrap()), } ); }