From 8c96a28ff7fd32c4cded4b47274bc1fd08629280 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Fri, 14 Apr 2023 21:42:26 -0700 Subject: [PATCH 1/5] Added workspace_default_members. --- src/cargo/ops/cargo_output_metadata.rs | 2 ++ tests/testsuite/metadata.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 9d52fa09ad7..c0a63aa75a2 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -43,6 +43,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo Ok(ExportInfo { packages, workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(), + workspace_default_members: ws.default_members().map(|pkg| pkg.package_id()).collect(), resolve, target_directory: ws.target_dir().into_path_unlocked(), version: VERSION, @@ -58,6 +59,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo pub struct ExportInfo { packages: Vec, workspace_members: Vec, + workspace_default_members: Vec, resolve: Option, target_directory: PathBuf, version: u32, diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 547916e7a77..299f5245dd4 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -65,6 +65,7 @@ fn cargo_metadata_simple() { } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { From b28601dfba545bc7ad22eaea5c3e7987d5b338c4 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Tue, 2 May 2023 23:19:22 -0700 Subject: [PATCH 2/5] Updated docs. --- src/doc/man/cargo-metadata.md | 6 ++++++ src/doc/man/generated_txt/cargo-metadata.txt | 6 ++++++ src/doc/src/commands/cargo-metadata.md | 6 ++++++ src/etc/man/cargo-metadata.1 | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/src/doc/man/cargo-metadata.md b/src/doc/man/cargo-metadata.md index 4f9032d56cc..0027a20b1f4 100644 --- a/src/doc/man/cargo-metadata.md +++ b/src/doc/man/cargo-metadata.md @@ -212,6 +212,12 @@ The output has the following format: "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/doc/man/generated_txt/cargo-metadata.txt b/src/doc/man/generated_txt/cargo-metadata.txt index be8bed7c66f..d9d48fd9a74 100644 --- a/src/doc/man/generated_txt/cargo-metadata.txt +++ b/src/doc/man/generated_txt/cargo-metadata.txt @@ -207,6 +207,12 @@ OUTPUT FORMAT "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/doc/src/commands/cargo-metadata.md b/src/doc/src/commands/cargo-metadata.md index ebde0ea101c..e9aeac7dfa7 100644 --- a/src/doc/src/commands/cargo-metadata.md +++ b/src/doc/src/commands/cargo-metadata.md @@ -212,6 +212,12 @@ The output has the following format: "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/etc/man/cargo-metadata.1 b/src/etc/man/cargo-metadata.1 index 8549290cde5..f2ebb63c7eb 100644 --- a/src/etc/man/cargo-metadata.1 +++ b/src/etc/man/cargo-metadata.1 @@ -209,6 +209,12 @@ The output has the following format: "workspace_members": [ "my\-package 0.1.0 (path+file:///path/to/my\-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my\-package 0.1.0 (path+file:///path/to/my\-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. From e421345d22f7d670f66d884a196de15e943a6ae5 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Wed, 3 May 2023 00:23:51 -0700 Subject: [PATCH 3/5] Added workspace_default_members to tests. --- tests/testsuite/metadata.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 299f5245dd4..95c13819626 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -1954,6 +1954,7 @@ const MANIFEST_OUTPUT: &str = r#" "documentation": null }], "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ], + "workspace_default_members": [ "foo 0.5.0 (path+file:[..]foo)" ], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2318,6 +2319,7 @@ fn cargo_metadata_path_to_cargo_toml_project() { "workspace_members": [ "bar 0.5.0 (path+file:[..])" ], + "workspace_default_members": [], "workspace_root": "[..]", "metadata": null } From f43e6d947fe313cfaf476b07615a844c6a61067f Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Wed, 3 May 2023 01:37:37 -0700 Subject: [PATCH 4/5] Added workspace_default_members to more tests. --- tests/testsuite/alt_registry.rs | 9 ++++ tests/testsuite/features_namespaced.rs | 1 + tests/testsuite/git.rs | 3 ++ tests/testsuite/metadata.rs | 57 +++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index e9dd0071e06..ac60ca92fa8 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -902,6 +902,9 @@ fn alt_reg_metadata() { "workspace_members": [ "foo 0.0.1 (path+file:[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file:[..]/foo)" + ], "resolve": null, "target_directory": "[..]/foo/target", "version": 1, @@ -1102,6 +1105,9 @@ fn alt_reg_metadata() { "workspace_members": [ "foo 0.0.1 (path+file:[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file:[..]/foo)" + ], "resolve": "{...}", "target_directory": "[..]/foo/target", "version": 1, @@ -1265,6 +1271,9 @@ fn unknown_registry() { "workspace_members": [ "foo 0.0.1 (path+file://[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file://[..]/foo)" + ], "resolve": "{...}", "target_directory": "[..]/foo/target", "version": 1, diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs index d090235d5ab..a6047231beb 100644 --- a/tests/testsuite/features_namespaced.rs +++ b/tests/testsuite/features_namespaced.rs @@ -609,6 +609,7 @@ fn json_exposed() { } ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": null, "target_directory": "[..]foo/target", "version": 1, diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 32d0730c129..09119203783 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -3337,6 +3337,9 @@ fn metadata_master_consistency() { "workspace_members": [ "foo 0.1.0 [..]" ], + "workspace_default_members": [ + "foo 0.1.0 [..]" + ], "resolve": { "nodes": [ { diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 95c13819626..ac2cec39661 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -165,6 +165,7 @@ crate-type = ["lib", "staticlib"] } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { @@ -258,6 +259,7 @@ optional_feat = [] } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { @@ -588,6 +590,9 @@ fn cargo_metadata_with_deps_and_version() { "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.5.0 (path+file:[..]foo)" + ], "workspace_root": "[..]/foo", "metadata": null }"#, @@ -669,6 +674,9 @@ name = "ex" "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" + ], "resolve": { "root": "foo 0.1.0 (path+file://[..]foo)", "nodes": [ @@ -763,6 +771,9 @@ crate-type = ["rlib", "dylib"] ], "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" + ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" ], "resolve": { "root": "foo 0.1.0 (path+file://[..]foo)", @@ -893,6 +904,7 @@ fn workspace_metadata() { } ], "workspace_members": ["bar 0.5.0 (path+file:[..]bar)", "baz 0.5.0 (path+file:[..]baz)"], + "workspace_default_members": ["bar 0.5.0 (path+file:[..]bar)", "baz 0.5.0 (path+file:[..]baz)"], "resolve": { "nodes": [ { @@ -1124,6 +1136,11 @@ fn workspace_metadata_with_dependencies_no_deps() { "artifact 0.5.0 (path+file:[..]/foo/artifact)", "baz 0.5.0 (path+file:[..]baz)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file:[..]bar)", + "artifact 0.5.0 (path+file:[..]/foo/artifact)", + "baz 0.5.0 (path+file:[..]baz)" + ], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -1756,6 +1773,12 @@ fn workspace_metadata_with_dependencies_and_resolve() { "bin-only-artifact 0.5.0 (path+file://[..]/foo/bin-only-artifact)", "non-artifact 0.5.0 (path+file://[..]/foo/non-artifact)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file://[..]/foo/bar)", + "artifact 0.5.0 (path+file://[..]/foo/artifact)", + "bin-only-artifact 0.5.0 (path+file://[..]/foo/bin-only-artifact)", + "non-artifact 0.5.0 (path+file://[..]/foo/non-artifact)" + ], "workspace_root": "[..]/foo" } "#, @@ -2149,6 +2172,7 @@ fn package_metadata() { } ], "workspace_members": ["foo[..]"], + "workspace_default_members": ["foo[..]"], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2224,6 +2248,7 @@ fn package_publish() { } ], "workspace_members": ["foo[..]"], + "workspace_default_members": ["foo[..]"], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2319,7 +2344,9 @@ fn cargo_metadata_path_to_cargo_toml_project() { "workspace_members": [ "bar 0.5.0 (path+file:[..])" ], - "workspace_default_members": [], + "workspace_default_members": [ + "bar 0.5.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2408,6 +2435,9 @@ fn package_edition_2018() { "workspace_members": [ "foo 0.1.0 (path+file:[..])" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2556,6 +2586,9 @@ fn target_edition_2018() { "workspace_members": [ "foo 0.1.0 (path+file:[..])" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2792,6 +2825,9 @@ fn rename_dependency() { "workspace_members": [ "foo 0.0.1[..]" ], + "workspace_default_members": [ + "foo 0.0.1[..]" + ], "workspace_root": "[..]", "metadata": null }"#, @@ -2892,6 +2928,9 @@ fn metadata_links() { "workspace_members": [ "foo 0.5.0 [..]" ], + "workspace_default_members": [ + "foo 0.5.0 [..]" + ], "workspace_root": "[..]/foo", "metadata": null } @@ -2982,6 +3021,9 @@ fn deps_with_bin_only() { "workspace_members": [ "foo 0.1.0 ([..])" ], + "workspace_default_members": [ + "foo 0.1.0 ([..])" + ], "resolve": { "nodes": [ { @@ -3361,6 +3403,9 @@ fn filter_platform() { "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" + ], "resolve": { "nodes": [ { @@ -3480,6 +3525,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3561,6 +3607,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3645,6 +3692,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3759,6 +3807,7 @@ fn dep_kinds() { { "packages": "{...}", "workspace_members": "{...}", + "workspace_default_members": "{...}", "target_directory": "{...}", "version": 1, "workspace_root": "{...}", @@ -3874,6 +3923,7 @@ fn dep_kinds_workspace() { { "packages": "{...}", "workspace_members": "{...}", + "workspace_default_members": "{...}", "target_directory": "[..]/foo/target", "version": 1, "workspace_root": "[..]/foo", @@ -4187,6 +4237,11 @@ fn workspace_metadata_with_dependencies_no_deps_artifact() { "artifact 0.5.0 (path+file://[..]/foo/artifact)", "baz 0.5.0 (path+file://[..]/foo/baz)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file://[..]/foo/bar)", + "artifact 0.5.0 (path+file://[..]/foo/artifact)", + "baz 0.5.0 (path+file://[..]/foo/baz)" + ], "workspace_root": "[..]/foo" } "#, From 61df6bb41865e3e6ca05da1efac01be0ae3cbea9 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Wed, 3 May 2023 13:08:51 -0700 Subject: [PATCH 5/5] Fixed test update::update_precise_first_run. --- tests/testsuite/update.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 057c8fca4a3..1d3ee05b702 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -633,6 +633,9 @@ fn update_precise_first_run() { "workspace_members": [ "bar 0.0.1 (path+file://[..]/foo)" ], + "workspace_default_members": [ + "bar 0.0.1 (path+file://[..]/foo)" + ], "workspace_root": "[..]/foo", "metadata": null }"#,