summaryrefslogtreecommitdiffstats
path: root/mqtt-tester
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-01-13 11:56:22 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-01-19 10:01:40 +0100
commit9dee7c8d16e2d78b3847523958ba1610d7c9ea5f (patch)
tree829978ddf43d73e2ad9f29ccaecde2f75dba91d6 /mqtt-tester
parent3b6b8c69c0a1eb6935e57fac7ea884df1c2282e7 (diff)
Fix: Execute behaviour tests properly
Somehow we messed up the execution of the behaviour tests when implementing it. This patch changes the execution to match the previous implementation of the `check_*` async functions. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'mqtt-tester')
-rw-r--r--mqtt-tester/src/client_report.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/mqtt-tester/src/client_report.rs b/mqtt-tester/src/client_report.rs
index f02359d..ef131ce 100644
--- a/mqtt-tester/src/client_report.rs
+++ b/mqtt-tester/src/client_report.rs
@@ -8,6 +8,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use futures::FutureExt;
+use futures::TryFutureExt;
use miette::IntoDiagnostic;
use mqtt_format::v3::packet::{MConnect, MPacket};
@@ -61,19 +62,26 @@ pub async fn create_client_report(
output.with_invariants(invariants.iter().cloned());
- let flow_result = flow.execute(input, output).await;
- let client_output = client.wait_with_output().await.into_diagnostic()?;
+ let (result, output) = match tokio::time::timeout(std::time::Duration::from_millis(100), {
+ flow.execute(input, output)
+ .and_then(|()| async { client.wait_with_output().await.into_diagnostic() })
+ })
+ .await
+ {
+ Ok(Ok(out)) => {
+ let res = flow.translate_client_exit_code(out.status.success());
+ (res, Some(out.stderr))
+ }
+ Ok(Err(_)) | Err(_) => (ReportResult::Failure, None),
+ };
collected_reports.push({
Report {
name: String::from(flow.report_name()),
description: String::from(flow.report_desc()),
normative_statement_number: String::from(flow.report_normative()),
- result: match flow_result {
- Ok(_) => flow.translate_client_exit_code(client_output.status.success()),
- Err(_e) => ReportResult::Failure,
- },
- output: Some(client_output.stdout),
+ result,
+ output,
}
})
}