Skip to content

Commit d85b7a3

Browse files
committed
Add tests
1 parent 59498d2 commit d85b7a3

File tree

1 file changed

+100
-2
lines changed

1 file changed

+100
-2
lines changed

tests/testsuite/doc.rs

+100-2
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,6 @@ fn doc_workspace_open_first_one_built_for_host() {
13611361
.file("bar/src/lib.rs", "")
13621362
.build();
13631363

1364-
// The order in which bar is compiled or documented is not deterministic
13651364
p.cargo("doc --workspace --open")
13661365
.masquerade_as_nightly_cargo(&["per-package-target"])
13671366
.env("BROWSER", tools::echo())
@@ -1413,7 +1412,6 @@ fn doc_workspace_open_first_one_when_no_one_built_for_host() {
14131412
.file("bar/src/lib.rs", "")
14141413
.build();
14151414

1416-
// The order in which bar is compiled or documented is not deterministic
14171415
p.cargo("doc --workspace --open")
14181416
.masquerade_as_nightly_cargo(&["per-package-target"])
14191417
.env("BROWSER", tools::echo())
@@ -1426,6 +1424,106 @@ fn doc_workspace_open_first_one_when_no_one_built_for_host() {
14261424
.run();
14271425
}
14281426

1427+
#[cargo_test(nightly, reason = "-Zper-package-target is unstable")]
1428+
fn doc_workspace_open_first_one_built_for_target() {
1429+
const TARGET: &str = "i686-unknown-linux-gnu";
1430+
1431+
let p = project()
1432+
.file(
1433+
"Cargo.toml",
1434+
r#"
1435+
[workspace]
1436+
members = ["foo", "bar"]
1437+
"#,
1438+
)
1439+
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
1440+
.file("foo/src/lib.rs", "")
1441+
.file(
1442+
"bar/Cargo.toml",
1443+
&format!(
1444+
r#"
1445+
cargo-features = ["per-package-target"]
1446+
[package]
1447+
name = "bar"
1448+
version = "0.1.0"
1449+
forced-target = "{}"
1450+
"#,
1451+
TARGET
1452+
),
1453+
)
1454+
.file("bar/src/lib.rs", "")
1455+
.build();
1456+
1457+
p.cargo("doc --workspace --open --target")
1458+
.arg(TARGET)
1459+
.masquerade_as_nightly_cargo(&["per-package-target"])
1460+
.env("BROWSER", tools::echo())
1461+
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
1462+
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")
1463+
.with_stderr_contains(&format!(
1464+
"[..] Opening [..]/target/{}/doc/bar/index.html",
1465+
TARGET
1466+
))
1467+
.run();
1468+
}
1469+
1470+
#[cargo_test(nightly, reason = "-Zper-package-target is unstable")]
1471+
fn doc_workspace_open_first_one_when_no_one_built_for_target() {
1472+
const TARGET: &str = "i686-unknown-linux-gnu";
1473+
1474+
let p = project()
1475+
.file(
1476+
"Cargo.toml",
1477+
r#"
1478+
[workspace]
1479+
members = ["foo", "bar"]
1480+
"#,
1481+
)
1482+
.file(
1483+
"foo/Cargo.toml",
1484+
&format!(
1485+
r#"
1486+
cargo-features = ["per-package-target"]
1487+
[package]
1488+
name = "foo"
1489+
version = "0.1.0"
1490+
forced-target = "{}"
1491+
"#,
1492+
TARGET
1493+
),
1494+
)
1495+
.file("foo/src/lib.rs", "")
1496+
.file(
1497+
"bar/Cargo.toml",
1498+
&format!(
1499+
r#"
1500+
cargo-features = ["per-package-target"]
1501+
[package]
1502+
name = "bar"
1503+
version = "0.1.0"
1504+
forced-target = "{}"
1505+
"#,
1506+
TARGET
1507+
),
1508+
)
1509+
.file("bar/src/lib.rs", "")
1510+
.build();
1511+
1512+
// We don't build for host, so we should open the first one built for TARGET.
1513+
let host_target = rustc_host();
1514+
p.cargo("doc --workspace --open --target")
1515+
.arg(host_target)
1516+
.masquerade_as_nightly_cargo(&["per-package-target"])
1517+
.env("BROWSER", tools::echo())
1518+
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
1519+
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")
1520+
.with_stderr_contains(&format!(
1521+
"[..] Opening [..]/target/{}/doc/bar/index.html",
1522+
TARGET
1523+
))
1524+
.run();
1525+
}
1526+
14291527
#[cargo_test(nightly, reason = "-Zextern-html-root-url is unstable")]
14301528
fn doc_extern_map_local() {
14311529
let p = project()

0 commit comments

Comments
 (0)