Skip to content

Commit 8189c0b

Browse files
committed
Pretty print failing tests using Rust notation
Signed-off-by: Didier Wenzek <[email protected]>
1 parent 3e3e1a3 commit 8189c0b

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

Cargo.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ rand = "0.8"
155155
rcgen = { version = "0.12", features = ["pem", "zeroize"] }
156156
regex = "1.4"
157157
reqwest = { version = "0.12", default-features = false }
158+
ron = "0.8"
158159
rpassword = "5.0"
159160
rstest = "0.16.0"
160161
rumqttc = { git = "https://github.com/jarhodes314/rumqtt", rev = "8c489faf6af910956c97b55587ff3ecb2ac4e96f" }

crates/core/tedge_agent/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ bytes = { workspace = true }
6060
http-body = { workspace = true }
6161
proptest = { workspace = true }
6262
rcgen = { workspace = true }
63+
ron = { workspace = true }
6364
rustls-pemfile = { workspace = true }
6465
tedge_actors = { workspace = true, features = ["test-helpers"] }
6566
tedge_mqtt_ext = { workspace = true, features = ["test-helpers"] }

crates/core/tedge_agent/src/entity_manager/tests.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,23 @@ mod model {
196196

197197
for command in &self.0 {
198198
f.write_str(sep)?;
199-
f.write_str(format!("{command}").as_str())?;
200199
if f.alternate() {
201-
sep = "\n "; // On test unit output, print each command on a new line
200+
// On test unit output, print each command on a new line (using Rust notation)
201+
sep = "\n ";
202+
f.write_str(format!("// {command}{sep}").as_str())?;
203+
f.write_str(&ron::to_string(&command).unwrap())?;
202204
} else {
203-
sep = " && "; // On proptest log, print all the commands on a single line
205+
// On proptest log, print all the commands on a single line (using shell commands)
206+
sep = " && ";
207+
f.write_str(format!("{command}").as_str())?;
204208
}
205209
}
206210
f.write_str("\n")?;
207211
Ok(())
208212
}
209213
}
210214

211-
#[derive(Clone)]
215+
#[derive(Clone, serde::Serialize)]
212216
pub struct Command {
213217
pub protocol: Protocol,
214218
pub action: Action,
@@ -256,14 +260,14 @@ mod model {
256260
}
257261
}
258262

259-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
263+
#[derive(Debug, Copy, Clone, Eq, PartialEq, serde::Serialize)]
260264
#[allow(clippy::upper_case_acronyms)]
261265
pub enum Protocol {
262266
HTTP,
263267
MQTT,
264268
}
265269

266-
#[derive(Debug, Clone)]
270+
#[derive(Debug, Clone, serde::Serialize)]
267271
pub enum Action {
268272
AddDevice {
269273
topic: String,

0 commit comments

Comments
 (0)