Merge branch 't3/fix-ci-macos-windows-lint'
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
2cd67da1b1
4 files changed
+90
-27
No files matched your search
@@ -487,7 +487,15 @@ fn closing_and_opening_a_book_over_and_over_loses_and_duplicates_nothing() {
|
|||||||
for cycle in 0..CYCLES {
|
for cycle in 0..CYCLES {
|
||||||
std::thread::sleep(Duration::from_millis(150 + (cycle as u64 * 37) % 100));
|
std::thread::sleep(Duration::from_millis(150 + (cycle as u64 * 37) % 100));
|
||||||
let beta_before = done.lock().unwrap().iter().filter(|d| d.book == B).count();
|
let beta_before = done.lock().unwrap().iter().filter(|d| d.book == B).count();
|
||||||
assert_eq!(close_book(&home, A), CloseOutcome::Closed, "cycle {cycle}");
|
let began = std::time::Instant::now();
|
||||||
|
let closed = close_book(&home, A);
|
||||||
|
let took = began.elapsed();
|
||||||
|
eprintln!("cycle {cycle}: the close took {took:?}");
|
||||||
|
assert_eq!(
|
||||||
|
closed,
|
||||||
|
CloseOutcome::Closed,
|
||||||
|
"cycle {cycle}, after {took:?}"
|
||||||
|
);
|
||||||
// Answered closed: from here nothing runs on the book until it is
|
// Answered closed: from here nothing runs on the book until it is
|
||||||
// opened, so its files stand still (and, the writer lock being
|
// opened, so its files stand still (and, the writer lock being
|
||||||
// released, another program could open it).
|
// released, another program could open it).
|
||||||
@@ -823,9 +831,7 @@ mod raw {
|
|||||||
let mut extra = extra.to_vec();
|
let mut extra = extra.to_vec();
|
||||||
extra.push(("expect", "100-continue"));
|
extra.push(("expect", "100-continue"));
|
||||||
self.start(method, path, &extra, body, 0);
|
self.start(method, path, &extra, body, 0);
|
||||||
self.stream
|
self.bound_reads(Duration::from_secs(120));
|
||||||
.set_read_timeout(Some(Duration::from_secs(120)))
|
|
||||||
.unwrap();
|
|
||||||
let mut seen = Vec::new();
|
let mut seen = Vec::new();
|
||||||
let mut byte = [0u8; 1];
|
let mut byte = [0u8; 1];
|
||||||
while !seen.ends_with(b"\r\n\r\n") {
|
while !seen.ends_with(b"\r\n\r\n") {
|
||||||
@@ -871,10 +877,24 @@ mod raw {
|
|||||||
self.stream.write_all(piece).is_ok()
|
self.stream.write_all(piece).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bound how long a read of this connection may wait. macOS refuses
|
||||||
|
/// (EINVAL) to set an option on a socket whose peer has already
|
||||||
|
/// closed it, which is what the server's cutting a connection is:
|
||||||
|
/// such a socket can't block a read (it gives what was sent, then
|
||||||
|
/// the end), so that refusal, and only that, is passed over.
|
||||||
|
fn bound_reads(&self, within: Duration) {
|
||||||
|
assert!(!within.is_zero(), "a read bound of no time");
|
||||||
|
match self.stream.set_read_timeout(Some(within)) {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {}
|
||||||
|
Err(e) => panic!("no bound on a read of the connection: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Everything the server sends until it closes the connection,
|
/// Everything the server sends until it closes the connection,
|
||||||
/// which it must do within `within`.
|
/// which it must do within `within`.
|
||||||
pub fn until_closed(&mut self, within: Duration) -> String {
|
pub fn until_closed(&mut self, within: Duration) -> String {
|
||||||
self.stream.set_read_timeout(Some(within)).unwrap();
|
self.bound_reads(within);
|
||||||
let mut seen = std::mem::take(&mut self.taken);
|
let mut seen = std::mem::take(&mut self.taken);
|
||||||
let mut buf = [0u8; 4096];
|
let mut buf = [0u8; 4096];
|
||||||
loop {
|
loop {
|
||||||
@@ -884,7 +904,9 @@ mod raw {
|
|||||||
Err(e)
|
Err(e)
|
||||||
if matches!(
|
if matches!(
|
||||||
e.kind(),
|
e.kind(),
|
||||||
std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::BrokenPipe
|
std::io::ErrorKind::ConnectionReset
|
||||||
|
| std::io::ErrorKind::BrokenPipe
|
||||||
|
| std::io::ErrorKind::NotConnected
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -934,9 +956,7 @@ mod raw {
|
|||||||
|
|
||||||
/// The response's status line and headers (the body is left).
|
/// The response's status line and headers (the body is left).
|
||||||
pub fn head(&mut self) -> (u16, String) {
|
pub fn head(&mut self) -> (u16, String) {
|
||||||
self.stream
|
self.bound_reads(Duration::from_secs(60));
|
||||||
.set_read_timeout(Some(Duration::from_secs(60)))
|
|
||||||
.unwrap();
|
|
||||||
let mut seen = std::mem::take(&mut self.taken);
|
let mut seen = std::mem::take(&mut self.taken);
|
||||||
let mut byte = [0u8; 1];
|
let mut byte = [0u8; 1];
|
||||||
while !seen.ends_with(b"\r\n\r\n") {
|
while !seen.ends_with(b"\r\n\r\n") {
|
||||||
@@ -2270,11 +2290,16 @@ fn a_late_timer_does_nothing(name: &str, held_timers: &str) {
|
|||||||
std::fs::create_dir_all(&disk).unwrap();
|
std::fs::create_dir_all(&disk).unwrap();
|
||||||
set_backup_folder(&mut w, &disk);
|
set_backup_folder(&mut w, &disk);
|
||||||
w.end();
|
w.end();
|
||||||
wait_for(
|
// (Not `wait_for`: a failure says which of the timers never held.)
|
||||||
"the timers hold their handles",
|
let by = std::time::Instant::now() + Duration::from_secs(60);
|
||||||
Duration::from_secs(60),
|
while !all_held() {
|
||||||
all_held,
|
assert!(
|
||||||
);
|
std::time::Instant::now() < by,
|
||||||
|
"never: the timers hold their handles; wanted `{held_timers}`, held so far {:?}",
|
||||||
|
seen().lines().collect::<Vec<_>>()
|
||||||
|
);
|
||||||
|
std::thread::sleep(Duration::from_millis(10));
|
||||||
|
}
|
||||||
let dir = home.book_dir(A);
|
let dir = home.book_dir(A);
|
||||||
assert!(matches!(close_book(&home, A), CloseOutcome::Closed));
|
assert!(matches!(close_book(&home, A), CloseOutcome::Closed));
|
||||||
for folder in ["uploads", "exports"] {
|
for folder in ["uploads", "exports"] {
|
||||||
@@ -2412,7 +2437,11 @@ fn a_close_stops_a_slow_drill_instead_of_waiting_for_it() {
|
|||||||
/// where a `reference-transaction` hook waits, while `slow-commit` (for the
|
/// where a `reference-transaction` hook waits, while `slow-commit` (for the
|
||||||
/// book's archive) or `slow-push` (for any other repository) exists in the
|
/// book's archive) or `slow-push` (for any other repository) exists in the
|
||||||
/// shim folder, at the point where git holds its ref locks. `hooked` has a
|
/// shim folder, at the point where git holds its ref locks. `hooked` has a
|
||||||
/// line per hook that waited. A real git, killed inside real work.
|
/// line per hook that waited. A real git, killed inside real work. While
|
||||||
|
/// `deaf` exists in the shim folder when a git begins, that git (and all it
|
||||||
|
/// starts) has SIGTERM blocked, a mask every child inherits: the signal stays
|
||||||
|
/// pending and only the kill ends it (a stopped process is not enough:
|
||||||
|
/// macOS acts on a SIGTERM sent to one, where Linux holds it).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn slow_real_git(home: &Home) -> PathBuf {
|
fn slow_real_git(home: &Home) -> PathBuf {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
@@ -2434,8 +2463,9 @@ fn slow_real_git(home: &Home) -> PathBuf {
|
|||||||
std::fs::write(
|
std::fs::write(
|
||||||
&exe,
|
&exe,
|
||||||
format!(
|
format!(
|
||||||
"#!/bin/sh\nn=$#\nwhile [ $n -gt 0 ]; do\n a=\"$1\"; shift\n case \"$a\" in\n *core.hooksPath=/dev/null*) a=$(printf '%s' \"$a\" | sed 's|core.hooksPath=/dev/null|core.hooksPath={}|g') ;;\n esac\n set -- \"$@\" \"$a\"\n n=$((n-1))\ndone\nexec {real} \"$@\"\n",
|
"#!/bin/sh\nn=$#\nwhile [ $n -gt 0 ]; do\n a=\"$1\"; shift\n case \"$a\" in\n *core.hooksPath=/dev/null*) a=$(printf '%s' \"$a\" | sed 's|core.hooksPath=/dev/null|core.hooksPath={}|g') ;;\n esac\n set -- \"$@\" \"$a\"\n n=$((n-1))\ndone\nif [ -e '{dir}/deaf' ]; then exec perl -MPOSIX -e 'sigprocmask(SIG_BLOCK, POSIX::SigSet->new(SIGTERM)) or die; exec @ARGV or die' {real} \"$@\"; fi\nexec {real} \"$@\"\n",
|
||||||
hooks.display()
|
hooks.display(),
|
||||||
|
dir = dir.display(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -2641,10 +2671,10 @@ fn call_unanswered(home: &Home, w: &Wire, id: u64, tool: &str, args: Value) -> r
|
|||||||
raw
|
raw
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hold every process of the group `pid` leads still (SIGSTOP): a SIGTERM
|
/// Hold every process of the group `pid` leads still (SIGSTOP), so that none
|
||||||
/// sent to it then stays pending, git can't end on it, and only the kill
|
/// goes on while the stop is being asked for. That git can't end on SIGTERM,
|
||||||
/// after the grace ends it (how a git that can't end on SIGTERM, holding
|
/// holding its locks, is made on purpose by the shim's `deaf` file, not by
|
||||||
/// its locks, is made on purpose).
|
/// this: macOS acts on a SIGTERM sent to a stopped process.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn freeze_group_of(pid: u32) {
|
fn freeze_group_of(pid: u32) {
|
||||||
let out = std::process::Command::new("ps")
|
let out = std::process::Command::new("ps")
|
||||||
@@ -3558,6 +3588,7 @@ fn a_lock_a_kill_leaves_in_the_backup_folder_is_reported_and_never_removed_by_th
|
|||||||
// named.
|
// named.
|
||||||
let another = target.join("refs").join("heads").join("another.lock");
|
let another = target.join("refs").join("heads").join("another.lock");
|
||||||
std::fs::write(&another, b"").unwrap();
|
std::fs::write(&another, b"").unwrap();
|
||||||
|
std::fs::write(shim.join("deaf"), b"").unwrap();
|
||||||
std::fs::write(shim.join("slow-push"), b"").unwrap();
|
std::fs::write(shim.join("slow-push"), b"").unwrap();
|
||||||
let closing = std::thread::spawn({
|
let closing = std::thread::spawn({
|
||||||
let admin = home.run().join("admin.sock");
|
let admin = home.run().join("admin.sock");
|
||||||
|
|||||||
@@ -5418,8 +5418,14 @@ mod tests {
|
|||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
walk(base, &path, out);
|
walk(base, &path, out);
|
||||||
} else if let Ok(bytes) = std::fs::read(&path) {
|
} else if let Ok(bytes) = std::fs::read(&path) {
|
||||||
|
// Keyed with `/` between parts on every system (the
|
||||||
|
// test names files so), not the system's separator.
|
||||||
out.insert(
|
out.insert(
|
||||||
path.strip_prefix(base).unwrap().display().to_string(),
|
path.strip_prefix(base)
|
||||||
|
.unwrap()
|
||||||
|
.display()
|
||||||
|
.to_string()
|
||||||
|
.replace('\\', "/"),
|
||||||
bytes,
|
bytes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2561,6 +2561,10 @@ mod tests {
|
|||||||
/// `hooks/slow` exists, at the point where git holds its ref locks (and
|
/// `hooks/slow` exists, at the point where git holds its ref locks (and
|
||||||
/// a commit its index lock): how a real git is made slow enough to be
|
/// a commit its index lock): how a real git is made slow enough to be
|
||||||
/// killed inside the work. `hooks/hooked` has a line per hook that waited.
|
/// killed inside the work. `hooks/hooked` has a line per hook that waited.
|
||||||
|
/// While `hooks/deaf` exists when a git begins, that git (and all it
|
||||||
|
/// starts) has SIGTERM blocked, as a mask every child inherits: the
|
||||||
|
/// signal stays pending, git's handler never runs, and only the kill
|
||||||
|
/// ends it ([`deaf`]).
|
||||||
fn slow_git(dir: &Path, real: &Git) -> (Git, PathBuf) {
|
fn slow_git(dir: &Path, real: &Git) -> (Git, PathBuf) {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
let hooks = dir.join("slow-hooks");
|
let hooks = dir.join("slow-hooks");
|
||||||
@@ -2585,8 +2589,10 @@ mod tests {
|
|||||||
std::fs::write(
|
std::fs::write(
|
||||||
&wrapper,
|
&wrapper,
|
||||||
format!(
|
format!(
|
||||||
"#!/bin/sh\nn=$#\nwhile [ $n -gt 0 ]; do\n a=\"$1\"; shift\n case \"$a\" in\n *core.hooksPath=/dev/null*) a=$(printf '%s' \"$a\" | sed 's|core.hooksPath=/dev/null|core.hooksPath={}|g') ;;\n esac\n set -- \"$@\" \"$a\"\n n=$((n-1))\ndone\nexec '{}' \"$@\"\n",
|
"#!/bin/sh\nn=$#\nwhile [ $n -gt 0 ]; do\n a=\"$1\"; shift\n case \"$a\" in\n *core.hooksPath=/dev/null*) a=$(printf '%s' \"$a\" | sed 's|core.hooksPath=/dev/null|core.hooksPath={}|g') ;;\n esac\n set -- \"$@\" \"$a\"\n n=$((n-1))\ndone\nif [ -e '{}/deaf' ]; then exec perl -MPOSIX -e 'sigprocmask(SIG_BLOCK, POSIX::SigSet->new(SIGTERM)) or die; exec @ARGV or die' '{}' \"$@\"; fi\nexec '{}' \"$@\"\n",
|
||||||
hooks.display(),
|
hooks.display(),
|
||||||
|
hooks.display(),
|
||||||
|
real.exe.display(),
|
||||||
real.exe.display()
|
real.exe.display()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -2635,10 +2641,19 @@ mod tests {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hold every process of the group `pid` leads still (SIGSTOP): a
|
/// Make the gits `slow_git` starts from now on unable to end on
|
||||||
/// SIGTERM sent to it then stays pending, git can't run its handler,
|
/// SIGTERM (a blocked signal stays pending on every system). A stopped
|
||||||
/// and only the kill after the grace ends it. This is how a git that
|
/// process is not enough: macOS acts on a SIGTERM sent to a process
|
||||||
/// can't end on SIGTERM, with the locks it holds, is made on purpose.
|
/// that was stopped (the git ended inside its grace, and removed its
|
||||||
|
/// own locks), where Linux holds the signal until it is continued.
|
||||||
|
fn deaf(hooks: &Path) {
|
||||||
|
std::fs::write(hooks.join("deaf"), b"").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hold every process of the group `pid` leads still (SIGSTOP), so that
|
||||||
|
/// none goes on while the stop is being asked for. A git that can't end
|
||||||
|
/// on SIGTERM, with the locks it holds, is made on purpose by [`deaf`];
|
||||||
|
/// this only keeps it from finishing meanwhile.
|
||||||
fn freeze_group_of(pid: u32) {
|
fn freeze_group_of(pid: u32) {
|
||||||
let out = std::process::Command::new("ps")
|
let out = std::process::Command::new("ps")
|
||||||
.args(["-o", "pgid=", "-p", &pid.to_string()])
|
.args(["-o", "pgid=", "-p", &pid.to_string()])
|
||||||
@@ -2738,6 +2753,7 @@ mod tests {
|
|||||||
s.add_account("6000", "Supplies", AccountType::Expense, None, false)
|
s.add_account("6000", "Supplies", AccountType::Expense, None, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let archive = b.join(ARCHIVE_DIR);
|
let archive = b.join(ARCHIVE_DIR);
|
||||||
|
deaf(&hooks);
|
||||||
std::fs::write(hooks.join("slow"), b"").unwrap();
|
std::fs::write(hooks.join("slow"), b"").unwrap();
|
||||||
let running = {
|
let running = {
|
||||||
let (git, b, head) = (cancelled.clone(), b.clone(), s.head());
|
let (git, b, head) = (cancelled.clone(), b.clone(), s.head());
|
||||||
@@ -2917,6 +2933,7 @@ mod tests {
|
|||||||
.clone()
|
.clone()
|
||||||
.with_cancel(flag.clone())
|
.with_cancel(flag.clone())
|
||||||
.with_term_grace(grace);
|
.with_term_grace(grace);
|
||||||
|
deaf(&hooks);
|
||||||
std::fs::write(hooks.join("slow"), b"").unwrap();
|
std::fs::write(hooks.join("slow"), b"").unwrap();
|
||||||
let running = {
|
let running = {
|
||||||
let (git, b, target) = (cancelled.clone(), b.clone(), target.clone());
|
let (git, b, target) = (cancelled.clone(), b.clone(), target.clone());
|
||||||
@@ -3015,6 +3032,9 @@ mod tests {
|
|||||||
.clone()
|
.clone()
|
||||||
.with_cancel(flag.clone())
|
.with_cancel(flag.clone())
|
||||||
.with_term_grace(Duration::from_millis(if frozen { 400 } else { 120_000 }));
|
.with_term_grace(Duration::from_millis(if frozen { 400 } else { 120_000 }));
|
||||||
|
if frozen {
|
||||||
|
deaf(&hooks);
|
||||||
|
}
|
||||||
std::fs::write(hooks.join("slow-pack"), b"").unwrap();
|
std::fs::write(hooks.join("slow-pack"), b"").unwrap();
|
||||||
let running = {
|
let running = {
|
||||||
let (git, b, target) = (cancelled.clone(), b.clone(), target.clone());
|
let (git, b, target) = (cancelled.clone(), b.clone(), target.clone());
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ ignore = [
|
|||||||
# Since 2026-11-09.
|
# Since 2026-11-09.
|
||||||
{ id = "RUSTSEC-2026-0194", reason = "typst's citationberg only; no outside XML reaches it" },
|
{ id = "RUSTSEC-2026-0194", reason = "typst's citationberg only; no outside XML reaches it" },
|
||||||
{ id = "RUSTSEC-2026-0195", reason = "typst's citationberg only; no outside XML reaches it" },
|
{ id = "RUSTSEC-2026-0195", reason = "typst's citationberg only; no outside XML reaches it" },
|
||||||
|
# chrono 0.4.45, RUSTSEC-2026-0543: an "unmaintained" notice, not a
|
||||||
|
# vulnerability, and the advisory offers no upgrade. chrono is a
|
||||||
|
# declared dependency of ledger-core, so the "workspace" rule above
|
||||||
|
# catches it. Replacing chrono with jiff (already a dependency) is a
|
||||||
|
# follow-up for the owner to decide. Since 2026-11-21.
|
||||||
|
{ id = "RUSTSEC-2026-0543", reason = "unmaintained notice only, not a vulnerability; no upgrade offered; chrono to jiff is the owner's call" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[licenses]
|
[licenses]
|
||||||
|
|||||||
Reference in new issue
Block a user