summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary
diff options
context:
space:
mode:
Diffstat (limited to 'subplotlib/src/steplibrary')
-rw-r--r--subplotlib/src/steplibrary/datadir.rs3
-rw-r--r--subplotlib/src/steplibrary/files.rs10
-rw-r--r--subplotlib/src/steplibrary/runcmd.rs26
3 files changed, 20 insertions, 19 deletions
diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs
index 5a344df..5060f63 100644
--- a/subplotlib/src/steplibrary/datadir.rs
+++ b/subplotlib/src/steplibrary/datadir.rs
@@ -150,8 +150,7 @@ pub fn datadir_has_enough_space(datadir: &Datadir, bytes: u64) {
let available = fs2::available_space(datadir.base_path())?;
if available < bytes {
throw!(format!(
- "Available space check failed, wanted {} bytes, but only {} were available",
- bytes, available
+ "Available space check failed, wanted {bytes} bytes, but only {available} were available",
));
}
}
diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs
index 8abe546..b1596ae 100644
--- a/subplotlib/src/steplibrary/files.rs
+++ b/subplotlib/src/steplibrary/files.rs
@@ -90,7 +90,7 @@ pub fn touch_with_timestamp(context: &Datadir, filename: &Path, mtime: &str) {
let fd = format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour]:[offset_minute]"
);
- let full_time = format!("{} +00:00", mtime);
+ let full_time = format!("{mtime} +00:00");
let ts = OffsetDateTime::parse(&full_time, &fd)?;
let (secs, nanos) = (ts.unix_timestamp(), 0);
let mtime = FileTime::from_unix_time(secs, nanos);
@@ -99,6 +99,7 @@ pub fn touch_with_timestamp(context: &Datadir, filename: &Path, mtime: &str) {
drop(
OpenOptions::new()
.create(true)
+ .truncate(false)
.write(true)
.open(&full_path)?,
);
@@ -130,7 +131,7 @@ pub fn remember_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
context.with_mut(
|context: &mut Files| {
context.metadata.insert(filename.to_owned(), metadata);
@@ -154,6 +155,7 @@ pub fn touch(context: &Datadir, filename: &Path) {
drop(
OpenOptions::new()
.create(true)
+ .truncate(false)
.write(true)
.open(&full_path)?,
);
@@ -320,7 +322,7 @@ pub fn has_remembered_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
if let Some(remembered) = context.with(
|context: &Files| Ok(context.metadata.get(filename).cloned()),
false,
@@ -359,7 +361,7 @@ pub fn has_different_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
if let Some(remembered) = context.with(
|context: &Files| Ok(context.metadata.get(filename).cloned()),
false,
diff --git a/subplotlib/src/steplibrary/runcmd.rs b/subplotlib/src/steplibrary/runcmd.rs
index 6692441..99605a3 100644
--- a/subplotlib/src/steplibrary/runcmd.rs
+++ b/subplotlib/src/steplibrary/runcmd.rs
@@ -353,7 +353,7 @@ pub fn exit_code_is(context: &Runcmd, exit: i32) {
#[step]
pub fn exit_code_is_not(context: &Runcmd, exit: i32) {
if context.exitcode.is_none() || context.exitcode == Some(exit) {
- throw!(format!("Expected exit code to not equal {}", exit));
+ throw!(format!("Expected exit code to not equal {exit}"));
}
}
@@ -422,7 +422,7 @@ fn check_matches(runcmd: &Runcmd, which: Stream, how: MatchKind, against: &str)
#[step]
pub fn stdout_is(runcmd: &Runcmd, text: &str) {
if !check_matches(runcmd, Stream::Stdout, MatchKind::Exact, text)? {
- throw!(format!("stdout is not {:?}", text));
+ throw!(format!("stdout is not {text:?}"));
}
}
@@ -435,7 +435,7 @@ pub fn stdout_is(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stdout_isnt(runcmd: &Runcmd, text: &str) {
if check_matches(runcmd, Stream::Stdout, MatchKind::Exact, text)? {
- throw!(format!("stdout is exactly {:?}", text));
+ throw!(format!("stdout is exactly {text:?}"));
}
}
@@ -448,7 +448,7 @@ pub fn stdout_isnt(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stderr_is(runcmd: &Runcmd, text: &str) {
if !check_matches(runcmd, Stream::Stderr, MatchKind::Exact, text)? {
- throw!(format!("stderr is not {:?}", text));
+ throw!(format!("stderr is not {text:?}"));
}
}
@@ -461,7 +461,7 @@ pub fn stderr_is(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stderr_isnt(runcmd: &Runcmd, text: &str) {
if check_matches(runcmd, Stream::Stderr, MatchKind::Exact, text)? {
- throw!(format!("stderr is exactly {:?}", text));
+ throw!(format!("stderr is exactly {text:?}"));
}
}
@@ -474,7 +474,7 @@ pub fn stderr_isnt(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stdout_contains(runcmd: &Runcmd, text: &str) {
if !check_matches(runcmd, Stream::Stdout, MatchKind::Contains, text)? {
- throw!(format!("stdout does not contain {:?}", text));
+ throw!(format!("stdout does not contain {text:?}"));
}
}
@@ -487,7 +487,7 @@ pub fn stdout_contains(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stdout_doesnt_contain(runcmd: &Runcmd, text: &str) {
if check_matches(runcmd, Stream::Stdout, MatchKind::Contains, text)? {
- throw!(format!("stdout contains {:?}", text));
+ throw!(format!("stdout contains {text:?}"));
}
}
@@ -500,7 +500,7 @@ pub fn stdout_doesnt_contain(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stderr_contains(runcmd: &Runcmd, text: &str) {
if !check_matches(runcmd, Stream::Stderr, MatchKind::Contains, text)? {
- throw!(format!("stderr does not contain {:?}", text));
+ throw!(format!("stderr does not contain {text:?}"));
}
}
@@ -513,7 +513,7 @@ pub fn stderr_contains(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stderr_doesnt_contain(runcmd: &Runcmd, text: &str) {
if check_matches(runcmd, Stream::Stderr, MatchKind::Contains, text)? {
- throw!(format!("stderr contains {:?}", text));
+ throw!(format!("stderr contains {text:?}"));
}
}
@@ -527,7 +527,7 @@ pub fn stderr_doesnt_contain(runcmd: &Runcmd, text: &str) {
#[step]
pub fn stdout_matches_regex(runcmd: &Runcmd, regex: &str) {
if !check_matches(runcmd, Stream::Stdout, MatchKind::Regex, regex)? {
- throw!(format!("stdout does not match {:?}", regex));
+ throw!(format!("stdout does not match {regex:?}"));
}
}
@@ -541,7 +541,7 @@ pub fn stdout_matches_regex(runcmd: &Runcmd, regex: &str) {
#[step]
pub fn stdout_doesnt_match_regex(runcmd: &Runcmd, regex: &str) {
if check_matches(runcmd, Stream::Stdout, MatchKind::Regex, regex)? {
- throw!(format!("stdout matches {:?}", regex));
+ throw!(format!("stdout matches {regex:?}"));
}
}
@@ -555,7 +555,7 @@ pub fn stdout_doesnt_match_regex(runcmd: &Runcmd, regex: &str) {
#[step]
pub fn stderr_matches_regex(runcmd: &Runcmd, regex: &str) {
if !check_matches(runcmd, Stream::Stderr, MatchKind::Regex, regex)? {
- throw!(format!("stderr does not match {:?}", regex));
+ throw!(format!("stderr does not match {regex:?}"));
}
}
@@ -569,6 +569,6 @@ pub fn stderr_matches_regex(runcmd: &Runcmd, regex: &str) {
#[step]
pub fn stderr_doesnt_match_regex(runcmd: &Runcmd, regex: &str) {
if check_matches(runcmd, Stream::Stderr, MatchKind::Regex, regex)? {
- throw!(format!("stderr matches {:?}", regex));
+ throw!(format!("stderr matches {regex:?}"));
}
}