summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-12-30 14:09:04 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-04 17:49:08 +0200
commit42bd070d7b71c3f9360f88ee50291eb66e54ccd9 (patch)
tree82c238f8b0e8bf8330e3eb84c0b14c99d668e571 /subplot
parent010480a957c52e14172049aea3e692447be8cdfe (diff)
downloadobnam-benchmark-42bd070d7b71c3f9360f88ee50291eb66e54ccd9.tar.gz
feat: actually run client and server
Also, switch Subplot step functions to Python: it was too hard to debug failures in the Rust ones. Sponsored-by: author
Diffstat (limited to 'subplot')
-rw-r--r--subplot/benchmark.py28
-rw-r--r--subplot/benchmark.rs2
-rw-r--r--subplot/benchmark.yaml8
3 files changed, 33 insertions, 5 deletions
diff --git a/subplot/benchmark.py b/subplot/benchmark.py
new file mode 100644
index 0000000..5400692
--- /dev/null
+++ b/subplot/benchmark.py
@@ -0,0 +1,28 @@
+import json
+import os
+
+
+def install_rust_program(ctx):
+ runcmd_prepend_to_path = globals()["runcmd_prepend_to_path"]
+ srcdir = globals()["srcdir"]
+
+ # Add the directory with built Rust binaries to the path.
+ default_target = os.path.join(srcdir, "target")
+ target = os.environ.get("CARGO_TARGET_DIR", default_target)
+ runcmd_prepend_to_path(ctx, dirname=os.path.join(target, "debug"))
+
+
+def file_is_at_least_this_long(ctx, filename=None, number=None):
+ st = os.lstat(filename)
+ assert st.st_size >= int(number)
+
+
+def json_files_match(ctx, first=None, second=None):
+ assert_eq = globals()["assert_eq"]
+ first = json.load(open(first))
+ second = json.load(open(second))
+ assert_eq(first, second)
+
+
+def file_is_valid_json(ctx, filename=None):
+ json.load(open(filename))
diff --git a/subplot/benchmark.rs b/subplot/benchmark.rs
index 082e02b..d7eda37 100644
--- a/subplot/benchmark.rs
+++ b/subplot/benchmark.rs
@@ -51,7 +51,7 @@ fn json_files_match(context: &ScenarioContext, first: &str, second: &str) {
Ok(())
},
false,
- );
+ )?;
}
#[step]
diff --git a/subplot/benchmark.yaml b/subplot/benchmark.yaml
index dc3a136..f745b23 100644
--- a/subplot/benchmark.yaml
+++ b/subplot/benchmark.yaml
@@ -1,19 +1,19 @@
- given: an installed Rust program obnam-benchmark
impl:
- rust:
+ python:
function: install_rust_program
- then: JSON files {first} and {second} match
impl:
- rust:
+ python:
function: json_files_match
- then: file {filename} is valid JSON
impl:
- rust:
+ python:
function: file_is_valid_json
- then: file {filename} is at least {number:int} bytes long
impl:
- rust:
+ python:
function: file_is_at_least_this_long