Detailed changes
@@ -851,7 +851,6 @@ impl Client {
})
.detach();
- let t0 = Instant::now();
let this = self.clone();
let cx = cx.clone();
cx.foreground()
@@ -868,12 +867,7 @@ impl Client {
}
}
Err(err) => {
- // TODO - remove. Make the test's non-determinism more apparent by
- // only sometimes formatting this stack trace.
- if Instant::now().duration_since(t0).as_nanos() % 2 == 0 {
- log::error!("connection error: {:?}", err);
- }
-
+ log::error!("connection error: {:?}", err);
this.set_status(Status::ConnectionLost, &cx);
}
}
@@ -17,7 +17,7 @@ use project::{search::SearchQuery, Project};
use rand::prelude::*;
use std::{env, path::PathBuf, sync::Arc};
-#[gpui::test(iterations = 100, detect_nondeterminism = true)]
+#[gpui::test(iterations = 100)]
async fn test_random_collaboration(
cx: &mut TestAppContext,
deterministic: Arc<Deterministic>,
@@ -198,9 +198,7 @@ impl Deterministic {
let unparker = self.parker.lock().unparker();
let (runnable, task) = async_task::spawn_local(future, move |runnable| {
let mut state = state.lock();
- state
- .poll_history
- .push(ExecutorEvent::EnqueuRunnable { id });
+ state.push_to_history(ExecutorEvent::EnqueuRunnable { id });
state
.scheduled_from_foreground
.entry(cx_id)
@@ -45,7 +45,7 @@ fn test_random_edits(mut rng: StdRng) {
let mut buffer = Buffer::new(0, 0, reference_string.clone());
LineEnding::normalize(&mut reference_string);
- buffer.history.group_interval = Duration::from_millis(rng.gen_range(0..=200));
+ buffer.set_group_interval(Duration::from_millis(rng.gen_range(0..=200)));
let mut buffer_versions = Vec::new();
log::info!(
"buffer text {:?}, version: {:?}",
@@ -488,7 +488,7 @@ fn test_anchors_at_start_and_end() {
fn test_undo_redo() {
let mut buffer = Buffer::new(0, 0, "1234".into());
// Set group interval to zero so as to not group edits in the undo stack.
- buffer.history.group_interval = Duration::from_secs(0);
+ buffer.set_group_interval(Duration::from_secs(0));
buffer.edit([(1..1, "abx")]);
buffer.edit([(3..4, "yzef")]);
@@ -524,6 +524,7 @@ fn test_undo_redo() {
fn test_history() {
let mut now = Instant::now();
let mut buffer = Buffer::new(0, 0, "123456".into());
+ buffer.set_group_interval(Duration::from_millis(300));
let transaction_1 = buffer.start_transaction_at(now).unwrap();
buffer.edit([(2..4, "cd")]);
@@ -535,7 +536,7 @@ fn test_history() {
buffer.end_transaction_at(now).unwrap();
assert_eq!(buffer.text(), "12cde6");
- now += buffer.history.group_interval + Duration::from_millis(1);
+ now += buffer.transaction_group_interval() + Duration::from_millis(1);
buffer.start_transaction_at(now);
buffer.edit([(0..1, "a")]);
buffer.edit([(1..1, "b")]);
@@ -115,6 +115,10 @@ impl History {
undo_stack: Vec::new(),
redo_stack: Vec::new(),
transaction_depth: 0,
+ // Don't group transactions in tests unless we opt in, because it's a footgun.
+ #[cfg(any(test, feature = "test-support"))]
+ group_interval: Duration::ZERO,
+ #[cfg(not(any(test, feature = "test-support")))]
group_interval: Duration::from_millis(300),
}
}