chore(dev): justfile (ядро) + CI-гейт (lint/test/deny) + rustfmt
just ci зелёный: fmt + clippy(-D warnings) + 6 unit-тестов common + cargo-deny. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Alexander <akotenev2003@gmail.com>
This commit is contained in:
@@ -23,7 +23,10 @@ pub fn tmp_path(path: &Path) -> PathBuf {
|
||||
/// Атомарно и durable записать `contents` в `path`.
|
||||
pub fn write_atomic(path: &Path, contents: &[u8]) -> io::Result<()> {
|
||||
let dir = path.parent().ok_or_else(|| {
|
||||
io::Error::new(io::ErrorKind::InvalidInput, "путь без родительского каталога")
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
"путь без родительского каталога",
|
||||
)
|
||||
})?;
|
||||
let tmp = tmp_path(path);
|
||||
|
||||
@@ -61,7 +64,10 @@ mod tests {
|
||||
write_atomic(&p, b"old").unwrap();
|
||||
write_atomic(&p, b"new").unwrap();
|
||||
assert_eq!(fs::read(&p).unwrap(), b"new");
|
||||
assert!(!tmp_path(&p).exists(), "осиротевший .tmp не должен оставаться");
|
||||
assert!(
|
||||
!tmp_path(&p).exists(),
|
||||
"осиротевший .tmp не должен оставаться"
|
||||
);
|
||||
}
|
||||
|
||||
// Целостность основного файла не зависит от постороннего .tmp (rename атомарен на одной ФС).
|
||||
|
||||
@@ -58,6 +58,9 @@ mod tests {
|
||||
assert_eq!(l.settings(), Path::new("/tmp/x/settings"));
|
||||
assert_eq!(l.state(), Path::new("/tmp/x/state"));
|
||||
assert_eq!(l.log(), Path::new("/tmp/x/log"));
|
||||
assert_eq!(l.provisioned_marker(), Path::new("/tmp/x/.shturman-provisioned"));
|
||||
assert_eq!(
|
||||
l.provisioned_marker(),
|
||||
Path::new("/tmp/x/.shturman-provisioned")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user