Skip to content
Open
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
55 changes: 55 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 @@ -1152,6 +1152,61 @@ async fn cargo_hosted_multiline_inline_table_is_pinned() {
}
}

/// #757: dotted keys (`cfg-if.version = …`, here with a wrapped features
/// array after the version line) and a literal-string version
/// (`cfg-if = '…'`) were refused as spellings the line grammar does not
/// edit. Each is pinned, builds against the patched copy, and `remove`
/// restores every byte, for LF and CRLF manifests.
#[tokio::test(flavor = "multi_thread")]
async fn cargo_hosted_dotted_and_literal_spellings_are_pinned() {
for (tag, dep, crlf) in [
(
"dotted",
"cfg-if.version = \"1.0.4\" # pinned\ncfg-if.features = [\n]\n",
false,
),
(
"dotted-crlf",
"cfg-if.version = \"1.0.4\" # pinned\ncfg-if.features = [\n]\n",
true,
),
(
"dotted-renamed",
"legacy.package = \"cfg-if\"\nlegacy.version = '1.0.4'\n",
false,
),
("literal", "cfg-if = '1.0.4' # pinned\n", false),
("literal-crlf", "cfg-if = '1.0.4' # pinned\n", true),
] {
let crate_ref = if tag == "dotted-renamed" {
"legacy"
} else {
"cfg_if"
};
let shape = Shape {
tag,
files: vec![
("Cargo.toml", consumer_manifest(dep)),
("src/main.rs", "fn main() {}\n".to_string()),
],
patches: vec![CFG_IF_1],
oracle: vec![(
"src/main.rs",
format!("fn main() {{ println!(\"{{}}\", {crate_ref}::socket_patched()); }}\n"),
)],
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
9 changes: 5 additions & 4 deletions crates/socket-patch-cli/tests/mode_migration_cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,10 +1341,11 @@ fn hosted_pinned(env: &serde_json::Value) -> u64 {
#[tokio::test(flavor = "multi_thread")]
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")),
// `registry = "crates-io"` (#386) and an inline table whose array
// wraps lines (#757) were cases here until hosted mode pinned them.
("multi-line-literal", format!("{DEP} = '''1.0'''\n")),
("multi-line-basic", format!("{DEP} = \"\"\"1.0\"\"\"\n")),
// `registry = "crates-io"` (#386), an inline table whose array
// wraps lines, dotted keys and a literal-string version (#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