Skip to content

Commit 0cdb247

Browse files
committed
mock: Add Debug impls to a bunch of bits
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
1 parent 22f2be6 commit 0cdb247

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tests/mock/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ pub struct MockChannel {
8282
}
8383

8484
// A single rust-installer package
85-
#[derive(Hash, Eq, PartialEq)]
85+
#[derive(Debug, Hash, Eq, PartialEq)]
8686
pub struct MockPackage {
8787
// rust, rustc, rust-std-$triple, rust-doc, etc.
8888
pub name: &'static str,
8989
pub version: String,
9090
pub targets: Vec<MockTargetedPackage>,
9191
}
9292

93-
#[derive(Hash, Eq, PartialEq, Clone)]
93+
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
9494
pub struct MockTargetedPackage {
9595
// Target triple
9696
pub target: String,
@@ -101,7 +101,7 @@ pub struct MockTargetedPackage {
101101
pub installer: MockInstallerBuilder,
102102
}
103103

104-
#[derive(PartialEq, Eq, Hash, Clone)]
104+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
105105
pub struct MockComponent {
106106
pub name: String,
107107
pub target: String,

tests/mock/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ use std::path::Path;
1212
use std::sync::Arc;
1313

1414
// Mock of the on-disk structure of rust-installer installers
15-
#[derive(PartialEq, Eq, Hash, Clone)]
15+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
1616
pub struct MockInstallerBuilder {
1717
pub components: Vec<MockComponentBuilder>,
1818
}
1919

20-
#[derive(PartialEq, Eq, Hash, Clone)]
20+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
2121
pub struct MockComponentBuilder {
2222
pub name: String,
2323
pub files: Vec<MockFile>,
2424
}
2525

26-
#[derive(PartialEq, Eq, Hash, Clone)]
26+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
2727
pub struct MockFile {
2828
path: String,
2929
contents: Contents,
3030
}
3131

32-
#[derive(PartialEq, Eq, Hash, Clone)]
32+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
3333
enum Contents {
3434
File(MockContents),
3535
Dir(Vec<(&'static str, MockContents)>),
@@ -41,6 +41,15 @@ struct MockContents {
4141
executable: bool,
4242
}
4343

44+
impl std::fmt::Debug for MockContents {
45+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46+
f.debug_struct("MockContents")
47+
.field("content_len", &self.contents.len())
48+
.field("executable", &self.executable)
49+
.finish()
50+
}
51+
}
52+
4453
impl MockInstallerBuilder {
4554
pub fn build(&self, path: &Path) {
4655
for component in &self.components {

0 commit comments

Comments
 (0)