Skip to content

Commit f08c9b4

Browse files
committed
test(replace): Show behavior post-rust-lang#12614
PR rust-lang#12614 - Changed ignored replaces to not-ignored - Has bugs in matching replaces
1 parent 6fa6fdc commit f08c9b4

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

tests/testsuite/replace.rs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,3 +1298,147 @@ fn override_plus_dep() {
12981298
.with_stderr_contains("error: cyclic package dependency: [..]")
12991299
.run();
13001300
}
1301+
1302+
#[cargo_test]
1303+
fn override_different_metadata() {
1304+
Package::new("bar", "0.1.0+a").publish();
1305+
1306+
let bar = git::repo(&paths::root().join("override"))
1307+
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
1308+
.file("src/lib.rs", "pub fn bar() {}")
1309+
.build();
1310+
1311+
let p = project()
1312+
.file(
1313+
"Cargo.toml",
1314+
&format!(
1315+
r#"
1316+
[package]
1317+
name = "foo"
1318+
version = "0.0.1"
1319+
authors = []
1320+
1321+
[dependencies]
1322+
bar = "0.1.0"
1323+
1324+
[replace]
1325+
"bar:0.1.0" = {{ git = '{}' }}
1326+
"#,
1327+
bar.url()
1328+
),
1329+
)
1330+
.file(
1331+
"src/lib.rs",
1332+
"extern crate bar; pub fn foo() { bar::bar(); }",
1333+
)
1334+
.build();
1335+
1336+
p.cargo("check")
1337+
.with_stderr(
1338+
"\
1339+
[UPDATING] `dummy-registry` index
1340+
[UPDATING] git repository `[..]`
1341+
thread 'main' panicked at src/cargo/core/resolver/dep_cache.rs:179:13:
1342+
assertion `left == right` failed
1343+
left: Version { major: 0, minor: 1, patch: 0 }
1344+
right: Version { major: 0, minor: 1, patch: 0, build: BuildMetadata(\"a\") }
1345+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1346+
",
1347+
)
1348+
.with_status(101)
1349+
.run();
1350+
}
1351+
1352+
#[cargo_test]
1353+
fn override_different_metadata_2() {
1354+
Package::new("bar", "0.1.0+a").publish();
1355+
1356+
let bar = git::repo(&paths::root().join("override"))
1357+
.file("Cargo.toml", &basic_manifest("bar", "0.1.0+a"))
1358+
.file("src/lib.rs", "pub fn bar() {}")
1359+
.build();
1360+
1361+
let p = project()
1362+
.file(
1363+
"Cargo.toml",
1364+
&format!(
1365+
r#"
1366+
[package]
1367+
name = "foo"
1368+
version = "0.0.1"
1369+
authors = []
1370+
1371+
[dependencies]
1372+
bar = "0.1.0"
1373+
1374+
[replace]
1375+
"bar:0.1.0+notTheBuild" = {{ git = '{}' }}
1376+
"#,
1377+
bar.url()
1378+
),
1379+
)
1380+
.file(
1381+
"src/lib.rs",
1382+
"extern crate bar; pub fn foo() { bar::bar(); }",
1383+
)
1384+
.build();
1385+
1386+
p.cargo("check")
1387+
.with_stderr(
1388+
"\
1389+
[UPDATING] `dummy-registry` index
1390+
[UPDATING] git repository `[..]`
1391+
[CHECKING] bar v0.1.0+a (file://[..])
1392+
[CHECKING] foo v0.0.1 ([CWD])
1393+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1394+
",
1395+
)
1396+
.run();
1397+
}
1398+
1399+
#[cargo_test]
1400+
fn override_different_metadata_3() {
1401+
Package::new("bar", "0.1.0+a").publish();
1402+
1403+
let bar = git::repo(&paths::root().join("override"))
1404+
.file("Cargo.toml", &basic_manifest("bar", "0.1.0+a"))
1405+
.file("src/lib.rs", "pub fn bar() {}")
1406+
.build();
1407+
1408+
let p = project()
1409+
.file(
1410+
"Cargo.toml",
1411+
&format!(
1412+
r#"
1413+
[package]
1414+
name = "foo"
1415+
version = "0.0.1"
1416+
authors = []
1417+
1418+
[dependencies]
1419+
bar = "0.1.0"
1420+
1421+
[replace]
1422+
"bar:0.1.0" = {{ git = '{}' }}
1423+
"#,
1424+
bar.url()
1425+
),
1426+
)
1427+
.file(
1428+
"src/lib.rs",
1429+
"extern crate bar; pub fn foo() { bar::bar(); }",
1430+
)
1431+
.build();
1432+
1433+
p.cargo("check")
1434+
.with_stderr(
1435+
"\
1436+
[UPDATING] `dummy-registry` index
1437+
[UPDATING] git repository `[..]`
1438+
[CHECKING] bar v0.1.0+a (file://[..])
1439+
[CHECKING] foo v0.0.1 ([CWD])
1440+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1441+
",
1442+
)
1443+
.run();
1444+
}

0 commit comments

Comments
 (0)