From abdcdf85e9dcdc7611ed11396fe29cc8b48ceff3 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 14 Nov 2023 18:24:09 -0800 Subject: [PATCH] new: Create multiple shims on Windows. (#287) --- CHANGELOG.md | 1 + Cargo.lock | 90 ++++++++++++------- crates/cli/Cargo.toml | 5 ++ crates/cli/tests/bin_test.rs | 2 +- crates/cli/tests/install_uninstall_test.rs | 21 +++++ crates/core/src/shimmer.rs | 69 +++++--------- crates/core/src/tool.rs | 18 ++-- crates/core/templates/bash_header.tpl | 3 - crates/core/templates/bash_local.tpl | 16 ---- crates/core/templates/cmd_header.tpl | 8 -- crates/core/templates/pwsh_header.tpl | 6 -- crates/core/templates/pwsh_local.tpl | 22 ----- .../{bash_global.tpl => unix/sh.tpl} | 4 + .../{cmd_global.tpl => windows/cmd.tpl} | 9 ++ .../{pwsh_global.tpl => windows/ps1.tpl} | 8 ++ crates/core/templates/windows/sh.tpl | 7 ++ crates/core/tests/shimmer_test.rs | 14 ++- .../shimmer_test__shimmer__alt_global.snap | 1 - ...r_test__shimmer__alt_global_with_args.snap | 1 - .../shimmer_test__shimmer__global.snap | 5 +- ...immer_test__shimmer__global_with_args.snap | 3 +- crates/pdk-test-utils/Cargo.toml | 2 +- 22 files changed, 158 insertions(+), 157 deletions(-) delete mode 100644 crates/core/templates/bash_header.tpl delete mode 100644 crates/core/templates/bash_local.tpl delete mode 100644 crates/core/templates/cmd_header.tpl delete mode 100644 crates/core/templates/pwsh_header.tpl delete mode 100644 crates/core/templates/pwsh_local.tpl rename crates/core/templates/{bash_global.tpl => unix/sh.tpl} (73%) rename crates/core/templates/{cmd_global.tpl => windows/cmd.tpl} (58%) rename crates/core/templates/{pwsh_global.tpl => windows/ps1.tpl} (58%) create mode 100644 crates/core/templates/windows/sh.tpl diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b2ec9c9..067eb24b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - `first-available` (default) - Will use the first available version that is found. Either from `.prototools` or a tool specific file (`.nvmrc`, etc). - `prefer-prototools` - Prefer a `.prototools` version, even if found in a parent directory. If none found, falls back to tool specific file. - Added support to plugins to ignore certain paths when detecting a version. +- Updated Windows to create 3 shim files for each tool: `.cmd` (cmd.exe), `.ps1` (powershell), and no extension (bash). - WASM API - Added `DetectVersionOutput.ignore` field. diff --git a/Cargo.lock b/Cargo.lock index ed2595255..bc9175a2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,11 +411,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -1400,9 +1401,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -1593,7 +1594,7 @@ checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-rustls", ] @@ -2315,6 +2316,9 @@ dependencies = [ "proto_core", "proto_pdk_api", "reqwest", + "rustls 0.21.8", + "rustls-pemfile", + "rustls-webpki", "semver", "serde", "shell-words", @@ -2393,7 +2397,7 @@ dependencies = [ "proto_core", "proto_pdk_api", "serde_json", - "toml 0.8.6", + "toml 0.8.8", ] [[package]] @@ -2583,7 +2587,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-native-certs", "rustls-pemfile", "serde", @@ -2611,12 +2615,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "rmp" version = "0.8.11" @@ -2701,19 +2719,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct", "webpki", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", + "ring 0.17.5", "rustls-webpki", "sct", ] @@ -2732,21 +2750,21 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64 0.21.0", ] [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -2824,8 +2842,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3037,6 +3055,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "sptr" version = "0.3.2" @@ -3160,7 +3184,7 @@ dependencies = [ "starbase_styles", "thiserror", "tokio", - "toml 0.8.6", + "toml 0.8.8", "tracing", "wax", ] @@ -3481,7 +3505,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -3522,14 +3546,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.7", + "toml_edit 0.21.0", ] [[package]] @@ -3556,9 +3580,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ "indexmap 2.0.2", "serde", @@ -3733,6 +3757,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "ureq" version = "2.6.2" @@ -4406,8 +4436,8 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index c317a4e4b..35b619c42 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -52,6 +52,11 @@ thiserror = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } +# Force latest rustls +rustls = "0.21.8" +rustls-pemfile = "1.0.4" +rustls-webpki = "0.101.7" + [target.'cfg(windows)'.dependencies] winreg = "0.51.0" diff --git a/crates/cli/tests/bin_test.rs b/crates/cli/tests/bin_test.rs index 82cfacb7f..8f0802726 100644 --- a/crates/cli/tests/bin_test.rs +++ b/crates/cli/tests/bin_test.rs @@ -82,7 +82,7 @@ mod bin { .assert(); if cfg!(windows) { - assert.stdout(predicate::str::contains("shims\\npm.cmd")); + assert.stdout(predicate::str::contains("shims\\npm.ps1")); } else { assert.stdout(predicate::str::contains("shims/npm")); } diff --git a/crates/cli/tests/install_uninstall_test.rs b/crates/cli/tests/install_uninstall_test.rs index acbffb583..7db381dd2 100644 --- a/crates/cli/tests/install_uninstall_test.rs +++ b/crates/cli/tests/install_uninstall_test.rs @@ -115,6 +115,27 @@ mod install_uninstall { )); } + #[test] + fn creates_all_shims() { + let temp = create_empty_sandbox(); + + let mut cmd = create_proto_command(temp.path()); + cmd.arg("install") + .arg("node") + .arg("19.0.0") + .arg("--") + .arg("--no-bundled-npm") + .assert(); + + if cfg!(windows) { + assert!(temp.path().join("shims/node").exists()); + assert!(temp.path().join("shims/node.cmd").exists()); + assert!(temp.path().join("shims/node.ps1").exists()); + } else { + assert!(temp.path().join("shims/node").exists()); + } + } + #[test] fn updates_the_manifest_when_installing() { let temp = create_empty_sandbox(); diff --git a/crates/core/src/shimmer.rs b/crates/core/src/shimmer.rs index c675475ca..0b0824cf1 100644 --- a/crates/core/src/shimmer.rs +++ b/crates/core/src/shimmer.rs @@ -3,12 +3,12 @@ use serde::Serialize; use serde_json::Value; use starbase_utils::fs; use std::fmt::Write; -use std::path::{Path, PathBuf}; +use std::path::Path; use tinytemplate::error::Error as TemplateError; use tinytemplate::TinyTemplate; use tracing::debug; -pub const SHIM_VERSION: u8 = 8; +pub const SHIM_VERSION: u8 = 9; #[derive(Debug, Default, Serialize)] pub struct ShimContext<'tool> { @@ -28,12 +28,6 @@ pub struct ShimContext<'tool> { // TOOL INFO /// ID of the tool, for logging purposes. pub tool_id: &'tool str, - - /// Path to the proto tool installation directory. - pub tool_dir: Option, - - /// Current resolved version. - pub tool_version: Option, } impl<'tool> ShimContext<'tool> { @@ -48,7 +42,7 @@ impl<'tool> ShimContext<'tool> { "Creating global shim" ); - fs::write_file(shim_path, build_shim_file(self, shim_path, true)?)?; + fs::write_file(shim_path, build_shim_file(self, shim_path)?)?; fs::update_perms(shim_path, None)?; Ok(()) @@ -69,49 +63,27 @@ fn format_uppercase(value: &Value, output: &mut String) -> Result<(), TemplateEr Ok(()) } -fn get_template_header<'l>(global: bool) -> &'l str { - if cfg!(windows) { - if global { - include_str!("../templates/cmd_header.tpl") - } else { - include_str!("../templates/pwsh_header.tpl") - } - } else { - include_str!("../templates/bash_header.tpl") +#[cfg(windows)] +fn get_template<'l>(shim_path: &Path) -> &'l str { + match shim_path.extension().map(|ext| ext.to_str().unwrap()) { + Some("cmd") => include_str!("../templates/windows/cmd.tpl"), + Some("ps1") => include_str!("../templates/windows/ps1.tpl"), + _ => include_str!("../templates/windows/sh.tpl"), } } -fn get_template<'l>(global: bool) -> &'l str { - if cfg!(windows) { - if global { - include_str!("../templates/cmd_global.tpl") - } else { - include_str!("../templates/pwsh_local.tpl") - } - } else if global { - include_str!("../templates/bash_global.tpl") - } else { - include_str!("../templates/bash_local.tpl") - } +#[cfg(not(windows))] +fn get_template<'l>(_shim_path: &Path) -> &'l str { + include_str!("../templates/unix/sh.tpl") } -fn build_shim_file( - context: &ShimContext, - shim_path: &Path, - global: bool, -) -> miette::Result { +fn build_shim_file(context: &ShimContext, shim_path: &Path) -> miette::Result { let mut template = TinyTemplate::new(); template.add_formatter("uppercase", format_uppercase); - let contents = format!( - "{}\n\n{}", - get_template_header(global), - get_template(global) - ); - template - .add_template("shim", &contents) + .add_template("shim", get_template(shim_path)) .map_err(|error| ProtoError::Shim { path: shim_path.to_path_buf(), error, @@ -128,11 +100,16 @@ fn build_shim_file( } #[cfg(windows)] -pub fn get_shim_file_name(name: &str, global: bool) -> String { - format!("{name}.{}", if global { "cmd" } else { "ps1" }) +pub fn get_shim_file_names(name: &str) -> Vec { + // Order is important! + vec![ + format!("{name}.ps1"), + format!("{name}.cmd"), + format!("{name}"), + ] } #[cfg(not(windows))] -pub fn get_shim_file_name(name: &str, _global: bool) -> String { - name.to_owned() +pub fn get_shim_file_names(name: &str) -> Vec { + vec![name.to_owned()] } diff --git a/crates/core/src/tool.rs b/crates/core/src/tool.rs index a4298ffaa..706f64bba 100644 --- a/crates/core/src/tool.rs +++ b/crates/core/src/tool.rs @@ -6,7 +6,7 @@ use crate::helpers::{ }; use crate::host_funcs::{create_host_functions, HostData}; use crate::proto::ProtoEnvironment; -use crate::shimmer::{get_shim_file_name, ShimContext, SHIM_VERSION}; +use crate::shimmer::{get_shim_file_names, ShimContext, SHIM_VERSION}; use crate::tool_manifest::ToolManifest; use crate::version_resolver::VersionResolver; use extism::{manifest::Wasm, Manifest as PluginManifest}; @@ -1146,8 +1146,6 @@ impl Tool { ShimContext { bin: &self.id, tool_id: &self.id, - tool_dir: Some(self.get_tool_dir()), - tool_version: Some(self.get_resolved_version().to_string()), ..ShimContext::default() } } @@ -1249,12 +1247,14 @@ impl Tool { let mut add = |name: &str, config: ExecutableConfig, primary: bool| { if !config.no_shim { - locations.push(ExecutableLocation { - path: self.proto.shims_dir.join(get_shim_file_name(name, true)), - name: name.to_owned(), - config, - primary, - }); + for shim_name in get_shim_file_names(name) { + locations.push(ExecutableLocation { + path: self.proto.shims_dir.join(shim_name), + name: name.to_owned(), + config: config.clone(), + primary, + }); + } } }; diff --git a/crates/core/templates/bash_header.tpl b/crates/core/templates/bash_header.tpl deleted file mode 100644 index 448485845..000000000 --- a/crates/core/templates/bash_header.tpl +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -set -e -[ -n "$PROTO_DEBUG" ] && set -x diff --git a/crates/core/templates/bash_local.tpl b/crates/core/templates/bash_local.tpl deleted file mode 100644 index b00324db2..000000000 --- a/crates/core/templates/bash_local.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{{ if tool_dir }} -export PROTO_{bin | uppercase}_DIR="{tool_dir}" -{{ endif }} - -{{ if tool_version }} -export PROTO_{bin | uppercase}_VERSION="{tool_version}" -{{ endif }} - -{{ if parent_bin }} -parent="$\{PROTO_{parent_bin | uppercase}_BIN:-{parent_bin}}" - -exec "$parent" "{bin_path}" {before_args} "$@" {after_args} -{{ else }} - -exec "{bin_path}" {before_args} "$@" {after_args} -{{ endif }} diff --git a/crates/core/templates/cmd_header.tpl b/crates/core/templates/cmd_header.tpl deleted file mode 100644 index dc6007172..000000000 --- a/crates/core/templates/cmd_header.tpl +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -setlocal - -set "ErrorActionPreference=Stop" - -if defined PROTO_DEBUG ( - set "DebugPreference=Continue" -) \ No newline at end of file diff --git a/crates/core/templates/pwsh_header.tpl b/crates/core/templates/pwsh_header.tpl deleted file mode 100644 index 58f86368c..000000000 --- a/crates/core/templates/pwsh_header.tpl +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env pwsh -$ErrorActionPreference = 'Stop' - -if (Test-Path env:PROTO_DEBUG) \{ - $DebugPreference = 'Continue' -} diff --git a/crates/core/templates/pwsh_local.tpl b/crates/core/templates/pwsh_local.tpl deleted file mode 100644 index dd54ee2e7..000000000 --- a/crates/core/templates/pwsh_local.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{{ if tool_dir }} -[Environment]::SetEnvironmentVariable('PROTO_{bin | uppercase}_DIR', '{tool_dir}', 'Process') -{{ endif }} - -{{ if tool_version }} -[Environment]::SetEnvironmentVariable('PROTO_{bin | uppercase}_VERSION', '{tool_version}', 'Process') -{{ endif }} - -{{ if parent_bin }} -if (Test-Path env:PROTO_{parent_bin | uppercase}_BIN) \{ - $parent = $Env:PROTO_{parent_bin | uppercase}_BIN -} else \{ - $parent = "{parent_bin}" -} - -& "$parent" "{bin_path}" {before_args} $args {after_args} -{{ else }} - -& "{bin_path}" {before_args} $args {after_args} -{{ endif }} - -exit $LASTEXITCODE diff --git a/crates/core/templates/bash_global.tpl b/crates/core/templates/unix/sh.tpl similarity index 73% rename from crates/core/templates/bash_global.tpl rename to crates/core/templates/unix/sh.tpl index b815e557b..b08dd0009 100644 --- a/crates/core/templates/bash_global.tpl +++ b/crates/core/templates/unix/sh.tpl @@ -1,3 +1,7 @@ +#!/usr/bin/env bash +set -e +[ -n "$PROTO_DEBUG" ] && set -x + {{ if alt_bin }} exec proto run {bin} --alt "{alt_bin}" -- {before_args} "$@" {after_args} {{ else }} diff --git a/crates/core/templates/cmd_global.tpl b/crates/core/templates/windows/cmd.tpl similarity index 58% rename from crates/core/templates/cmd_global.tpl rename to crates/core/templates/windows/cmd.tpl index fd65f193e..a975849be 100644 --- a/crates/core/templates/cmd_global.tpl +++ b/crates/core/templates/windows/cmd.tpl @@ -1,3 +1,12 @@ +@echo off +setlocal + +set "ErrorActionPreference=Stop" + +if defined PROTO_DEBUG ( + set "DebugPreference=Continue" +) + {{ if alt_bin }} proto.exe run {bin} --alt "{alt_bin}" -- {before_args} %* {after_args} {{ else }} diff --git a/crates/core/templates/pwsh_global.tpl b/crates/core/templates/windows/ps1.tpl similarity index 58% rename from crates/core/templates/pwsh_global.tpl rename to crates/core/templates/windows/ps1.tpl index aeda838db..3d924bbee 100644 --- a/crates/core/templates/pwsh_global.tpl +++ b/crates/core/templates/windows/ps1.tpl @@ -1,5 +1,13 @@ +#!/usr/bin/env pwsh +$ErrorActionPreference = 'Stop' + +if (Test-Path env:PROTO_DEBUG) \{ + $DebugPreference = 'Continue' +} + {{ if alt_bin }} & proto.exe run {bin} --alt "{alt_bin}" -- {before_args} $args {after_args} {{ else }} & proto.exe run {bin} -- {before_args} $args {after_args} {{ endif }} + diff --git a/crates/core/templates/windows/sh.tpl b/crates/core/templates/windows/sh.tpl new file mode 100644 index 000000000..7909fc928 --- /dev/null +++ b/crates/core/templates/windows/sh.tpl @@ -0,0 +1,7 @@ +#!/bin/sh + +{{ if alt_bin }} +proto.exe run {bin} --alt "{alt_bin}" -- {before_args} "$@" {after_args} +{{ else }} +proto.exe run {bin} -- {before_args} "$@" {after_args} +{{ endif }} diff --git a/crates/core/tests/shimmer_test.rs b/crates/core/tests/shimmer_test.rs index af90b72c3..97b0a0320 100644 --- a/crates/core/tests/shimmer_test.rs +++ b/crates/core/tests/shimmer_test.rs @@ -6,12 +6,10 @@ mod shimmer { use std::fs; use std::path::Path; - fn create_context<'l>(id: &'l str, proto: &'l ProtoEnvironment) -> ShimContext<'l> { + fn create_context(id: &str) -> ShimContext { ShimContext { bin: id, tool_id: id, - tool_dir: Some(proto.tools_dir.join(id).join("1.2.3")), - tool_version: Some("1.2.3".into()), ..ShimContext::default() } } @@ -28,7 +26,7 @@ mod shimmer { sandbox.create_file(".proto/shims/primary", "test"); let proto = ProtoEnvironment::new_testing(sandbox.path()); - let context = create_context("primary", &proto); + let context = create_context("primary"); let shim_path = proto.shims_dir.join("primary"); context.create_shim(&shim_path, true).unwrap(); @@ -40,7 +38,7 @@ mod shimmer { fn global() { let sandbox = create_empty_sandbox(); let proto = ProtoEnvironment::new_testing(sandbox.path()); - let context = create_context("primary", &proto); + let context = create_context("primary"); let shim_path = proto.shims_dir.join("primary"); context.create_shim(&shim_path, false).unwrap(); @@ -53,7 +51,7 @@ mod shimmer { let sandbox = create_empty_sandbox(); let proto = ProtoEnvironment::new_testing(sandbox.path()); - let mut context = create_context("primary", &proto); + let mut context = create_context("primary"); context.before_args = Some("--a -b"); context.after_args = Some("./file"); @@ -69,7 +67,7 @@ mod shimmer { let proto = ProtoEnvironment::new_testing(sandbox.path()); let bin_path = "other/bin/path"; - let mut context = create_context("primary", &proto); + let mut context = create_context("primary"); context.alt_bin = Some(bin_path); let shim_path = proto.shims_dir.join("secondary"); @@ -84,7 +82,7 @@ mod shimmer { let proto = ProtoEnvironment::new_testing(sandbox.path()); let bin_path = "other/bin/path"; - let mut context = create_context("primary", &proto); + let mut context = create_context("primary"); context.alt_bin = Some(bin_path); context.before_args = Some("--a -b"); context.after_args = Some("./file"); diff --git a/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global.snap b/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global.snap index 774991833..44fbd62b7 100644 --- a/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global.snap +++ b/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global.snap @@ -7,7 +7,6 @@ set -e [ -n "$PROTO_DEBUG" ] && set -x - exec proto run primary --alt "other/bin/path" -- "$@" diff --git a/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global_with_args.snap b/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global_with_args.snap index 3bba69e83..7d3d4defe 100644 --- a/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global_with_args.snap +++ b/crates/core/tests/snapshots/shimmer_test__shimmer__alt_global_with_args.snap @@ -7,7 +7,6 @@ set -e [ -n "$PROTO_DEBUG" ] && set -x - exec proto run primary --alt "other/bin/path" -- --a -b "$@" ./file diff --git a/crates/core/tests/snapshots/shimmer_test__shimmer__global.snap b/crates/core/tests/snapshots/shimmer_test__shimmer__global.snap index a6488e378..d8c3d7abb 100644 --- a/crates/core/tests/snapshots/shimmer_test__shimmer__global.snap +++ b/crates/core/tests/snapshots/shimmer_test__shimmer__global.snap @@ -1,13 +1,12 @@ --- source: crates/core/tests/shimmer_test.rs -expression: "read_shim(&shim, sandbox.path())" +expression: "read_shim(&shim_path, sandbox.path())" --- #!/usr/bin/env bash set -e [ -n "$PROTO_DEBUG" ] && set -x - -exec proto run primary -- "$@" +exec proto run primary -- "$@" diff --git a/crates/core/tests/snapshots/shimmer_test__shimmer__global_with_args.snap b/crates/core/tests/snapshots/shimmer_test__shimmer__global_with_args.snap index 35f73a774..ee2705136 100644 --- a/crates/core/tests/snapshots/shimmer_test__shimmer__global_with_args.snap +++ b/crates/core/tests/snapshots/shimmer_test__shimmer__global_with_args.snap @@ -1,13 +1,12 @@ --- source: crates/core/tests/shimmer_test.rs -expression: "read_shim(&shim, sandbox.path())" +expression: "read_shim(&shim_path, sandbox.path())" --- #!/usr/bin/env bash set -e [ -n "$PROTO_DEBUG" ] && set -x - exec proto run primary -- --a -b "$@" ./file diff --git a/crates/pdk-test-utils/Cargo.toml b/crates/pdk-test-utils/Cargo.toml index bfc5f3b93..bebad1857 100644 --- a/crates/pdk-test-utils/Cargo.toml +++ b/crates/pdk-test-utils/Cargo.toml @@ -12,7 +12,7 @@ proto_core = { version = "0.22.5", path = "../core" } proto_pdk_api = { version = "0.10.3", path = "../pdk-api" } extism = { workspace = true } serde_json = { workspace = true } -toml = { version = "0.8.6", optional = true } +toml = { version = "0.8.8", optional = true } [features] default = []