From 8cc3ce1f17a313d60589b8d87207efcfb4100c90 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 7 Nov 2024 22:19:36 -0700 Subject: [PATCH] Fix extension tests on release branches (#20307) Co-Authored-By: Max cc @maxdeviant Release Notes: - N/A --------- Co-authored-by: Max --- crates/extension_host/Cargo.toml | 3 +++ crates/extension_host/src/wasm_host/wit.rs | 21 ++++++++++++++------- crates/extensions_ui/Cargo.toml | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/extension_host/Cargo.toml b/crates/extension_host/Cargo.toml index ebe02fca04..34f2b2f555 100644 --- a/crates/extension_host/Cargo.toml +++ b/crates/extension_host/Cargo.toml @@ -12,6 +12,9 @@ workspace = true path = "src/extension_host.rs" doctest = false +[features] +test-support = [] + [dependencies] anyhow.workspace = true async-compression.workspace = true diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs index dfee3cec9d..593d462972 100644 --- a/crates/extension_host/src/wasm_host/wit.rs +++ b/crates/extension_host/src/wasm_host/wit.rs @@ -80,13 +80,20 @@ impl Extension { version: SemanticVersion, component: &Component, ) -> Result { - // Note: The release channel can be used to stage a new version of the extension API. - let allow_latest_version = match release_channel { - ReleaseChannel::Dev | ReleaseChannel::Nightly => true, - ReleaseChannel::Stable | ReleaseChannel::Preview => false, - }; - - if allow_latest_version && version >= latest::MIN_VERSION { + if version >= latest::MIN_VERSION { + // Note: The release channel can be used to stage a new version of the extension API. + // We always allow the latest in tests so that the extension tests pass on release branches. + let allow_latest_version = match release_channel { + ReleaseChannel::Dev | ReleaseChannel::Nightly => true, + ReleaseChannel::Stable | ReleaseChannel::Preview => { + cfg!(any(test, feature = "test-support")) + } + }; + if !allow_latest_version { + Err(anyhow!( + "unreleased versions of the extension API can only be used on development builds of Zed" + ))?; + } let extension = latest::Extension::instantiate_async(store, component, latest::linker()) .await diff --git a/crates/extensions_ui/Cargo.toml b/crates/extensions_ui/Cargo.toml index fb00011692..f68c5a5470 100644 --- a/crates/extensions_ui/Cargo.toml +++ b/crates/extensions_ui/Cargo.toml @@ -52,6 +52,7 @@ async-tar.workspace = true ctor.workspace = true editor = { workspace = true, features = ["test-support"] } env_logger.workspace = true +extension_host = {workspace = true, features = ["test-support"] } fs = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } http_client.workspace = true