summaryrefslogtreecommitdiff
path: root/subplot/benchmark.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-12-26 17:21:49 +0000
committerLars Wirzenius <liw@liw.fi>2021-12-26 17:21:49 +0000
commit010480a957c52e14172049aea3e692447be8cdfe (patch)
treefefd20b8aa3da4d7771a46121fc03d8fb1c5dad0 /subplot/benchmark.rs
parent9f170606eb4fc24086274b446bb77cc1195280f0 (diff)
parentabfeccd0d839eef9e90397dcff40f0bf918ed477 (diff)
downloadobnam-benchmark-010480a957c52e14172049aea3e692447be8cdfe.tar.gz
Merge branch 'random' into 'main'
feat: generate test data with junk contents See merge request obnam/obnam-benchmark!3
Diffstat (limited to 'subplot/benchmark.rs')
-rw-r--r--subplot/benchmark.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/subplot/benchmark.rs b/subplot/benchmark.rs
index 566ce30..082e02b 100644
--- a/subplot/benchmark.rs
+++ b/subplot/benchmark.rs
@@ -72,3 +72,20 @@ fn read_json_file(filename: &Path) -> anyhow::Result<Value> {
let file = File::open(filename)?;
Ok(serde_json::from_reader(&file)?)
}
+
+#[step]
+#[context(Datadir)]
+#[context(SubplotContext)]
+fn file_is_at_least_this_long(context: &ScenarioContext, filename: &str, number: u64) {
+ context.with(
+ |context: &Datadir| {
+ let filename = context.canonicalise_filename(&filename)?;
+ let meta = std::fs::metadata(&filename)?;
+ if meta.len() < number {
+ panic!("file is {} bytes, wanted at least {} bytes", meta.len(), number);
+ }
+ Ok(())
+ },
+ false,
+ )?;
+}