diff --git a/crates/componentize/src/lib.rs b/crates/componentize/src/lib.rs index e78269c256..7e43389e6e 100644 --- a/crates/componentize/src/lib.rs +++ b/crates/componentize/src/lib.rs @@ -466,7 +466,7 @@ mod tests { let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); let mut cmd = process::Command::new("cargo"); cmd.arg("build") - .current_dir(&format!("tests/{name}")) + .current_dir(format!("tests/{name}")) .arg("--release") .arg("--target=wasm32-wasi") .env("CARGO_TARGET_DIR", out_dir); diff --git a/crates/trigger/src/cli.rs b/crates/trigger/src/cli.rs index ab5d9816dd..af66221d54 100644 --- a/crates/trigger/src/cli.rs +++ b/crates/trigger/src/cli.rs @@ -14,10 +14,9 @@ use spin_common::sloth; use spin_common::ui::quoted_path; use spin_common::url::parse_file_url; use spin_factors::RuntimeFactors; -use spin_factors_executor::FactorsExecutor; +use spin_factors_executor::{ComponentLoader, FactorsExecutor}; -use crate::loader::ComponentLoader; -use crate::{Trigger, TriggerApp}; +use crate::{loader::ComponentLoader as ComponentLoaderImpl, Trigger, TriggerApp}; pub use initial_kv_setter::InitialKvSetterHook; pub use launch_metadata::LaunchMetadata; pub use sqlite_statements::SqlStatementExecutorHook; @@ -220,7 +219,19 @@ impl, B: RuntimeFactorsBuilder> FactorsTriggerCommand, B: RuntimeFactorsBuilder> TriggerAppBuilder { app: App, common_options: FactorsConfig, options: B::CliArgs, + loader: &impl ComponentLoader, ) -> anyhow::Result> { let mut core_engine_builder = { self.trigger.update_core_config(&mut self.engine_config)?; @@ -319,7 +331,7 @@ impl, B: RuntimeFactorsBuilder> TriggerAppBuilder { let configured_app = { let _sloth_guard = warn_if_wasm_build_slothful(); executor - .load_app(app, runtime_config.into(), &ComponentLoader::default()) + .load_app(app, runtime_config.into(), loader) .await? }; @@ -332,8 +344,9 @@ impl, B: RuntimeFactorsBuilder> TriggerAppBuilder { app: App, common_options: FactorsConfig, options: B::CliArgs, + loader: &impl ComponentLoader, ) -> anyhow::Result>> { - let configured_app = self.build(app, common_options, options).await?; + let configured_app = self.build(app, common_options, options, loader).await?; Ok(self.trigger.run(configured_app)) } } diff --git a/crates/trigger/src/loader.rs b/crates/trigger/src/loader.rs index a96221a385..8479fa5e8c 100644 --- a/crates/trigger/src/loader.rs +++ b/crates/trigger/src/loader.rs @@ -5,11 +5,17 @@ use spin_factors::AppComponent; #[derive(Default)] pub struct ComponentLoader { + _private: (), #[cfg(feature = "unsafe-aot-compilation")] aot_compilation_enabled: bool, } impl ComponentLoader { + /// Create a new `ComponentLoader` + pub fn new() -> Self { + Self::default() + } + /// Updates the TriggerLoader to load AOT precompiled components /// /// **Warning: This feature may bypass important security guarantees of the diff --git a/tests/testing-framework/src/runtimes/in_process_spin.rs b/tests/testing-framework/src/runtimes/in_process_spin.rs index 0298ba3392..b9320e68c7 100644 --- a/tests/testing-framework/src/runtimes/in_process_spin.rs +++ b/tests/testing-framework/src/runtimes/in_process_spin.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use anyhow::Context as _; use spin_runtime_factors::{FactorsBuilder, TriggerAppArgs, TriggerFactors}; -use spin_trigger::cli::TriggerAppBuilder; +use spin_trigger::{cli::TriggerAppBuilder, loader::ComponentLoader}; use spin_trigger_http::{HttpServer, HttpTrigger}; use test_environment::{ http::{Request, Response}, @@ -111,6 +111,7 @@ async fn initialize_trigger( app, spin_trigger::cli::FactorsConfig::default(), TriggerAppArgs::default(), + &ComponentLoader::new(), ) .await?; let server = builder.trigger.into_server(trigger_app)?;