Skip to content

Commit af4fe47

Browse files
committed
Collect IOPub streams until end matches
1 parent bcf1cfb commit af4fe47

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

crates/amalthea/src/fixtures/dummy_frontend.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,35 +518,31 @@ impl DummyFrontend {
518518
// Receive a piece of stream output (with a timeout)
519519
let msg = self.recv_iopub();
520520

521-
// Assert its type
522521
let piece = assert_matches!(msg, Message::Stream(data) => {
523522
assert_eq!(data.content.name, stream);
524523
data.content.text
525524
});
526525

527-
// Add to what we've already collected
528526
out += piece.as_str();
529527

530-
if out == expect {
531-
// Done, found the entire `expect` string
532-
return;
533-
}
534-
535-
if !expect.starts_with(out.as_str()) {
536-
// Something is wrong, message doesn't match up
537-
panic!("Expected IOPub stream of '{expect}'. Actual stream of '{out}'.");
528+
if out.ends_with(expect) {
529+
break;
538530
}
539531

540532
// We have a prefix of `expect`, but not the whole message yet.
541533
// Wait on the next IOPub Stream message.
542534
}
543535
}
544536

537+
/// Receives stdout stream output until the collected output ends with
538+
/// `expect`. Note: The comparison uses `ends_with`, not full equality.
545539
#[track_caller]
546540
pub fn recv_iopub_stream_stdout(&self, expect: &str) {
547541
self.recv_iopub_stream(expect, Stream::Stdout)
548542
}
549543

544+
/// Receives stderr stream output until the collected output ends with
545+
/// `expect`. Note: The comparison uses `ends_with`, not full equality.
550546
#[track_caller]
551547
pub fn recv_iopub_stream_stderr(&self, expect: &str) {
552548
self.recv_iopub_stream(expect, Stream::Stderr)

0 commit comments

Comments
 (0)