From 319e069106381d9311e598c592515fedefc60dd0 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:14:43 +0200 Subject: unwrap-or Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index ac414c7..b94dbe4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -92,7 +92,7 @@ impl ObnamBuilder { } let v = String::from_utf8_lossy(&output.stdout); - let v = v.strip_suffix('\n').or(Some(&v)).unwrap().to_string(); + let v = v.strip_suffix('\n').unwrap_or(&v).to_string(); Ok(v) } -- cgit v1.2.1 From 92ce5228ec468d573db67f73b8faedf7b2b04ea0 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:15:19 +0200 Subject: unwrap-or Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index b94dbe4..f2aadf2 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -140,7 +140,7 @@ fn git_create_branch(dir: &Path, branch: &str, commit: &str) -> Result<(), Obnam fn git_resolve(dir: &Path, commit: &str) -> Result { run("git", &["rev-parse", commit], dir) - .map(|s| s.strip_suffix('\n').or(Some("")).unwrap().to_string()) + .map(|s| s.strip_suffix('\n').unwrap_or("").to_string()) .map_err(ObnamBuilderError::Git) } -- cgit v1.2.1 From 0ff4ff6432538f0eefa031655c290459f981fe66 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:16:07 +0200 Subject: to_owned Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/client.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index dd2a624..43a52ec 100644 --- a/src/client.rs +++ b/src/client.rs @@ -58,9 +58,7 @@ impl ObnamClient { std::process::exit(1); } - Ok(String::from_utf8_lossy(&output.stdout) - .to_owned() - .to_string()) + Ok(String::from_utf8_lossy(&output.stdout).to_string()) } } -- cgit v1.2.1 From c21dd2c62fa089df5910f05eede744a387860acd Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:16:42 +0200 Subject: slice Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/daemon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon.rs b/src/daemon.rs index 8bf8adb..a4406a4 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -84,7 +84,7 @@ impl DaemonManager { info!("start daemon: {:?}", argv); let pid = NamedTempFile::new()?; let output = Command::new("daemonize") - .args(&[ + .args([ "-c", "/", "-e", -- cgit v1.2.1 From 04bf4b107c6e2e2414956b970cfcc0b44f470117 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:17:06 +0200 Subject: to_owned Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/daemon.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index a4406a4..3e3a189 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -134,11 +134,7 @@ impl DaemonManager { if !cmd.is_empty() { cmd.push(' '); } - cmd.push_str( - &String::from_utf8_lossy(arg.as_bytes()) - .to_owned() - .to_string(), - ); + cmd.push_str(&String::from_utf8_lossy(arg.as_bytes()).to_string()); } let err = read(&stderr).map_err(DaemonError::Stderr)?; let err = String::from_utf8_lossy(&err).into_owned(); -- cgit v1.2.1 From a174166b9f3d9ba2bed09bf2a7c0ff80188ca6a2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:17:43 +0200 Subject: as_ref Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/daemon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon.rs b/src/daemon.rs index 3e3a189..f615333 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -134,7 +134,7 @@ impl DaemonManager { if !cmd.is_empty() { cmd.push(' '); } - cmd.push_str(&String::from_utf8_lossy(arg.as_bytes()).to_string()); + cmd.push_str(String::from_utf8_lossy(arg.as_bytes()).to_string().as_ref()); } let err = read(&stderr).map_err(DaemonError::Stderr)?; let err = String::from_utf8_lossy(&err).into_owned(); -- cgit v1.2.1 From 2bbe1bbcbb6552915bb1238a61cfb70e5da24342 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:18:01 +0200 Subject: unnecessary borrow Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/daemon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon.rs b/src/daemon.rs index f615333..10c197c 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -136,7 +136,7 @@ impl DaemonManager { } cmd.push_str(String::from_utf8_lossy(arg.as_bytes()).to_string().as_ref()); } - let err = read(&stderr).map_err(DaemonError::Stderr)?; + let err = read(stderr).map_err(DaemonError::Stderr)?; let err = String::from_utf8_lossy(&err).into_owned(); Err(DaemonError::Timeout(self.timeout.as_millis(), cmd, err)) } -- cgit v1.2.1 From aecbc022010cca3eed48d2d3c4aa54de2d68f29f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:18:31 +0200 Subject: unwrap_or Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/suite.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/suite.rs b/src/suite.rs index 86c4c6d..aeeff80 100644 --- a/src/suite.rs +++ b/src/suite.rs @@ -250,8 +250,7 @@ impl Benchmark { .client .run(&["resolve", "latest"])? .strip_suffix('\n') - .or(Some("")) - .unwrap() + .unwrap_or("") .to_string(); debug!("backed up generation {}", gen_id); self.gen_ids.insert(n, gen_id); -- cgit v1.2.1 From 1f75fe4477d2a9fefb0c9ae703399e2dcbd05e36 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:18:51 +0200 Subject: to_owned Signed-off-by: Lars Wirzenius Sponsored-by: author --- src/summain.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/summain.rs b/src/summain.rs index ce9cf0f..3c977f1 100644 --- a/src/summain.rs +++ b/src/summain.rs @@ -19,7 +19,5 @@ pub fn summain(root: &Path) -> Result { std::process::exit(1); } - Ok(String::from_utf8_lossy(&output.stdout) - .to_owned() - .to_string()) + Ok(String::from_utf8_lossy(&output.stdout).to_string()) } -- cgit v1.2.1 From 742ad488bf780df4e480c71c97d029e93722f6d1 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:21:04 +0200 Subject: chore: use a .subplot file instead of embedded YAML Subplot no longer supports the embedded YAML. Signed-off-by: Lars Wirzenius Sponsored-by: author --- check | 5 ++--- obnam-benchmark.md | 16 ---------------- obnam-benchmark.subplot | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 obnam-benchmark.subplot diff --git a/check b/check index cc8ef6c..c23d849 100755 --- a/check +++ b/check @@ -5,9 +5,8 @@ set -euo pipefail cargo clippy -q --all-targets -- -D clippy::all cargo build --all-targets -q chronic cargo test -q -subplot docgen obnam-benchmark.md -o obnam-benchmark.html -subplot docgen obnam-benchmark.md -o obnam-benchmark.pdf -subplot codegen obnam-benchmark.md -o test.py +subplot docgen obnam-benchmark.subplot -o obnam-benchmark.html +subplot codegen obnam-benchmark.subplot -o test.py chronic python3 test.py --log test.log "$@" cargo fmt -- --check echo A-OK diff --git a/obnam-benchmark.md b/obnam-benchmark.md index 5fc3164..d68b695 100644 --- a/obnam-benchmark.md +++ b/obnam-benchmark.md @@ -1,19 +1,3 @@ ---- -title: "`obnam-benchmark`---tool to run benchmarks" -author: "The Obnam project" -documentclass: report -bindings: -- subplot/benchmark.yaml -- lib/files.yaml -- lib/runcmd.yaml -impls: - python: - - subplot/benchmark.py - - lib/files.py - - lib/runcmd.py -... - - # Introduction Obnam is a backup program. It aims to have good performance. To diff --git a/obnam-benchmark.subplot b/obnam-benchmark.subplot new file mode 100644 index 0000000..b0da175 --- /dev/null +++ b/obnam-benchmark.subplot @@ -0,0 +1,14 @@ +title: "`obnam-benchmark`---tool to run benchmarks" +authors: + - The Obnam project +markdowns: + - obnam-benchmark.md +bindings: +- subplot/benchmark.yaml +- lib/files.yaml +- lib/runcmd.yaml +impls: + python: + - subplot/benchmark.py + - lib/files.py + - lib/runcmd.py -- cgit v1.2.1 From 3e089045170cfba1c53bb55e8d1bac8734f66d30 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:26:43 +0200 Subject: tests(check): add --offline for Ambient Signed-off-by: Lars Wirzenius Sponsored-by: author --- check | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/check b/check index c23d849..9056788 100755 --- a/check +++ b/check @@ -2,9 +2,15 @@ set -euo pipefail +offline= +if [ "$#" -gt 0 ] && [ "$1" = "--offline" ]; then + offline=--offline + shift 1 +fi + cargo clippy -q --all-targets -- -D clippy::all -cargo build --all-targets -q -chronic cargo test -q +cargo build --all-targets -q $offline +chronic cargo test -q $offline subplot docgen obnam-benchmark.subplot -o obnam-benchmark.html subplot codegen obnam-benchmark.subplot -o test.py chronic python3 test.py --log test.log "$@" -- cgit v1.2.1 From 9ffb76f4839baae6cc8370ed1eca2ee4bb44c5fc Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 19:32:17 +0200 Subject: tests(check): if test.py fails, output test.log This makes it easier to see in a CI situation. Signed-off-by: Lars Wirzenius Sponsored-by: author --- check | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check b/check index 9056788..ea6f30d 100755 --- a/check +++ b/check @@ -13,6 +13,9 @@ cargo build --all-targets -q $offline chronic cargo test -q $offline subplot docgen obnam-benchmark.subplot -o obnam-benchmark.html subplot codegen obnam-benchmark.subplot -o test.py -chronic python3 test.py --log test.log "$@" +if ! chronic python3 test.py --log test.log "$@"; then + cat test.log + exit 1 +fi cargo fmt -- --check echo A-OK -- cgit v1.2.1 From f29c6e680baefec5289d4fb75d7bf96118b62d84 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 15 Mar 2024 07:43:33 +0200 Subject: debian/rules: offline, no dh-cargo Signed-off-by: Lars Wirzenius Sponsored-by: author --- debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index 29cabab..f27120f 100755 --- a/debian/rules +++ b/debian/rules @@ -1,13 +1,13 @@ #!/usr/bin/make -f %: - dh $@ --buildsystem cargo + dh $@ override_dh_auto_build: true override_dh_auto_install: - cargo install --path=. --root=debian/obnam-benchmark + cargo install --offline --path=. --root=debian/obnam-benchmark find debian -name '.crates*' -delete override_dh_auto_test: -- cgit v1.2.1