on master help sign in
print doc state during tests
commit1db252913b427c806f89972edf1df6c80bc37fe6 authorSkyler Hawthorne <skyler@dead10ck.com> dateSat 22 Oct 2022, 22:19 (4 years ago) parent5b07ce7
1 file changed+16−1
helix-term/tests/test/helpers.rs+16−1
helix-term/tests/test/helpers.rs+16−1
@@ -9,7 +9,7 @@ use anyhow::bail;
99use crossterm::event::{Event, KeyEvent};
1010use helix_core::{diagnostic::Severity, test, Selection, Transaction};
1111use 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};
1313use tempfile::NamedTempFile;
1414use tokio_stream::wrappers::UnboundedReceiverStream;
1515
@@ -64,6 +64,11 @@ pub async fn test_key_sequences(
6464 let num_inputs = inputs.len();
6565
6666 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+
6772 if let Some(in_keys) = in_keys {
6873 for key_event in parse_macro(in_keys)?.into_iter() {
6974 let key = Event::Key(KeyEvent::from(key_event));
@@ -74,6 +79,16 @@ pub async fn test_key_sequences(
7479
7580 let app_exited = !app.event_loop_until_idle(&mut rx_stream).await;
7681
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+
7792 // the app should not exit from any test until the last one
7893 if i < num_inputs - 1 && app_exited {
7994 bail!("application exited before test function could run");