Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test helper improvements #6156

Merged
merged 7 commits into from
Mar 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
print doc state during tests
  • Loading branch information
dead10ck committed Mar 19, 2023
commit 88d2fa29706c88ae45bca18da0b761ff71ca6536
17 changes: 16 additions & 1 deletion helix-term/tests/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::bail;
use crossterm::event::{Event, KeyEvent};
use helix_core::{diagnostic::Severity, test, Selection, Transaction};
use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
use helix_view::{doc, editor::LspConfig, input::parse_macro, Editor};
use helix_view::{current_ref, doc, editor::LspConfig, input::parse_macro, Editor};
use tempfile::NamedTempFile;
use tokio_stream::wrappers::UnboundedReceiverStream;

Expand Down Expand Up @@ -64,6 +64,11 @@ pub async fn test_key_sequences(
let num_inputs = inputs.len();

for (i, (in_keys, test_fn)) in inputs.into_iter().enumerate() {
let (view, doc) = current_ref!(app.editor);
let state = test::plain(&doc.text().to_string(), doc.selection(view.id));

log::debug!("executing test with document state:\n\n-----\n\n{}", state);

if let Some(in_keys) = in_keys {
for key_event in parse_macro(in_keys)?.into_iter() {
let key = Event::Key(KeyEvent::from(key_event));
Expand All @@ -74,6 +79,16 @@ pub async fn test_key_sequences(

let app_exited = !app.event_loop_until_idle(&mut rx_stream).await;

if !app_exited {
let (view, doc) = current_ref!(app.editor);
let state = test::plain(&doc.text().to_string(), doc.selection(view.id));

log::debug!(
"finished running test with document state:\n\n-----\n\n{}",
state
);
}

// the app should not exit from any test until the last one
if i < num_inputs - 1 && app_exited {
bail!("application exited before test function could run");
Expand Down