Fix extension tests on release branches (#20307)

Co-Authored-By: Max <max@zed.dev>
cc @maxdeviant

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Conrad Irwin 2024-11-07 22:19:36 -07:00 committed by GitHub
parent 6ad8c4a0f4
commit 8cc3ce1f17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 7 deletions

View file

@ -12,6 +12,9 @@ workspace = true
path = "src/extension_host.rs" path = "src/extension_host.rs"
doctest = false doctest = false
[features]
test-support = []
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
async-compression.workspace = true async-compression.workspace = true

View file

@ -80,13 +80,20 @@ impl Extension {
version: SemanticVersion, version: SemanticVersion,
component: &Component, component: &Component,
) -> Result<Self> { ) -> Result<Self> {
// Note: The release channel can be used to stage a new version of the extension API. if version >= latest::MIN_VERSION {
let allow_latest_version = match release_channel { // Note: The release channel can be used to stage a new version of the extension API.
ReleaseChannel::Dev | ReleaseChannel::Nightly => true, // We always allow the latest in tests so that the extension tests pass on release branches.
ReleaseChannel::Stable | ReleaseChannel::Preview => false, let allow_latest_version = match release_channel {
}; ReleaseChannel::Dev | ReleaseChannel::Nightly => true,
ReleaseChannel::Stable | ReleaseChannel::Preview => {
if allow_latest_version && version >= latest::MIN_VERSION { 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 = let extension =
latest::Extension::instantiate_async(store, component, latest::linker()) latest::Extension::instantiate_async(store, component, latest::linker())
.await .await

View file

@ -52,6 +52,7 @@ async-tar.workspace = true
ctor.workspace = true ctor.workspace = true
editor = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] }
env_logger.workspace = true env_logger.workspace = true
extension_host = {workspace = true, features = ["test-support"] }
fs = { workspace = true, features = ["test-support"] } fs = { workspace = true, features = ["test-support"] }
gpui = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] }
http_client.workspace = true http_client.workspace = true