mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
gpui: Add sendable foreground execution for web HTTP clients (#66165)
## Summary This cleans up the gpui_platform code a bit, and in combination the way we set up the http client for the web. This does introduce a `ForegroundExecutor` variant that it itself is Send-able, allowing to dispatch foreground futures from background workers (by requiring the future to be Send, unlike `ForegroundExecutor`), which is a requirement for web fetch. a31c7b54c60738b82524e4e4c12aec2f6caf101d fixes a bunch of warnings with our binary names Release Notes: - [gpui] N/A
This commit is contained in:
Generated
+1
@@ -7364,6 +7364,7 @@ dependencies = [
|
||||
"gpui_platform",
|
||||
"gpui_shared_string",
|
||||
"gpui_util",
|
||||
"gpui_web",
|
||||
"hdrhistogram",
|
||||
"heapless",
|
||||
"http_client",
|
||||
|
||||
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "auto_update_helper"
|
||||
name = "auto-update-helper"
|
||||
path = "src/auto_update_helper.rs"
|
||||
doctest = false
|
||||
|
||||
|
||||
@@ -26,5 +26,5 @@ theme.workspace = true
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "docs_preprocessor"
|
||||
name = "docs-preprocessor"
|
||||
path = "src/main.rs"
|
||||
|
||||
@@ -12,6 +12,10 @@ workspace = true
|
||||
path = "src/edit_prediction_metrics.rs"
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "edit-prediction-metrics"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
tree-sitter = ["dep:tree-sitter"]
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ fn report_from_json_example(
|
||||
|
||||
fn print_usage() {
|
||||
eprintln!(
|
||||
"Usage:\n edit_prediction_metrics --base <base.txt> --expected-patch <expected.diff> --actual-patch <actual.diff>\n edit_prediction_metrics --json <example.json> [--prediction-index <n>]"
|
||||
"Usage:\n edit-prediction-metrics --base <base.txt> --expected-patch <expected.diff> --actual-patch <actual.diff>\n edit-prediction-metrics --json <example.json> [--prediction-index <n>]"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ version = "0.1.0"
|
||||
publish.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "editor-benchmarks"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
editor.workspace = true
|
||||
|
||||
@@ -42,7 +42,7 @@ fn parse_args() -> Args {
|
||||
}
|
||||
"--help" | "-h" => {
|
||||
eprintln!(
|
||||
"Usage: editor_benchmarks [OPTIONS] <FILE> <QUERY>\n\n\
|
||||
"Usage: editor-benchmarks [OPTIONS] <FILE> <QUERY>\n\n\
|
||||
Arguments:\n \
|
||||
<FILE> Path to the file to search in\n \
|
||||
<QUERY> The search query string\n\n\
|
||||
@@ -60,7 +60,7 @@ fn parse_args() -> Args {
|
||||
}
|
||||
|
||||
if positional.len() < 2 {
|
||||
eprintln!("Usage: editor_benchmarks [OPTIONS] <FILE> <QUERY>");
|
||||
eprintln!("Usage: editor-benchmarks [OPTIONS] <FILE> <QUERY>");
|
||||
std::process::exit(1);
|
||||
}
|
||||
parsed.file = positional.remove(0);
|
||||
|
||||
@@ -4,6 +4,10 @@ version = "0.1.0"
|
||||
publish.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "fs-benchmarks"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
fs.workspace = true
|
||||
gpui.workspace = true
|
||||
|
||||
@@ -20,6 +20,7 @@ workspace = true
|
||||
[features]
|
||||
default = ["font-kit", "wayland", "x11", "windows-manifest"]
|
||||
test-support = [
|
||||
"bench_metrics?/test-support",
|
||||
"collections/test-support",
|
||||
"http_client/test-support",
|
||||
"wayland",
|
||||
@@ -173,7 +174,6 @@ windows = { workspace = true, features = [
|
||||
|
||||
[dev-dependencies]
|
||||
backtrace.workspace = true
|
||||
bench_metrics = { workspace = true, features = ["test-support"] }
|
||||
collections = { workspace = true, features = ["test-support"] }
|
||||
env_logger.workspace = true
|
||||
futures-concurrency.workspace = true
|
||||
@@ -192,6 +192,7 @@ proptest.workspace = true
|
||||
reqwest_client = { workspace = true, features = ["test-support"] }
|
||||
|
||||
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
||||
gpui_web.workspace = true
|
||||
wasm-bindgen.workspace = true
|
||||
web-sys.workspace = true
|
||||
|
||||
|
||||
@@ -154,10 +154,13 @@ actions!(image, [Quit]);
|
||||
fn run_example() {
|
||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
let app = gpui_platform::application();
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
let app = gpui_platform::application();
|
||||
let http_client =
|
||||
ReqwestClient::user_agent("gpui example").expect("failed to create HTTP client");
|
||||
#[cfg(target_family = "wasm")]
|
||||
let app = gpui_platform::application();
|
||||
let http_client = gpui_web::FetchHttpClient::new(app.foreground_executor().to_send());
|
||||
let app = app.with_http_client(Arc::new(http_client));
|
||||
app.with_assets(Assets {
|
||||
base: manifest_dir.join("examples"),
|
||||
})
|
||||
@@ -165,12 +168,6 @@ fn run_example() {
|
||||
if !example_support::load_fonts(cx) {
|
||||
return;
|
||||
}
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
{
|
||||
let http_client = ReqwestClient::user_agent("gpui example").unwrap();
|
||||
cx.set_http_client(Arc::new(http_client));
|
||||
}
|
||||
|
||||
cx.activate(true);
|
||||
cx.on_action(|_: &Quit, cx| cx.quit());
|
||||
cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]);
|
||||
|
||||
@@ -241,16 +241,17 @@ fn run_example() {
|
||||
let app = gpui_platform::application();
|
||||
#[cfg(target_family = "wasm")]
|
||||
let app = gpui_platform::single_threaded_web();
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
let http_client =
|
||||
ReqwestClient::user_agent("gpui example").expect("failed to create HTTP client");
|
||||
#[cfg(target_family = "wasm")]
|
||||
let http_client = gpui_web::FetchHttpClient::new(app.foreground_executor().to_send());
|
||||
let app = app.with_http_client(Arc::new(http_client));
|
||||
|
||||
app.run(move |cx: &mut App| {
|
||||
if !example_support::load_fonts(cx) {
|
||||
return;
|
||||
}
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
{
|
||||
let http_client = ReqwestClient::user_agent("gpui example").unwrap();
|
||||
cx.set_http_client(Arc::new(http_client));
|
||||
}
|
||||
|
||||
cx.activate(true);
|
||||
cx.on_action(|_: &Quit, cx| cx.quit());
|
||||
|
||||
@@ -1352,13 +1352,9 @@ impl VisualContext for BenchWindowContext<'_, '_> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{
|
||||
rc::Rc,
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicU64, Ordering},
|
||||
},
|
||||
};
|
||||
#[cfg(feature = "test-support")]
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
|
||||
use super::*;
|
||||
use crate::profiler::journal::install_test_foreground_journal;
|
||||
@@ -1366,6 +1362,7 @@ mod tests {
|
||||
/// Runs `benchmark` under a wall-time primary with a fake counter as the
|
||||
/// secondary metric and returns the per-iteration values the report
|
||||
/// recorded for it.
|
||||
#[cfg(feature = "test-support")]
|
||||
fn secondary_values_per_iteration(
|
||||
counter: Arc<AtomicU64>,
|
||||
benchmark: impl Fn(&mut BenchAppContext, &Arc<AtomicU64>),
|
||||
@@ -1407,6 +1404,7 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-support")]
|
||||
#[test]
|
||||
fn secondary_metric_is_normalized_per_iteration_for_bench_iter() {
|
||||
let values = secondary_values_per_iteration(Arc::new(AtomicU64::new(0)), |cx, counter| {
|
||||
@@ -1421,6 +1419,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-support")]
|
||||
#[test]
|
||||
fn secondary_metric_is_accumulated_across_per_iteration_batches() {
|
||||
let values = secondary_values_per_iteration(Arc::new(AtomicU64::new(0)), |cx, counter| {
|
||||
|
||||
@@ -32,6 +32,23 @@ pub struct ForegroundExecutor {
|
||||
not_send: PhantomData<Rc<()>>,
|
||||
}
|
||||
|
||||
/// A thread-safe handle for spawning `Send` futures on the main thread.
|
||||
#[derive(Clone)]
|
||||
pub struct SendForegroundExecutor {
|
||||
inner: scheduler::SendLocalExecutor,
|
||||
}
|
||||
|
||||
impl SendForegroundExecutor {
|
||||
/// Enqueues a future to run on the main thread, even when submitted from another thread.
|
||||
#[track_caller]
|
||||
pub fn spawn<R>(&self, future: impl Future<Output = R> + Send + 'static) -> Task<R>
|
||||
where
|
||||
R: Send + 'static,
|
||||
{
|
||||
self.inner.spawn(future)
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension trait for `Task<Result<T, E>>` that adds `detach_and_log_err` with an `&App` context.
|
||||
///
|
||||
/// This trait is automatically implemented for all `Task<Result<T, E>>` types.
|
||||
@@ -297,6 +314,13 @@ impl BackgroundExecutor {
|
||||
}
|
||||
|
||||
impl ForegroundExecutor {
|
||||
/// Creates a thread-safe handle that submits `Send` futures to this foreground executor.
|
||||
pub fn to_send(&self) -> SendForegroundExecutor {
|
||||
SendForegroundExecutor {
|
||||
inner: self.inner.to_send(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new ForegroundExecutor from the given PlatformDispatcher.
|
||||
pub fn new(dispatcher: Arc<dyn PlatformDispatcher>) -> Self {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
@@ -555,6 +579,25 @@ mod test {
|
||||
(dispatcher, background_executor, app)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_foreground_executor_submits_from_worker() {
|
||||
let dispatcher = TestDispatcher::new(0);
|
||||
let foreground_executor = ForegroundExecutor::new(Arc::new(dispatcher.clone()));
|
||||
let main_thread = std::thread::current().id();
|
||||
let foreground_executor = foreground_executor.to_send();
|
||||
let task = std::thread::spawn(move || {
|
||||
foreground_executor.spawn(async move {
|
||||
assert_eq!(std::thread::current().id(), main_thread);
|
||||
42
|
||||
})
|
||||
})
|
||||
.join()
|
||||
.expect("worker must submit the foreground task");
|
||||
|
||||
dispatcher.run_until_parked();
|
||||
assert_eq!(task.now_or_never(), Some(42));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanity_test_tasks_run() {
|
||||
let (dispatcher, _background_executor, app) = create_test_app();
|
||||
|
||||
@@ -145,6 +145,7 @@ impl TestPlatform {
|
||||
Self::with_platform(executor, foreground_executor, text_system, None)
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn simulate_display_added(
|
||||
&self,
|
||||
display_id: DisplayId,
|
||||
@@ -156,6 +157,7 @@ impl TestPlatform {
|
||||
|
||||
/// Adds a display without telling App yet, as when the platform's
|
||||
/// notifications about a window arrive before those about displays.
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn connect_display(
|
||||
&self,
|
||||
display_id: DisplayId,
|
||||
@@ -166,6 +168,7 @@ impl TestPlatform {
|
||||
self.displays.borrow_mut().push(display);
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn simulate_display_removed(&self, display_id: DisplayId) {
|
||||
self.displays
|
||||
.borrow_mut()
|
||||
@@ -173,6 +176,7 @@ impl TestPlatform {
|
||||
self.report_displays_changed();
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn simulate_display_refresh_interval_change(
|
||||
&self,
|
||||
display_id: DisplayId,
|
||||
@@ -186,6 +190,7 @@ impl TestPlatform {
|
||||
self.report_displays_changed();
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn report_displays_changed(&self) {
|
||||
let callback = self.displays_changed_callback.borrow_mut().take();
|
||||
if let Some(mut callback) = callback {
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
pub use gpui::Platform;
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub use gpui_web::WebBackendPreference;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Returns a background executor for the current platform.
|
||||
@@ -11,12 +14,6 @@ pub fn background_executor() -> gpui::BackgroundExecutor {
|
||||
}
|
||||
|
||||
pub fn application() -> gpui::Application {
|
||||
#[cfg(target_family = "wasm")]
|
||||
{
|
||||
application_with_web_backend(gpui_web::WebBackendPreference::Auto)
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
gpui::Application::with_platform(current_platform(false))
|
||||
}
|
||||
|
||||
@@ -37,25 +34,20 @@ pub fn linux(allowed_modes: gpui::WindowingModes) -> gpui::Application {
|
||||
gpui::Application::with_platform(gpui_linux::linux_platform(allowed_modes))
|
||||
}
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub use gpui_web::WebBackendPreference;
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub fn application_with_web_backend(backend_preference: WebBackendPreference) -> gpui::Application {
|
||||
let platform = Rc::new(gpui_web::WebPlatform::new_with_backend(
|
||||
true,
|
||||
backend_preference,
|
||||
));
|
||||
let http_client = std::sync::Arc::new(platform.fetch_http_client());
|
||||
gpui::Application::with_platform(platform).with_http_client(http_client)
|
||||
gpui::Application::with_platform(platform)
|
||||
}
|
||||
|
||||
/// Unlike `application`, this function returns a single-threaded web application.
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub fn single_threaded_web() -> gpui::Application {
|
||||
let platform = Rc::new(gpui_web::WebPlatform::new(false));
|
||||
let http_client = std::sync::Arc::new(platform.fetch_http_client());
|
||||
gpui::Application::with_platform(platform).with_http_client(http_client)
|
||||
gpui::Application::with_platform(platform)
|
||||
}
|
||||
|
||||
/// Initializes panic hooks and logging for the web platform.
|
||||
@@ -68,44 +60,24 @@ pub fn web_init() {
|
||||
|
||||
/// Returns the default [`Platform`] for the current OS.
|
||||
pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
|
||||
#[cfg(target_os = "ios")]
|
||||
{
|
||||
gpui_ios::current_platform(headless)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
Rc::new(gpui_macos::MacPlatform::new(headless))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Rc::new(
|
||||
cfg_select! {
|
||||
target_os = "ios" => gpui_ios::current_platform(headless),
|
||||
target_os = "macos" => Rc::new(gpui_macos::MacPlatform::new(headless)),
|
||||
target_os = "windows" => Rc::new(
|
||||
gpui_windows::WindowsPlatform::new(headless)
|
||||
.expect("failed to initialize Windows platform"),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_env = "ohos")]
|
||||
{
|
||||
let _ = headless;
|
||||
panic!(
|
||||
"gpui_platform does not select an OpenHarmony backend; inject gpui-ohos with Application::with_platform"
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "freebsd"),
|
||||
not(target_env = "ohos")
|
||||
))]
|
||||
{
|
||||
gpui_linux::current_platform(headless)
|
||||
}
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
{
|
||||
let _ = headless;
|
||||
Rc::new(gpui_web::WebPlatform::new(true))
|
||||
),
|
||||
all(
|
||||
any(target_os = "linux", target_os = "freebsd"),
|
||||
not(target_env = "ohos")
|
||||
) => gpui_linux::current_platform(headless),
|
||||
target_family = "wasm" => {
|
||||
let _ = headless;
|
||||
Rc::new(gpui_web::WebPlatform::new_with_backend(
|
||||
true,
|
||||
gpui_web::WebBackendPreference::Auto,
|
||||
))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ edition = "2024"
|
||||
publish = false
|
||||
|
||||
[[bin]]
|
||||
name = "hello_web"
|
||||
name = "hello-web"
|
||||
path = "main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "hello_world"
|
||||
name = "hello-world"
|
||||
path = "../../../gpui/examples/hello_world.rs"
|
||||
|
||||
[[bin]]
|
||||
@@ -19,11 +19,11 @@ name = "text"
|
||||
path = "../../../gpui/examples/text.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "text_layout"
|
||||
name = "text-layout"
|
||||
path = "../../../gpui/examples/text_layout.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "text_wrapper"
|
||||
name = "text-wrapper"
|
||||
path = "../../../gpui/examples/text_wrapper.rs"
|
||||
|
||||
[[bin]]
|
||||
@@ -31,19 +31,19 @@ name = "input"
|
||||
path = "../../../gpui/examples/input.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "font_fallback_test"
|
||||
name = "font-fallback-test"
|
||||
path = "font_fallback_test.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "queue_test"
|
||||
name = "queue-test"
|
||||
path = "queue_test.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "dynamic_fonts"
|
||||
name = "dynamic-fonts"
|
||||
path = "dynamic_fonts.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "http_client_test"
|
||||
name = "http-client-test"
|
||||
path = "http_client_test.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use futures::AsyncReadExt as _;
|
||||
use gpui::Platform as _;
|
||||
use gpui_web::WebPlatform;
|
||||
use gpui_web::{FetchHttpClient, WebPlatform};
|
||||
use http_client::HttpClient as _;
|
||||
use std::sync::Arc;
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -15,7 +15,9 @@ fn main() {}
|
||||
#[wasm_bindgen]
|
||||
pub async fn test_worker_fetch(url: String) -> Result<(), JsValue> {
|
||||
let platform = WebPlatform::new(true);
|
||||
let client = Arc::new(platform.fetch_http_client());
|
||||
let client = Arc::new(FetchHttpClient::new(
|
||||
platform.foreground_executor().to_send(),
|
||||
));
|
||||
let background = platform.background_executor();
|
||||
let main_thread = std::thread::current().id();
|
||||
let readers = (0..8).map(|_| {
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=0" />
|
||||
<title>GPUI Web Examples</title>
|
||||
<link data-trunk rel="rust" data-bin="hello_web" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-bin="hello-web" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<!-- Trunk's worker pipelines build auxiliary modules without starting them.
|
||||
The gallery imports these on the main thread, not in Web Workers. -->
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="hello_world" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="hello-world" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="text" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="text_layout" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="text_wrapper" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="text-layout" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="text-wrapper" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="input" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<script data-trunk type="module" src="gallery.js"></script>
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="dynamic_fonts" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="font_fallback_test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="queue_test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="http_client_test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="dynamic-fonts" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="font-fallback-test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="queue-test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<link data-trunk rel="rust" data-type="worker" data-bin="http-client-test" data-bindgen-target="web" data-keep-debug data-wasm-opt="0" />
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@@ -99,13 +99,13 @@
|
||||
<h1>GPUI Web Examples</h1>
|
||||
<p>Each example runs in its own WebAssembly instance. Choose an example to open it.</p>
|
||||
<ul>
|
||||
<li><a href="/hello-world" data-module="hello_world"><strong>Hello world</strong><span>Basic GPUI layout and styling.</span></a></li>
|
||||
<li><a href="/hello-world" data-module="hello-world"><strong>Hello world</strong><span>Basic GPUI layout and styling.</span></a></li>
|
||||
<li><a href="/text" data-module="text"><strong>Styled text</strong><span>Typography, font sizes, and line heights.</span></a></li>
|
||||
<li><a href="/text-layout" data-module="text_layout"><strong>Text layout</strong><span>Alignment, decorations, and font weights.</span></a></li>
|
||||
<li><a href="/text-wrapper" data-module="text_wrapper"><strong>Text wrapping</strong><span>Wrapping and truncation, including CJK sample text.</span></a></li>
|
||||
<li><a href="/text-layout" data-module="text-layout"><strong>Text layout</strong><span>Alignment, decorations, and font weights.</span></a></li>
|
||||
<li><a href="/text-wrapper" data-module="text-wrapper"><strong>Text wrapping</strong><span>Wrapping and truncation, including CJK sample text.</span></a></li>
|
||||
<li><a href="/input" data-module="input"><strong>Text input</strong><span>Typing, cursor movement, and selections.</span></a></li>
|
||||
<li><a href="/dynamic-fonts" data-module="dynamic_fonts"><strong>Dynamic fonts</strong><span>Download a font when missing glyphs are reported.</span></a></li>
|
||||
<li><a href="/prime-sieve" data-module="hello_web"><strong>Prime sieve</strong><span>Background tasks and progress updates.</span></a></li>
|
||||
<li><a href="/dynamic-fonts" data-module="dynamic-fonts"><strong>Dynamic fonts</strong><span>Download a font when missing glyphs are reported.</span></a></li>
|
||||
<li><a href="/prime-sieve" data-module="hello-web"><strong>Prime sieve</strong><span>Background tasks and progress updates.</span></a></li>
|
||||
</ul>
|
||||
</main>
|
||||
<a id="back" href="/" hidden>All examples</a>
|
||||
|
||||
@@ -111,7 +111,7 @@ try {
|
||||
}
|
||||
assert.ok(await evaluate('!!document.querySelector("textarea")'), "Input example did not launch");
|
||||
await evaluate(`(async () => {
|
||||
const tests = await import("/font_fallback_test.js");
|
||||
const tests = await import("/font-fallback-test.js");
|
||||
await tests.default();
|
||||
tests.test_missing_glyph_notifications();
|
||||
})()`);
|
||||
|
||||
@@ -99,7 +99,7 @@ try {
|
||||
expression: `(async () => {
|
||||
const check = (condition, message) => { if (!condition) throw new Error(message); };
|
||||
check(crossOriginIsolated, "Shared-memory isolation headers are required");
|
||||
const fixture = await import("/http_client_test.js");
|
||||
const fixture = await import("/http-client-test.js");
|
||||
const bindings = await fixture.default();
|
||||
check(bindings.memory.buffer instanceof SharedArrayBuffer, "Wasm memory must be shared");
|
||||
let waitForbidden = false;
|
||||
|
||||
@@ -86,7 +86,7 @@ try {
|
||||
awaitPromise: true, returnByValue: true,
|
||||
expression: `(async () => {
|
||||
if (!crossOriginIsolated) throw new Error("Shared-memory isolation headers are required");
|
||||
const fixture = await import("/queue_test.js");
|
||||
const fixture = await import("/queue-test.js");
|
||||
await fixture.default();
|
||||
let trapped = false;
|
||||
try { fixture.forbidden_main_thread_wait(); }
|
||||
|
||||
@@ -44,7 +44,6 @@ enum MainThreadItem {
|
||||
runnable: RunnableVariant,
|
||||
timeout: Option<Duration>,
|
||||
},
|
||||
Function(Box<dyn FnOnce() + Send>),
|
||||
// TODO-Wasm: Shouldn't these run on their own dedicated thread?
|
||||
RealtimeFunction(Box<dyn FnOnce() + Send>),
|
||||
}
|
||||
@@ -226,19 +225,6 @@ impl WebDispatcher {
|
||||
fn on_main_thread(&self) -> bool {
|
||||
std::thread::current().id() == self.main_thread_id
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch_function_on_main_thread(
|
||||
&self,
|
||||
function: impl FnOnce() + Send + 'static,
|
||||
) {
|
||||
if self.on_main_thread() {
|
||||
let callback = Closure::once_into_js(function);
|
||||
browser_window().queue_microtask(callback.unchecked_ref());
|
||||
} else {
|
||||
self.main_thread_mailbox
|
||||
.post(Priority::High, MainThreadItem::Function(Box::new(function)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PlatformDispatcher for WebDispatcher {
|
||||
@@ -355,7 +341,7 @@ fn execute_on_main_thread(window: &web_sys::Window, item: MainThreadItem) {
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
MainThreadItem::Function(function) | MainThreadItem::RealtimeFunction(function) => {
|
||||
MainThreadItem::RealtimeFunction(function) => {
|
||||
function();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use crate::WebDispatcher;
|
||||
use anyhow::{Context as _, anyhow};
|
||||
use futures::{AsyncRead, AsyncReadExt as _, FutureExt as _, TryStreamExt as _, channel::oneshot};
|
||||
use gpui::SendForegroundExecutor;
|
||||
use http_client::{AsyncBody, HttpClient, RedirectPolicy};
|
||||
use std::{
|
||||
io,
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
use wasm_bindgen::JsCast as _;
|
||||
@@ -18,7 +17,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
pub struct FetchHttpClient {
|
||||
dispatcher: Arc<WebDispatcher>,
|
||||
foreground_executor: SendForegroundExecutor,
|
||||
user_agent: Option<http_client::http::header::HeaderValue>,
|
||||
credentials: FetchCredentials,
|
||||
}
|
||||
@@ -36,20 +35,22 @@ pub enum FetchCredentials {
|
||||
}
|
||||
|
||||
impl FetchHttpClient {
|
||||
pub(crate) fn new(dispatcher: Arc<WebDispatcher>) -> Self {
|
||||
/// Creates a browser Fetch client using the web platform's foreground executor.
|
||||
pub fn new(foreground_executor: SendForegroundExecutor) -> Self {
|
||||
Self {
|
||||
dispatcher,
|
||||
foreground_executor,
|
||||
user_agent: None,
|
||||
credentials: FetchCredentials::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn with_user_agent(
|
||||
dispatcher: Arc<WebDispatcher>,
|
||||
/// Creates a browser Fetch client with the given reported user agent.
|
||||
pub fn with_user_agent(
|
||||
foreground_executor: SendForegroundExecutor,
|
||||
user_agent: &str,
|
||||
) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
dispatcher,
|
||||
foreground_executor,
|
||||
user_agent: Some(http_client::http::header::HeaderValue::from_str(
|
||||
user_agent,
|
||||
)?),
|
||||
@@ -79,20 +80,22 @@ impl HttpClient for FetchHttpClient {
|
||||
{
|
||||
let (parts, body) = req.into_parts();
|
||||
let credentials = self.credentials;
|
||||
let dispatcher = self.dispatcher.clone();
|
||||
let foreground_executor = self.foreground_executor.clone();
|
||||
|
||||
Box::pin(async move {
|
||||
let body_bytes = read_body_to_bytes(body).await?;
|
||||
let (sender, receiver) = oneshot::channel();
|
||||
|
||||
dispatcher.dispatch_function_on_main_thread(move || {
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let result = fetch(parts, body_bytes, credentials).await;
|
||||
if sender.send(result).is_err() {
|
||||
log::debug!("fetch response receiver was dropped");
|
||||
}
|
||||
});
|
||||
});
|
||||
foreground_executor
|
||||
.spawn(async move {
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let result = fetch(parts, body_bytes, credentials).await;
|
||||
if sender.send(result).is_err() {
|
||||
log::debug!("fetch response receiver was dropped");
|
||||
}
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
|
||||
receiver.await.context("browser fetch task was canceled")?
|
||||
})
|
||||
|
||||
@@ -32,7 +32,6 @@ use wasm_bindgen::prelude::*;
|
||||
pub struct WebPlatform {
|
||||
browser_window: web_sys::Window,
|
||||
platform_info: gpui::PlatformInfo,
|
||||
dispatcher: Arc<WebDispatcher>,
|
||||
background_executor: BackgroundExecutor,
|
||||
foreground_executor: ForegroundExecutor,
|
||||
text_system: Arc<dyn PlatformTextSystem>,
|
||||
@@ -197,7 +196,6 @@ impl WebPlatform {
|
||||
Self {
|
||||
browser_window,
|
||||
platform_info,
|
||||
dispatcher,
|
||||
background_executor,
|
||||
foreground_executor,
|
||||
text_system,
|
||||
@@ -217,7 +215,7 @@ impl WebPlatform {
|
||||
|
||||
/// Returns an HTTP client that runs browser Fetch operations on this platform's main thread.
|
||||
pub fn fetch_http_client(&self) -> FetchHttpClient {
|
||||
FetchHttpClient::new(self.dispatcher.clone())
|
||||
FetchHttpClient::new(self.foreground_executor.to_send())
|
||||
}
|
||||
|
||||
/// Returns a browser Fetch HTTP client with the given reported user agent.
|
||||
@@ -225,7 +223,7 @@ impl WebPlatform {
|
||||
&self,
|
||||
user_agent: &str,
|
||||
) -> anyhow::Result<FetchHttpClient> {
|
||||
FetchHttpClient::with_user_agent(self.dispatcher.clone(), user_agent)
|
||||
FetchHttpClient::with_user_agent(self.foreground_executor.to_send(), user_agent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ doctest = false
|
||||
# DNS-rebinding/SSRF protection, so it must NEVER be enabled in a real Zed
|
||||
# build (debug or release) — it exists solely for the NixOS sandbox integration
|
||||
# tests, whose echo servers live on the VM's private network. Enabled only via
|
||||
# `sandbox/nixos-test` when building `bwrap_test_helper`.
|
||||
# `sandbox/nixos-test` when building `bwrap-test-helper`.
|
||||
nixos-integration-tests = []
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -160,7 +160,7 @@ pub fn is_forbidden_ip(ip: IpAddr) -> bool {
|
||||
// servers live on the VM's private network, which this filter would
|
||||
// otherwise reject. It is compiled in ONLY under the
|
||||
// `nixos-integration-tests` feature (enabled via `sandbox/nixos-test` when
|
||||
// building `bwrap_test_helper`), so in a real Zed build the env var has no
|
||||
// building `bwrap-test-helper`), so in a real Zed build the env var has no
|
||||
// effect and cannot disable DNS-rebinding/SSRF protection.
|
||||
#[cfg(feature = "nixos-integration-tests")]
|
||||
if std::env::var_os("ZED_SANDBOX_PROXY_ALLOW_LOCAL_IPS").is_some() {
|
||||
|
||||
@@ -8,7 +8,7 @@ edition.workspace = true
|
||||
test-support = ["http_client/test-support"]
|
||||
|
||||
[[bin]]
|
||||
name = "project_benchmarks"
|
||||
name = "project-benchmarks"
|
||||
path = "src/main.rs"
|
||||
required-features = ["test-support"]
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ async fn build_remote_server_from_source(
|
||||
.join("remote_server")
|
||||
.join(&triple)
|
||||
.join("debug")
|
||||
.join("remote_server")
|
||||
.join("remote-server")
|
||||
.with_extension(if platform.os.is_windows() { "exe" } else { "" });
|
||||
|
||||
let path = if !build_remote_server.contains("nocompress") {
|
||||
@@ -502,9 +502,16 @@ async fn build_remote_server_from_source(
|
||||
if smol::fs::metadata(&zip_path).await.is_ok() {
|
||||
smol::fs::remove_file(&zip_path).await?;
|
||||
}
|
||||
// SSH clients expect the underscore name inside the archive.
|
||||
let archive_bin_path = bin_path.with_file_name(if platform.os.is_windows() {
|
||||
"remote_server.exe"
|
||||
} else {
|
||||
"remote_server"
|
||||
});
|
||||
smol::fs::copy(&bin_path, &archive_bin_path).await?;
|
||||
let compress_command = format!(
|
||||
"Compress-Archive -Path '{}' -DestinationPath '{}' -Force",
|
||||
bin_path.display(),
|
||||
archive_bin_path.display(),
|
||||
zip_path.display(),
|
||||
);
|
||||
run_cmd(new_command("powershell.exe").args([
|
||||
@@ -513,6 +520,7 @@ async fn build_remote_server_from_source(
|
||||
&compress_command,
|
||||
]))
|
||||
.await?;
|
||||
smol::fs::remove_file(&archive_bin_path).await?;
|
||||
zip_path
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ path = "src/server.rs"
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "remote_server"
|
||||
name = "remote-server"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -177,7 +177,7 @@ fn test_remote_command_inherits_shell_environment() -> Result<()> {
|
||||
working_dir: None,
|
||||
};
|
||||
let exec =
|
||||
stdio_launcher_command(ShellKind::Posix, env!("CARGO_BIN_EXE_remote_server"))?;
|
||||
stdio_launcher_command(ShellKind::Posix, env!("CARGO_BIN_EXE_remote-server"))?;
|
||||
let mut child = shell_launcher(home.path(), &exec).spawn()?;
|
||||
child
|
||||
.stdin
|
||||
@@ -744,7 +744,7 @@ fn test_remote_command_launcher_survives_local_nushell() -> Result<()> {
|
||||
}
|
||||
|
||||
fn launcher() -> Command {
|
||||
let mut command = Command::new(env!("CARGO_BIN_EXE_remote_server"));
|
||||
let mut command = Command::new(env!("CARGO_BIN_EXE_remote-server"));
|
||||
command
|
||||
.arg("exec")
|
||||
.stdin(Stdio::piped())
|
||||
@@ -757,7 +757,7 @@ fn install_helper(home: &std::path::Path) -> Result<String> {
|
||||
let helper_directory = home.join(".local/share/zed");
|
||||
std::fs::create_dir_all(&helper_directory)?;
|
||||
let helper = helper_directory.join("remote server");
|
||||
std::os::unix::fs::symlink(env!("CARGO_BIN_EXE_remote_server"), &helper)?;
|
||||
std::os::unix::fs::symlink(env!("CARGO_BIN_EXE_remote-server"), &helper)?;
|
||||
Ok(helper.display().to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ path = "src/sandbox.rs"
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
# Builds `bwrap_test_helper`, the behavior helper driven by the NixOS sandbox
|
||||
# Builds `bwrap-test-helper`, the behavior helper driven by the NixOS sandbox
|
||||
# VM tests in `nix/tests/sandboxing`. Off by default so normal builds don't
|
||||
# produce the test binary. Pulls in serde only when enabled (the helper parses
|
||||
# its check list as JSON), and enables the matching `http_proxy` escape hatch so
|
||||
@@ -24,7 +24,7 @@ nixos-test = [
|
||||
"http_proxy/nixos-integration-tests",
|
||||
]
|
||||
|
||||
# Builds `wsl_sandbox_test_helper`, the Windows analog of `bwrap_test_helper`.
|
||||
# Builds `wsl-sandbox-test-helper`, the Windows analog of `bwrap-test-helper`.
|
||||
# It drives the real WSL/Bubblewrap sandbox end-to-end (see
|
||||
# `script/test-wsl-sandbox.ps1` / `cargo xtask wsl-sandbox-tests`). Off by
|
||||
# default so normal builds and the workspace test run don't produce it.
|
||||
@@ -33,14 +33,14 @@ wsl-test = []
|
||||
# Behavior test helper for the Linux Bubblewrap sandbox. Only built when the
|
||||
# `nixos-test` feature is enabled (and only meaningful on Linux).
|
||||
[[bin]]
|
||||
name = "bwrap_test_helper"
|
||||
name = "bwrap-test-helper"
|
||||
path = "src/bwrap_test_helper.rs"
|
||||
required-features = ["nixos-test"]
|
||||
|
||||
# Behavior test helper for the Windows WSL/Bubblewrap sandbox. Only built when
|
||||
# the `wsl-test` feature is enabled (and only meaningful on Windows).
|
||||
[[bin]]
|
||||
name = "wsl_sandbox_test_helper"
|
||||
name = "wsl-sandbox-test-helper"
|
||||
path = "src/wsl_sandbox_test_helper.rs"
|
||||
required-features = ["wsl-test"]
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn main() {
|
||||
eprintln!("bwrap_test_helper is only supported on Linux");
|
||||
eprintln!("bwrap-test-helper is only supported on Linux");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Behavior test helper for the Windows WSL Bubblewrap sandbox — the Windows
|
||||
//! analog of `bwrap_test_helper`.
|
||||
//! analog of `bwrap-test-helper`.
|
||||
//!
|
||||
//! Where the Linux helper is the sandboxed process itself (it re-execs under
|
||||
//! the launcher), here the sandboxed process is a *Linux* program inside WSL
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn main() {
|
||||
eprintln!("wsl_sandbox_test_helper is only supported on Windows");
|
||||
eprintln!("wsl-sandbox-test-helper is only supported on Windows");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ mod imp {
|
||||
allow_fs_write: bool,
|
||||
}
|
||||
|
||||
/// Tag prefixed to every result line, matching `bwrap_test_helper` so both
|
||||
/// Tag prefixed to every result line, matching `bwrap-test-helper` so both
|
||||
/// helpers' output reads the same.
|
||||
const RESULT_TAG: &str = "[sandbox_test]:";
|
||||
|
||||
@@ -722,7 +722,7 @@ mod imp {
|
||||
}
|
||||
|
||||
/// Tracks assertion results so the helper can report a summary and a single
|
||||
/// exit code, mirroring `bwrap_test_helper`.
|
||||
/// exit code, mirroring `bwrap-test-helper`.
|
||||
struct Checks {
|
||||
passed: usize,
|
||||
failed: usize,
|
||||
|
||||
@@ -51,6 +51,14 @@ impl LocalExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a thread-safe handle that submits `Send` futures to this executor's dispatch destination.
|
||||
pub fn to_send(&self) -> SendLocalExecutor {
|
||||
SendLocalExecutor {
|
||||
_scheduler: self.scheduler.clone(),
|
||||
dispatch: self.dispatch.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_id(&self) -> SessionId {
|
||||
self.session_id
|
||||
}
|
||||
@@ -193,6 +201,36 @@ impl LocalExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/// Submits `Send` futures from any thread to a [`LocalExecutor`]'s dispatch destination.
|
||||
///
|
||||
/// Retains the scheduler and dispatch destination independently of the original executor.
|
||||
#[derive(Clone)]
|
||||
pub struct SendLocalExecutor {
|
||||
_scheduler: Arc<dyn Scheduler>,
|
||||
dispatch: Arc<dyn Fn(Runnable<RunnableMeta>) + Send + Sync>,
|
||||
}
|
||||
|
||||
impl SendLocalExecutor {
|
||||
/// Spawns a future whose polls run on the original executor's dispatch thread.
|
||||
#[track_caller]
|
||||
pub fn spawn<F>(&self, future: F) -> Task<F::Output>
|
||||
where
|
||||
F: Future + Send + 'static,
|
||||
F::Output: Send + 'static,
|
||||
{
|
||||
let dispatch = self.dispatch.clone();
|
||||
let location = Location::caller();
|
||||
let (runnable, task) = async_task::Builder::new()
|
||||
.metadata(RunnableMeta {
|
||||
location,
|
||||
spawned: crate::SpawnTime(Instant::now()),
|
||||
})
|
||||
.spawn(move |_| future, move |runnable| dispatch(runnable));
|
||||
runnable.schedule();
|
||||
Task(TaskState::Spawned(task))
|
||||
}
|
||||
}
|
||||
|
||||
/// Boxes the user-supplied dedicated closure into the type-erased shape
|
||||
/// expected by [`Scheduler::spawn_dedicated`]. The user's `Fut::Output` is
|
||||
/// boxed as `Box<dyn Any + Send + Sync>` on the dedicated side and downcast
|
||||
|
||||
@@ -25,6 +25,89 @@ fn test_foreground_executor_spawn() {
|
||||
assert_eq!(result, 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_send_local_executor_worker_submission_and_wakeup() {
|
||||
let scheduler = Arc::new(TestScheduler::new(TestSchedulerConfig::default()));
|
||||
let dispatch_thread = std::thread::current().id();
|
||||
let (runnable_sender, runnable_receiver) = flume::unbounded();
|
||||
let executor = LocalExecutor::new(SessionId::new(0), scheduler, move |runnable| {
|
||||
runnable_sender
|
||||
.send(runnable)
|
||||
.expect("dispatch receiver dropped");
|
||||
});
|
||||
let executor = Arc::new(executor.to_send());
|
||||
let (waker_sender, waker_receiver) = flume::bounded::<Waker>(1);
|
||||
let (result_sender, result_receiver) = flume::bounded(1);
|
||||
let timeout = Duration::from_secs(5);
|
||||
|
||||
let worker = std::thread::spawn({
|
||||
move || {
|
||||
assert_ne!(std::thread::current().id(), dispatch_thread);
|
||||
let mut polls = 0;
|
||||
let task = executor.spawn(future::poll_fn(move |cx| {
|
||||
assert_eq!(std::thread::current().id(), dispatch_thread);
|
||||
polls += 1;
|
||||
if polls == 1 {
|
||||
waker_sender
|
||||
.send(cx.waker().clone())
|
||||
.expect("worker dropped");
|
||||
Poll::Pending
|
||||
} else {
|
||||
assert_eq!(polls, 2);
|
||||
Poll::Ready(std::cell::Cell::new(42))
|
||||
}
|
||||
}));
|
||||
waker_receiver
|
||||
.recv_timeout(timeout)
|
||||
.expect("task was not polled")
|
||||
.wake();
|
||||
result_sender
|
||||
.send(block_on(task).get())
|
||||
.expect("result receiver dropped");
|
||||
}
|
||||
});
|
||||
|
||||
for _ in 0..2 {
|
||||
runnable_receiver
|
||||
.recv_timeout(timeout)
|
||||
.expect("task was not dispatched")
|
||||
.run();
|
||||
}
|
||||
assert_eq!(
|
||||
result_receiver
|
||||
.recv_timeout(timeout)
|
||||
.expect("task did not complete"),
|
||||
42
|
||||
);
|
||||
worker.join().expect("worker panicked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_send_local_executor_retains_scheduler() {
|
||||
let scheduler = Arc::new(TestScheduler::new(TestSchedulerConfig::default()));
|
||||
let weak_scheduler = Arc::downgrade(&scheduler);
|
||||
let executor = scheduler.foreground();
|
||||
let send_executor = executor.to_send();
|
||||
let executor_clone = send_executor.clone();
|
||||
drop(send_executor);
|
||||
drop(executor);
|
||||
drop(scheduler);
|
||||
|
||||
let task = std::thread::spawn(move || {
|
||||
let task = executor_clone.spawn(async { 42 });
|
||||
(executor_clone, task)
|
||||
})
|
||||
.join()
|
||||
.expect("worker panicked");
|
||||
let (executor, task) = task;
|
||||
let scheduler = weak_scheduler.upgrade().expect("scheduler was dropped");
|
||||
scheduler.run();
|
||||
assert_eq!(block_on(task), 42);
|
||||
drop(scheduler);
|
||||
drop(executor);
|
||||
assert!(weak_scheduler.upgrade().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_background_executor_spawn() {
|
||||
TestScheduler::once(async |scheduler| {
|
||||
|
||||
@@ -8,6 +8,10 @@ license = "GPL-3.0-or-later"
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "schema-generator"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
|
||||
@@ -8,6 +8,10 @@ license = "GPL-3.0-or-later"
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "theme-importer"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
|
||||
@@ -4,6 +4,10 @@ version = "0.1.0"
|
||||
publish.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "worktree-benchmarks"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
fs.workspace = true
|
||||
gpui_platform.workspace = true
|
||||
|
||||
@@ -59,7 +59,7 @@ name = "zed"
|
||||
path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "zed_visual_test_runner"
|
||||
name = "zed-visual-test-runner"
|
||||
path = "src/visual_test_runner.rs"
|
||||
required-features = ["visual-tests"]
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
//! ## Usage
|
||||
//!
|
||||
//! Run the visual tests:
|
||||
//! cargo run -p zed --bin zed_visual_test_runner --features visual-tests
|
||||
//! cargo run -p zed --bin zed-visual-test-runner --features visual-tests
|
||||
//!
|
||||
//! Update baseline images (when UI intentionally changes):
|
||||
//! UPDATE_BASELINE=1 cargo run -p zed --bin zed_visual_test_runner --features visual-tests
|
||||
//! UPDATE_BASELINE=1 cargo run -p zed --bin zed-visual-test-runner --features visual-tests
|
||||
//!
|
||||
//! ## Environment Variables
|
||||
//!
|
||||
|
||||
+2
-2
@@ -110,7 +110,7 @@ Replace `<version>` with the new version of `c15t` you are installing. Then upda
|
||||
|
||||
## Postprocessor
|
||||
|
||||
A postprocessor is implemented as a sub-command of `docs_preprocessor` that wraps the built-in HTML renderer and applies post-processing to the HTML files, to add support for page-specific title and `meta` tag description values.
|
||||
A postprocessor is implemented as a sub-command of `docs-preprocessor` that wraps the built-in HTML renderer and applies post-processing to the HTML files, to add support for page-specific title and `meta` tag description values.
|
||||
|
||||
An example of the syntax can be found in `git.md`, as well as below:
|
||||
|
||||
@@ -140,7 +140,7 @@ If no front matter is provided, or if one or both keys aren't provided, the `tit
|
||||
### Implementation details
|
||||
|
||||
Unfortunately, mdBook does not support post-processing like it does pre-processing, and only supports defining one description to put in the `meta` tag per book rather than per file.
|
||||
So in order to apply post-processing (necessary to modify the HTML `head` tags) the global book description is set to a marker value `#description#` and the HTML renderer is replaced with a sub-command of `docs_preprocessor` that wraps the built-in HTML renderer and applies post-processing to the HTML files, replacing the marker value and the `<title>(.*)</title>` with the contents of the front matter if there is one.
|
||||
So in order to apply post-processing (necessary to modify the HTML `head` tags) the global book description is set to a marker value `#description#` and the HTML renderer is replaced with a sub-command of `docs-preprocessor` that wraps the built-in HTML renderer and applies post-processing to the HTML files, replacing the marker value and the `<title>(.*)</title>` with the contents of the front matter if there is one.
|
||||
|
||||
### Known limitations
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ You must grant Screen Recording permission to your terminal:
|
||||
### Running Visual Tests
|
||||
|
||||
```sh
|
||||
cargo run -p zed --bin zed_visual_test_runner --features visual-tests
|
||||
cargo run -p zed --bin zed-visual-test-runner --features visual-tests
|
||||
```
|
||||
|
||||
### Baseline Images
|
||||
@@ -92,7 +92,7 @@ Before making any UI changes, generate baseline images from a known-good state:
|
||||
|
||||
```sh
|
||||
git checkout origin/main
|
||||
UPDATE_BASELINE=1 cargo run -p zed --bin zed_visual_test_runner --features visual-tests
|
||||
UPDATE_BASELINE=1 cargo run -p zed --bin zed-visual-test-runner --features visual-tests
|
||||
git checkout -
|
||||
```
|
||||
|
||||
@@ -103,7 +103,7 @@ This creates baselines that reflect the current expected UI.
|
||||
When UI changes are intentional, update the baseline images after your changes:
|
||||
|
||||
```sh
|
||||
UPDATE_BASELINE=1 cargo run -p zed --bin zed_visual_test_runner --features visual-tests
|
||||
UPDATE_BASELINE=1 cargo run -p zed --bin zed-visual-test-runner --features visual-tests
|
||||
```
|
||||
|
||||
> **Note:** In the future, baselines may be stored externally. For now, they
|
||||
|
||||
@@ -228,7 +228,7 @@ If you'd like to maintain the server binary yourself you can. You can either dow
|
||||
|
||||
```bash
|
||||
cargo build --release --package remote_server
|
||||
llvm-objcopy --strip-debug target/release/remote_server
|
||||
llvm-objcopy --strip-debug target/release/remote-server
|
||||
```
|
||||
|
||||
Stripping debug symbols matches the packaging step in [`script/bundle-linux`](https://github.com/zed-industries/zed/blob/main/script/bundle-linux) and keeps the binary closer to the size of Zed's prebuilt downloads. Prefer `llvm-objcopy` because GNU `objcopy` may not understand newer LLVM-emitted CREL sections.
|
||||
@@ -237,7 +237,7 @@ The official Linux release builds a musl/static remote server. If you need that,
|
||||
|
||||
```bash
|
||||
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --package remote_server --target x86_64-unknown-linux-musl
|
||||
llvm-objcopy --strip-debug target/x86_64-unknown-linux-musl/release/remote_server
|
||||
llvm-objcopy --strip-debug target/x86_64-unknown-linux-musl/release/remote-server
|
||||
```
|
||||
|
||||
If you do this, you must upload it to `~/.zed_server/zed-remote-server-{RELEASE_CHANNEL}-{VERSION}` on the server, for example `~/.zed_server/zed-remote-server-stable-0.217.3+stable.105.80433cb239e868271457ac376673a5f75bc4adb1`. The version must exactly match the version of Zed itself you are using.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
dontUseCmakeConfigure = true;
|
||||
meta = {
|
||||
description = "mdBook preprocessor and postprocessor for the Zed docs";
|
||||
mainProgram = "docs_preprocessor";
|
||||
mainProgram = "docs-preprocessor";
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -118,8 +118,8 @@
|
||||
# instead of `cargo run`. mdBook lowercases these keys and turns `_`
|
||||
# into `-`, so they map to `preprocessor.zed-docs-preprocessor.command`
|
||||
# and `output.zed-html.command` in `docs/book.toml`.
|
||||
MDBOOK_PREPROCESSOR__ZED_DOCS_PREPROCESSOR__COMMAND = "${docs-preprocessor}/bin/docs_preprocessor";
|
||||
MDBOOK_OUTPUT__ZED_HTML__COMMAND = "${docs-preprocessor}/bin/docs_preprocessor postprocess";
|
||||
MDBOOK_PREPROCESSOR__ZED_DOCS_PREPROCESSOR__COMMAND = "${docs-preprocessor}/bin/docs-preprocessor";
|
||||
MDBOOK_OUTPUT__ZED_HTML__COMMAND = "${docs-preprocessor}/bin/docs-preprocessor postprocess";
|
||||
|
||||
ZED_ZSTD_MUSL_LIB = "${pkgs.pkgsCross.musl64.pkgsStatic.zstd.out}/lib";
|
||||
# For aws-lc-sys musl cross-compilation
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# `SandboxProbeFailed`.
|
||||
#
|
||||
# The behavior to assert is declared *here* as a list of `checks`, serialized to
|
||||
# JSON and handed to the `bwrap_test_helper` binary, which builds the described
|
||||
# JSON and handed to the `bwrap-test-helper` binary, which builds the described
|
||||
# sandbox policy via the sandbox crate's public API, performs the operation, and
|
||||
# asserts the outcome. Each check is one of:
|
||||
#
|
||||
@@ -191,7 +191,7 @@ let
|
||||
print(machine.succeed(
|
||||
"ZED_SANDBOX_CHECKS=${checksFile} "
|
||||
"ZED_TEST_ECHO_PORT=${toString echoPort} "
|
||||
"bwrap_test_helper 2>&1"
|
||||
"bwrap-test-helper 2>&1"
|
||||
))
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Builds the `bwrap_test_helper` binary (sandbox crate, `nixos-test` feature)
|
||||
# Builds the `bwrap-test-helper` binary (sandbox crate, `nixos-test` feature)
|
||||
# used by the Bubblewrap sandbox VM tests in this directory.
|
||||
{
|
||||
pkgs,
|
||||
@@ -38,7 +38,7 @@ let
|
||||
version = "0.0.0";
|
||||
inherit src;
|
||||
cargoLock = ../../../Cargo.lock;
|
||||
cargoExtraArgs = "-p sandbox --bin bwrap_test_helper --features sandbox/nixos-test --locked";
|
||||
cargoExtraArgs = "-p sandbox --bin bwrap-test-helper --features sandbox/nixos-test --locked";
|
||||
CARGO_PROFILE = "dev";
|
||||
doCheck = false;
|
||||
|
||||
@@ -58,7 +58,7 @@ craneLib.buildPackage (
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
cp target/debug/bwrap_test_helper $out/bin/bwrap_test_helper
|
||||
cp target/debug/bwrap-test-helper $out/bin/bwrap-test-helper
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ cargo build --release --target "${remote_server_triple}" --package remote_server
|
||||
|
||||
# Strip debug symbols and save them for upload to DigitalOcean
|
||||
# objcopy --only-keep-debug "${target_dir}/${target_triple}/release/zed" "${target_dir}/${target_triple}/release/zed.dbg"
|
||||
# objcopy --only-keep-debug "${target_dir}/${remote_server_triple}/release/remote_server" "${target_dir}/${remote_server_triple}/release/remote_server.dbg"
|
||||
# objcopy --only-keep-debug "${target_dir}/${remote_server_triple}/release/remote-server" "${target_dir}/${remote_server_triple}/release/remote-server.dbg"
|
||||
# objcopy --strip-debug "${target_dir}/${target_triple}/release/zed"
|
||||
# objcopy --strip-debug "${target_dir}/${target_triple}/release/cli"
|
||||
# objcopy --strip-debug "${target_dir}/${remote_server_triple}/release/remote_server"
|
||||
# objcopy --strip-debug "${target_dir}/${remote_server_triple}/release/remote-server"
|
||||
|
||||
# gzip -f "${target_dir}/${target_triple}/release/zed.dbg"
|
||||
# gzip -f "${target_dir}/${remote_server_triple}/release/remote_server.dbg"
|
||||
# gzip -f "${target_dir}/${remote_server_triple}/release/remote-server.dbg"
|
||||
|
||||
# if [[ -n "${DIGITALOCEAN_SPACES_SECRET_KEY:-}" && -n "${DIGITALOCEAN_SPACES_ACCESS_KEY:-}" ]]; then
|
||||
# upload_to_blob_store_public \
|
||||
@@ -80,12 +80,12 @@ cargo build --release --target "${remote_server_triple}" --package remote_server
|
||||
# "$channel/zed-$version-${target_triple}.dbg.gz"
|
||||
# upload_to_blob_store_public \
|
||||
# "zed-debug-symbols" \
|
||||
# "${target_dir}/${remote_server_triple}/release/remote_server.dbg.gz" \
|
||||
# "${target_dir}/${remote_server_triple}/release/remote-server.dbg.gz" \
|
||||
# "$channel/remote_server-$version-${remote_server_triple}.dbg.gz"
|
||||
# fi
|
||||
|
||||
# Ensure that remote_server does not depend on libssl nor libcrypto, as we got rid of these deps.
|
||||
if ldd "${target_dir}/${remote_server_triple}/release/remote_server" | grep -q 'libcrypto\|libssl'; then
|
||||
if ldd "${target_dir}/${remote_server_triple}/release/remote-server" | grep -q 'libcrypto\|libssl'; then
|
||||
echo "Error: remote_server still depends on libssl or libcrypto" && exit 1
|
||||
fi
|
||||
|
||||
@@ -157,5 +157,5 @@ arch=$(uname -m)
|
||||
# ls "${target_dir}/release" | grep -E ${remove_match} | xargs -d "\n" -I {} rm -f "${target_dir}/release/{}" || true
|
||||
# tar -czvf "${target_dir}/release/$archive" -C ${temp_dir} "zed$suffix.app"
|
||||
|
||||
gzip -f --stdout --best "${target_dir}/${remote_server_triple}/release/remote_server" \
|
||||
gzip -f --stdout --best "${target_dir}/${remote_server_triple}/release/remote-server" \
|
||||
> "${target_dir}/zed-remote-server-freebsd-x86_64.gz"
|
||||
|
||||
+4
-4
@@ -144,7 +144,7 @@ if ! "$skip_sentry"; then
|
||||
echo "Attempting sentry upload (attempt $attempt/3)..."
|
||||
if sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev \
|
||||
"${target_dir}/${target_triple}"/release/zed \
|
||||
"${target_dir}/${remote_server_triple}"/release/remote_server; then
|
||||
"${target_dir}/${remote_server_triple}"/release/remote-server; then
|
||||
echo "Sentry upload successful on attempt $attempt"
|
||||
break
|
||||
fi
|
||||
@@ -163,10 +163,10 @@ fi
|
||||
# We use llvm-objcopy because GNU objcopy on older distros (e.g. Ubuntu 20.04)
|
||||
# doesn't understand CREL sections produced by newer LLVM.
|
||||
llvm-objcopy --only-keep-debug "${target_dir}/${target_triple}/release/zed" "${target_dir}/${target_triple}/release/zed.dbg"
|
||||
llvm-objcopy --only-keep-debug "${target_dir}/${remote_server_triple}/release/remote_server" "${target_dir}/${remote_server_triple}/release/remote_server.dbg"
|
||||
llvm-objcopy --only-keep-debug "${target_dir}/${remote_server_triple}/release/remote-server" "${target_dir}/${remote_server_triple}/release/remote-server.dbg"
|
||||
|
||||
# Ensure that remote_server does not depend on libssl nor libcrypto, as we got rid of these deps.
|
||||
if ldd "${target_dir}/${remote_server_triple}/release/remote_server" | grep -q 'libcrypto\|libssl'; then
|
||||
if ldd "${target_dir}/${remote_server_triple}/release/remote-server" | grep -q 'libcrypto\|libssl'; then
|
||||
if [[ "$remote_server_triple" == *-musl ]]; then
|
||||
echo "Error: remote_server still depends on libssl or libcrypto" && exit 1
|
||||
else
|
||||
@@ -190,7 +190,7 @@ zed_dir="${temp_dir}/zed$suffix.app"
|
||||
mkdir -p "${zed_dir}/bin" "${zed_dir}/libexec"
|
||||
llvm-objcopy --strip-unneeded "${target_dir}/${target_triple}/release/zed" "${zed_dir}/libexec/zed-editor"
|
||||
llvm-objcopy --strip-debug --discard-all "${target_dir}/${target_triple}/release/cli" "${zed_dir}/bin/zed"
|
||||
llvm-objcopy --strip-debug --discard-all "${target_dir}/${remote_server_triple}/release/remote_server" "${temp_dir}/remote_server"
|
||||
llvm-objcopy --strip-debug --discard-all "${target_dir}/${remote_server_triple}/release/remote-server" "${temp_dir}/remote_server"
|
||||
|
||||
# Libs
|
||||
# Bundle libstdc++ so older supported systems can run binaries built with our
|
||||
|
||||
+5
-5
@@ -327,7 +327,7 @@ function extract_debug_symbols() {
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
fi
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/remote_server" 2> target/dsymutil.log; then
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/remote-server" 2> target/dsymutil.log; then
|
||||
echo "dsymutil failed"
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
@@ -345,7 +345,7 @@ function upload_debug_symbols() {
|
||||
echo "Sentry upload attempt $attempt..."
|
||||
if sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev \
|
||||
"target/${target_triple}/${target_dir}/zed.dwarf" \
|
||||
"target/${target_triple}/${target_dir}/remote_server.dwarf"; then
|
||||
"target/${target_triple}/${target_dir}/remote-server.dwarf"; then
|
||||
break
|
||||
else
|
||||
echo "Sentry upload failed on attempt $attempt"
|
||||
@@ -369,12 +369,12 @@ if [[ "$target_dir" == "release" && "$local_install" != true ]]; then
|
||||
extract_debug_symbols
|
||||
strip -x "target/${target_triple}/${target_dir}/zed"
|
||||
strip -x "target/${target_triple}/${target_dir}/cli"
|
||||
strip -x "target/${target_triple}/${target_dir}/remote_server"
|
||||
strip -x "target/${target_triple}/${target_dir}/remote-server"
|
||||
fi
|
||||
|
||||
cp target/${target_triple}/${target_dir}/zed "${app_path}/Contents/MacOS/zed"
|
||||
cp target/${target_triple}/${target_dir}/cli "${app_path}/Contents/MacOS/cli"
|
||||
sign_app_binaries
|
||||
|
||||
sign_binary "target/$target_triple/release/remote_server"
|
||||
gzip -f --stdout --best target/$target_triple/release/remote_server > target/zed-remote-server-macos-$arch_suffix.gz
|
||||
sign_binary "target/$target_triple/release/remote-server"
|
||||
gzip -f --stdout --best target/$target_triple/release/remote-server > target/zed-remote-server-macos-$arch_suffix.gz
|
||||
|
||||
@@ -115,11 +115,11 @@ function GenerateLicenses {
|
||||
|
||||
function BuildZedAndItsFriends {
|
||||
Write-Output "Building Zed and its friends, for channel: $channel"
|
||||
# Build zed.exe, cli.exe and auto_update_helper.exe
|
||||
# Build zed.exe, cli.exe and auto-update-helper.exe
|
||||
cargo --config .cargo/bundle-config.toml build --release --package zed --package cli --package auto_update_helper --target $target
|
||||
Copy-Item -Path ".\$CargoOutDir\zed.exe" -Destination "$innoDir\Zed.exe" -Force
|
||||
Copy-Item -Path ".\$CargoOutDir\cli.exe" -Destination "$innoDir\cli.exe" -Force
|
||||
Copy-Item -Path ".\$CargoOutDir\auto_update_helper.exe" -Destination "$innoDir\auto_update_helper.exe" -Force
|
||||
Copy-Item -Path ".\$CargoOutDir\auto-update-helper.exe" -Destination "$innoDir\auto_update_helper.exe" -Force
|
||||
# Build explorer_command_injector.dll
|
||||
switch ($channel) {
|
||||
"stable" {
|
||||
@@ -139,8 +139,9 @@ function BuildRemoteServer {
|
||||
Write-Output "Building remote_server for $target"
|
||||
cargo --config .cargo/bundle-config.toml build --release --package remote_server --target $target
|
||||
|
||||
# Create zipped remote server binary
|
||||
$remoteServerSrc = (Resolve-Path ".\$CargoOutDir\remote_server.exe").Path
|
||||
# SSH clients expect remote_server.exe inside the archive.
|
||||
Copy-Item -Path ".\$CargoOutDir\remote-server.exe" -Destination "$innoDir\remote_server.exe" -Force
|
||||
$remoteServerSrc = (Resolve-Path "$innoDir\remote_server.exe").Path
|
||||
|
||||
if ($canCodeSign) {
|
||||
Write-Output "Code signing remote_server.exe"
|
||||
@@ -150,6 +151,7 @@ function BuildRemoteServer {
|
||||
$remoteServerDst = "$env:ZED_WORKSPACE\target\zed-remote-server-windows-$Architecture.zip"
|
||||
Write-Output "Compressing remote_server to $remoteServerDst"
|
||||
Compress-Archive -Path $remoteServerSrc -DestinationPath $remoteServerDst -Force
|
||||
Remove-Item -Path $remoteServerSrc -Force
|
||||
|
||||
Write-Output "Remote server compressed successfully"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# current default WSL distro) user namespaces are restricted by AppArmor by
|
||||
# default, which is exactly why this step is needed.
|
||||
# 3. Runs `cargo xtask wsl-sandbox-tests`, which builds and runs
|
||||
# `wsl_sandbox_test_helper` against the real WSL/Bubblewrap sandbox.
|
||||
# `wsl-sandbox-test-helper` against the real WSL/Bubblewrap sandbox.
|
||||
#
|
||||
# By default it requires the sandbox to actually be enforced (so a broken setup
|
||||
# fails loudly instead of silently skipping). Pass -AllowSkip to keep the
|
||||
|
||||
@@ -9,7 +9,7 @@ use clap::Parser;
|
||||
/// of `cargo xtask sandbox-tests`.
|
||||
///
|
||||
/// Where the Linux tests boot a NixOS VM, here we build and run
|
||||
/// `wsl_sandbox_test_helper` (sandbox crate, `wsl-test` feature), which drives
|
||||
/// `wsl-sandbox-test-helper` (sandbox crate, `wsl-test` feature), which drives
|
||||
/// the real `windows_wsl::wrap_invocation`, spawns the resulting `wsl.exe`
|
||||
/// command, and asserts the sandbox's grants and restrictions hold end-to-end.
|
||||
///
|
||||
@@ -45,7 +45,7 @@ pub fn run_wsl_sandbox_tests(args: WslSandboxTestsArgs) -> Result<()> {
|
||||
"--features",
|
||||
"wsl-test",
|
||||
"--bin",
|
||||
"wsl_sandbox_test_helper",
|
||||
"wsl-sandbox-test-helper",
|
||||
]);
|
||||
if args.release {
|
||||
command.arg("--release");
|
||||
|
||||
Reference in New Issue
Block a user