Skip to content

Commit c049dfd

Browse files
mikolalysenkoclaude
andcommitted
Normalize CRLF in the contract tests; count every rollback leg in bun.lockb e2e
- json_envelope's contract tests read CLI_CONTRACT.md through one LF-normalized copy, so a Windows checkout (CRLF) no longer misses the ```jsonc fence (review thread on #1273; full-scope test windows). - e2e_bun_lockb's shared-bundled case also has an agent copy that fails (hash_mismatch on a bundled copy the patch never touched); with #1066's all-leg counter, `failed` is the hosted refusal plus those agent failures. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 91bf3ea commit c049dfd

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎crates/socket-patch-cli/src/json_envelope.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,15 @@ mod tests {
13791379
}
13801380

13811381
/// The ```jsonc block under `heading` in CLI_CONTRACT.md.
1382+
/// CLI_CONTRACT.md with LF line endings: a Windows checkout may carry
1383+
/// CRLF, which the `"```jsonc\n"` fence match below would miss.
1384+
fn contract_doc() -> &'static str {
1385+
static DOC: std::sync::OnceLock<String> = std::sync::OnceLock::new();
1386+
DOC.get_or_init(|| include_str!("../CLI_CONTRACT.md").replace("\r\n", "\n"))
1387+
}
1388+
13821389
fn contract_block(heading: &str) -> &'static str {
1383-
let doc = include_str!("../CLI_CONTRACT.md");
1390+
let doc = contract_doc();
13841391
let at = doc
13851392
.find(heading)
13861393
.unwrap_or_else(|| panic!("{heading} missing"));
@@ -1457,7 +1464,7 @@ mod tests {
14571464
object_keys(value["files"][0].clone()),
14581465
"files[] keys"
14591466
);
1460-
let doc = include_str!("../CLI_CONTRACT.md");
1467+
let doc = contract_doc();
14611468
for action in [
14621469
PatchAction::Discovered,
14631470
PatchAction::Downloaded,

‎crates/socket-patch-cli/tests/e2e_bun_lockb.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,16 @@ fn rollback_refuses_binary_hosted_pin_then_checkout(
146146
assert_eq!(env["error"]["code"], "rollback_failed", "{env}");
147147
assert_eq!(env["alreadyOriginal"], 0, "{env}");
148148
}
149-
assert_eq!(env["failed"], 1, "{env}");
149+
// `failed` spans every leg (#1066): the refused hosted pin plus any
150+
// agent copy that could not be restored (a bundled copy the patch never
151+
// touched reports `hash_mismatch`).
152+
let agent_failed = env["results"]
153+
.as_array()
154+
.into_iter()
155+
.flatten()
156+
.filter(|r| r["success"] == false)
157+
.count();
158+
assert_eq!(env["failed"], 1 + agent_failed, "{env}");
150159
let failed = env["hosted"]["failed"]
151160
.as_array()
152161
.cloned()

0 commit comments

Comments
 (0)