From 8db3ea9edab130fa6d05bcb184782f089407e65d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 6 Nov 2024 11:04:07 -0700 Subject: [PATCH] Fix extension tests on release branches Co-Authored-By: Max --- .../src/extension_store_test.rs | 1 + crates/extension_host/src/wasm_host/wit.rs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/extension_host/src/extension_store_test.rs b/crates/extension_host/src/extension_store_test.rs index bd571703dba7f63848defc042662b2f62a4c0f1a..3fbf042785c4a406af15b58c73c54fb3d06aaa28 100644 --- a/crates/extension_host/src/extension_store_test.rs +++ b/crates/extension_host/src/extension_store_test.rs @@ -616,6 +616,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) { }) .detach(); }); + std::fs::remove_dir_all(test_extension_dir.join("target")).unwrap(); extension_store .update(cx, |store, cx| { diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs index 3aff59ee2af7da984ad04432d680f37867a30ede..b124ded22c2be60a813a0ba411cbddbfd0bcd13b 100644 --- a/crates/extension_host/src/wasm_host/wit.rs +++ b/crates/extension_host/src/wasm_host/wit.rs @@ -78,13 +78,18 @@ 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 dbg!(release_channel) { + ReleaseChannel::Dev | ReleaseChannel::Nightly => true, + ReleaseChannel::Stable | ReleaseChannel::Preview => cfg!(test), + }; + 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