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
43 changes: 43 additions & 0 deletions crates/socket-patch-cli/tests/e2e_redirect_cargo_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,13 @@ async fn cargo_hosted_explicit_crates_io_registry_is_pinned() {
consumer_manifest("cfg-if = { version = \"1.0.4\", registry = \"crates-io\" }\n"),
consumer_manifest("cfg-if = \"1.0.4\"\n"),
),
(
"crates-io-wrapped",
consumer_manifest(
"cfg-if = { version = \"1.0.4\", features = [\n], registry = \"crates-io\" }\n",
),
consumer_manifest("cfg-if = { version = \"1.0.4\", features = [\n] }\n"),
),
(
"crates-io-table",
format!(
Expand Down Expand Up @@ -1109,6 +1116,42 @@ async fn cargo_hosted_explicit_crates_io_registry_is_pinned() {
}
}

/// #757: an inline table whose array value wraps lines (rustfmt's style for
/// a long feature list) was refused as "inline table does not close on its
/// line". It is pinned on its opening line, builds against the patched
/// copy, and `remove` restores every byte, for LF and CRLF manifests.
#[tokio::test(flavor = "multi_thread")]
async fn cargo_hosted_multiline_inline_table_is_pinned() {
for (tag, crlf) in [("multiline-inline", false), ("multiline-inline-crlf", true)] {
let shape = Shape {
tag,
files: vec![
(
"Cargo.toml",
consumer_manifest(
"cfg-if = { version = \"1.0.4\", features = [ # none needed\n] }\n",
),
),
("src/main.rs", "fn main() {}\n".to_string()),
],
patches: vec![CFG_IF_1],
oracle: vec![(
"src/main.rs",
"fn main() { println!(\"{}\", cfg_if::socket_patched()); }\n".to_string(),
)],
crlf,
lockless: false,
refused: None,
prefetch: "",
contest: None,
restored: vec![],
};
if run_shape(shape).await.is_none() {
return;
}
}
}

/// Bug H: a config ending in a blank line comes back byte-for-byte (the
/// appended block's removal once normalized the trailing newline run). A
/// config without a final newline comes back with every byte but that
Expand Down
8 changes: 2 additions & 6 deletions crates/socket-patch-cli/tests/mode_migration_cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,12 +1343,8 @@ async fn takeover_over_unrewritable_spelling_keeps_vendored() {
for (tag, spelling) in [
("dotted", format!("{DEP}.version = \"1.0\"\n")),
("literal", format!("{DEP} = '1.0'\n")),
// An inline table spread over lines (#757). `registry = "crates-io"`
// was this case until #386 made hosted mode pin it.
(
"multi-line-inline",
format!("{DEP} = {{ version = \"1.0\", features = [\n] }}\n"),
),
// `registry = "crates-io"` (#386) and an inline table whose array
// wraps lines (#757) were cases here until hosted mode pinned them.
] {
let tmp = tempfile::tempdir().unwrap();
let Some((proj, cargo_home, version, crate_dir)) = stage_fixture(tmp.path()) else {
Expand Down
Loading
Loading