Skip to content

Commit 2a755cd

Browse files
DRMacIverclaude
andcommitted
Fix CI: StopTest detection, mark_complete race, formatting, and nix
- Include error type in protocol error messages so StopTest is detected instead of calling process::exit(134) - Change mark_complete to request-response to prevent race condition when closing channels - Remove unused send_request_json method - Update Cargo.lock files to include ciborium and crc32fast - Point flake.nix hegel input to DRMacIver/new-protocol branch - Fix clippy warnings (div_ceil, io_other_error, manual_range_contains) - Run cargo fmt and rustfmt on all source files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 69bd000 commit 2a755cd

File tree

8 files changed

+168
-45
lines changed

8 files changed

+168
-45
lines changed

Cargo.lock

Lines changed: 67 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
inputs = {
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6-
hegel.url = "git+ssh://git@github.com/antithesishq/hegel";
6+
hegel.url = "git+ssh://git@github.com/antithesishq/hegel?ref=DRMacIver/new-protocol";
77
};
88

99
outputs =

src/embedded.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,7 @@ where
438438
.unwrap_or(0);
439439

440440
if verbosity == Verbosity::Debug {
441-
eprintln!(
442-
"Test done. interesting_test_cases={}",
443-
n_interesting
444-
);
441+
eprintln!("Test done. interesting_test_cases={}", n_interesting);
445442
}
446443

447444
// Process final replay test cases (one per interesting example)
@@ -526,8 +523,8 @@ fn run_test_case<F: FnMut()>(
526523
got_interesting.store(true, Ordering::SeqCst);
527524

528525
// Take panic info - we need location for origin, and print details on final
529-
let (thread_name, thread_id, location, backtrace) =
530-
take_panic_info().unwrap_or_else(|| {
526+
let (thread_name, thread_id, location, backtrace) = take_panic_info()
527+
.unwrap_or_else(|| {
531528
(
532529
"<unknown>".to_string(),
533530
"?".to_string(),
@@ -578,8 +575,8 @@ fn run_test_case<F: FnMut()>(
578575
"status": status,
579576
"origin": origin,
580577
});
581-
// Fire-and-forget: server does not send a response to mark_complete
582-
let _ = state.channel.send_request_json(&mark_complete);
578+
// Wait for server to acknowledge mark_complete before closing
579+
let _ = state.channel.request_json(&mark_complete);
583580
// Close the test case channel
584581
let _ = state.channel.close();
585582
}

src/gen/binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const BASE64_ALPHABET: &[u8; 64] =
77

88
#[cfg(test)]
99
fn base64_encode(input: &[u8]) -> String {
10-
let mut result = String::with_capacity((input.len() + 2) / 3 * 4);
10+
let mut result = String::with_capacity(input.len().div_ceil(3) * 4);
1111

1212
for chunk in input.chunks(3) {
1313
// 3 bytes (3x8=24 bits) -> 4 base64 chars (4x6=24 bits)

src/protocol.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,13 @@ impl Channel {
244244
Ok(())
245245
}
246246

247-
/// Send a JSON request without waiting for a response (fire-and-forget).
248-
/// Returns the message ID of the sent request.
249-
pub fn send_request_json(&self, message: &serde_json::Value) -> std::io::Result<u32> {
250-
let mut payload = Vec::new();
251-
ciborium::into_writer(message, &mut payload)
252-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
253-
self.send_request(payload)
254-
}
255-
256247
/// Close this channel by sending a close packet to the remote side.
257248
pub fn close(&self) -> std::io::Result<()> {
258-
let packet = Packet::request(self.channel_id, CLOSE_CHANNEL_MESSAGE_ID, CLOSE_CHANNEL_PAYLOAD.to_vec());
249+
let packet = Packet::request(
250+
self.channel_id,
251+
CLOSE_CHANNEL_MESSAGE_ID,
252+
CLOSE_CHANNEL_PAYLOAD.to_vec(),
253+
);
259254
self.connection.send_packet(&packet)
260255
}
261256

@@ -276,10 +271,11 @@ impl Channel {
276271

277272
// Check for error response
278273
if let Some(error) = response.get("error") {
279-
return Err(std::io::Error::new(
280-
std::io::ErrorKind::Other,
281-
format!("Server error: {}", error),
282-
));
274+
let error_type = response.get("type").and_then(|t| t.as_str()).unwrap_or("");
275+
return Err(std::io::Error::other(format!(
276+
"Server error ({}): {}",
277+
error_type, error
278+
)));
283279
}
284280

285281
// Extract result field if present

tests/nix/Cargo.lock

Lines changed: 77 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/nix/tests/integration.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ use hegel::gen::{self, Generate};
22
use nix_test::Rectangle;
33

44
fn rectangles() -> impl Generate<Rectangle> {
5-
gen::tuples(gen::integers::<u32>(), gen::integers::<u32>())
6-
.map(|(w, h)| Rectangle::new(w, h))
5+
gen::tuples(gen::integers::<u32>(), gen::integers::<u32>()).map(|(w, h)| Rectangle::new(w, h))
76
}
87

98
#[test]
10-
fn test_nix_integration_canary() {
11-
12-
}
9+
fn test_nix_integration_canary() {}
1310

1411
#[test]
1512
fn test_area_is_product_of_sides() {
@@ -23,7 +20,10 @@ fn test_area_is_product_of_sides() {
2320
fn test_perimeter_is_twice_sum_of_sides() {
2421
hegel::hegel(|| {
2522
let rect = rectangles().generate();
26-
assert_eq!(rect.perimeter(), 2 * (rect.width as u64 + rect.height as u64));
23+
assert_eq!(
24+
rect.perimeter(),
25+
2 * (rect.width as u64 + rect.height as u64)
26+
);
2727
});
2828
}
2929

tests/test_combinators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_optional_respects_inner_generator_bounds() {
4646
let value: Option<i32> =
4747
gen::optional(gen::integers().with_min(10).with_max(20)).generate();
4848
if let Some(n) = value {
49-
assert!(n >= 10 && n <= 20);
49+
assert!((10..=20).contains(&n));
5050
}
5151
});
5252
}

0 commit comments

Comments
 (0)