on master help sign in
print doc state during tests
1db2529Skyler Hawthorne
helix-term/tests/test/helpers.rs+16−1
@@ -9,7 +9,7 @@ use anyhow::bail;
9use crossterm::event::{Event, KeyEvent};
9use crossterm::event::{Event, KeyEvent};
10use helix_core::{diagnostic::Severity, test, Selection, Transaction};
10use helix_core::{diagnostic::Severity, test, Selection, Transaction};
11use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
11use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
12−use helix_view::{doc, editor::LspConfig, input::parse_macro, Editor};
12+use helix_view::{current_ref, doc, editor::LspConfig, input::parse_macro, Editor};
13use tempfile::NamedTempFile;
13use tempfile::NamedTempFile;
14use tokio_stream::wrappers::UnboundedReceiverStream;
14use tokio_stream::wrappers::UnboundedReceiverStream;
15
15
@@ -64,6 +64,11 @@ pub async fn test_key_sequences(
64 let num_inputs = inputs.len();
64 let num_inputs = inputs.len();
65
65
66 for (i, (in_keys, test_fn)) in inputs.into_iter().enumerate() {
66 for (i, (in_keys, test_fn)) in inputs.into_iter().enumerate() {
67+ let (view, doc) = current_ref!(app.editor);
68+ let state = test::plain(&doc.text().to_string(), doc.selection(view.id));
69+
70+ log::debug!("executing test with document state:\n\n-----\n\n{}", state);
71+
67 if let Some(in_keys) = in_keys {
72 if let Some(in_keys) = in_keys {
68 for key_event in parse_macro(in_keys)?.into_iter() {
73 for key_event in parse_macro(in_keys)?.into_iter() {
69 let key = Event::Key(KeyEvent::from(key_event));
74 let key = Event::Key(KeyEvent::from(key_event));
@@ -74,6 +79,16 @@ pub async fn test_key_sequences(
74
79
75 let app_exited = !app.event_loop_until_idle(&mut rx_stream).await;
80 let app_exited = !app.event_loop_until_idle(&mut rx_stream).await;
76
81
82+ if !app_exited {
83+ let (view, doc) = current_ref!(app.editor);
84+ let state = test::plain(&doc.text().to_string(), doc.selection(view.id));
85+
86+ log::debug!(
87+ "finished running test with document state:\n\n-----\n\n{}",
88+ state
89+ );
90+ }
91+
77 // the app should not exit from any test until the last one
92 // the app should not exit from any test until the last one
78 if i < num_inputs - 1 && app_exited {
93 if i < num_inputs - 1 && app_exited {
79 bail!("application exited before test function could run");
94 bail!("application exited before test function could run");