Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,12 @@ mod remote_tests {
// As the real client: a relay that fails at once may close the pipe before Hello.
let _ = hello().write_to(&mut stdin);
let mut screen = Vec::new();
let seen = pump(Vec::new(), stdout, &mut screen, false, |_| {});
// The `lost` fake cuts the link only once the client has the marker.
let seen = pump(Vec::new(), stdout, &mut screen, false, |r| {
if r.armed {
let _ = std::fs::write(self.dir.join("armed"), "");
}
});
drop(stdin);
let (exit, said) = finish(child, stderr);
(seen, screen, exit, said)
Expand Down Expand Up @@ -2273,8 +2278,14 @@ mod remote_tests {
#[test]
fn a_link_that_dies_after_the_arming_is_a_loss() {
let fake = Fake::new("lost", "lost");
let server = fake.serve(|s| {
let armed = fake.dir.join("armed");
let server = fake.serve(move |s| {
s.write_all(ARMED).unwrap();
// Open until the client has the marker, however slow the machine, then long enough for the fake ssh to cut the link.
let t = std::time::Instant::now();
while !armed.exists() && t.elapsed() < Duration::from_secs(60) {
std::thread::sleep(Duration::from_millis(20));
}
std::thread::sleep(Duration::from_secs(3));
});
let (seen, _, exit, said) = fake.run("1");
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/fake-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ case $last in
unset NERD_SOCKET NERD_INSTANCE
export NERD_STATE_DIR="$dir/state" HOME="$dir"
if [ "$mode" = lost ]; then
# The link drops a second in: the relay dies with no word, ssh exits 255.
# The link drops once the client has the armed marker: the relay dies with no word, ssh exits 255.
"$dir/nerd" --relay "$id" <&0 &
pid=$!
sleep 1
kill -9 $pid
while [ ! -e "$dir/armed" ] && kill -0 $pid 2>/dev/null; do sleep 0.05; done
kill -9 $pid 2>/dev/null
: > "$dir/ended"
exit 255
fi
Expand Down
Loading