Skip to content

Commit 2492bf5

Browse files
committed
Fix package_default_run.
The output was checking the `targets`, whose order depends on the filesystem order. Instead of checking all the output, just check the one field this test is for.
1 parent 393077f commit 2492bf5

File tree

1 file changed

+3
-100
lines changed

1 file changed

+3
-100
lines changed

tests/testsuite/metadata.rs

Lines changed: 3 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use cargo_test_support::install::cargo_home;
44
use cargo_test_support::paths::CargoPathExt;
55
use cargo_test_support::registry::Package;
66
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, main_file, project, rustc_host};
7+
use serde_json::json;
78

89
#[cargo_test]
910
fn cargo_metadata_simple() {
@@ -1550,106 +1551,8 @@ fn package_default_run() {
15501551
"#,
15511552
)
15521553
.build();
1553-
p.cargo("metadata")
1554-
.with_json(
1555-
r#"
1556-
{
1557-
"packages": [
1558-
{
1559-
"authors": [
1560-
1561-
],
1562-
"categories": [],
1563-
"default_run": "a",
1564-
"dependencies": [],
1565-
"description": null,
1566-
"edition": "2018",
1567-
"features": {},
1568-
"id": "foo 0.1.0 (path+file:[..])",
1569-
"keywords": [],
1570-
"license": null,
1571-
"license_file": null,
1572-
"links": null,
1573-
"manifest_path": "[..]Cargo.toml",
1574-
"metadata": null,
1575-
"publish": null,
1576-
"name": "foo",
1577-
"readme": null,
1578-
"repository": null,
1579-
"homepage": null,
1580-
"documentation": null,
1581-
"source": null,
1582-
"targets": [
1583-
{
1584-
"crate_types": [
1585-
"lib"
1586-
],
1587-
"doc": true,
1588-
"doctest": true,
1589-
"test": true,
1590-
"edition": "2018",
1591-
"kind": [
1592-
"lib"
1593-
],
1594-
"name": "foo",
1595-
"src_path": "[..]src/lib.rs"
1596-
},
1597-
{
1598-
"crate_types": [
1599-
"bin"
1600-
],
1601-
"doc": true,
1602-
"doctest": false,
1603-
"test": true,
1604-
"edition": "2018",
1605-
"kind": [
1606-
"bin"
1607-
],
1608-
"name": "a",
1609-
"src_path": "[..]src/bin/a.rs",
1610-
"test": true
1611-
},
1612-
{
1613-
"crate_types": [
1614-
"bin"
1615-
],
1616-
"doc": true,
1617-
"doctest": false,
1618-
"test": true,
1619-
"edition": "2018",
1620-
"kind": [
1621-
"bin"
1622-
],
1623-
"name": "b",
1624-
"src_path": "[..]src/bin/b.rs",
1625-
"test": true
1626-
}
1627-
],
1628-
"version": "0.1.0"
1629-
}
1630-
],
1631-
"resolve": {
1632-
"nodes": [
1633-
{
1634-
"dependencies": [],
1635-
"deps": [],
1636-
"features": [],
1637-
"id": "foo 0.1.0 (path+file:[..])"
1638-
}
1639-
],
1640-
"root": "foo 0.1.0 (path+file:[..])"
1641-
},
1642-
"target_directory": "[..]",
1643-
"version": 1,
1644-
"workspace_members": [
1645-
"foo 0.1.0 (path+file:[..])"
1646-
],
1647-
"workspace_root": "[..]",
1648-
"metadata": null
1649-
}
1650-
"#,
1651-
)
1652-
.run();
1554+
let json = p.cargo("metadata").run_json();
1555+
assert_eq!(json["packages"][0]["default_run"], json!("a"));
16531556
}
16541557

16551558
#[cargo_test]

0 commit comments

Comments
 (0)