@@ -5,8 +5,7 @@ extern crate serde_json;
5
5
6
6
use camino:: Utf8PathBuf ;
7
7
use cargo_metadata:: {
8
- workspace_default_members_is_missing, ArtifactDebuginfo , CargoOpt , DependencyKind , Edition ,
9
- Message , Metadata , MetadataCommand ,
8
+ ArtifactDebuginfo , CargoOpt , DependencyKind , Edition , Message , Metadata , MetadataCommand ,
10
9
} ;
11
10
12
11
/// Output from oldest version ever supported (1.24).
@@ -125,9 +124,9 @@ fn old_minimal() {
125
124
assert_eq ! ( meta. workspace_metadata, serde_json:: Value :: Null ) ;
126
125
assert_eq ! ( meta. target_directory, "/foo/target" ) ;
127
126
128
- assert ! ( workspace_default_members_is_missing (
129
- & meta. workspace_default_members
130
- ) ) ;
127
+ assert ! ( !meta . workspace_default_members . is_available ( ) ) ;
128
+ assert ! ( meta. workspace_default_members. is_missing ( ) ) ;
129
+
131
130
let serialized = serde_json:: to_value ( meta) . unwrap ( ) ;
132
131
assert ! ( !serialized
133
132
. as_object( )
@@ -724,6 +723,159 @@ fn missing_workspace_default_members() {
724
723
let _ = & * meta. workspace_default_members ;
725
724
}
726
725
726
+ #[ test]
727
+ fn workspace_default_members_is_available ( ) {
728
+ // generated with cargo +1.71.0 metadata --format-version 1
729
+ let json = r#"
730
+ {
731
+ "packages": [
732
+ {
733
+ "name": "basic",
734
+ "version": "0.1.0",
735
+ "id": "basic 0.1.0 (path+file:///example)",
736
+ "license": null,
737
+ "license_file": null,
738
+ "description": null,
739
+ "source": null,
740
+ "dependencies": [],
741
+ "targets": [
742
+ {
743
+ "kind": [
744
+ "lib"
745
+ ],
746
+ "crate_types": [
747
+ "lib"
748
+ ],
749
+ "name": "basic",
750
+ "src_path": "/example/src/lib.rs",
751
+ "edition": "2021",
752
+ "doc": true,
753
+ "doctest": true,
754
+ "test": true
755
+ }
756
+ ],
757
+ "features": {},
758
+ "manifest_path": "/example/Cargo.toml",
759
+ "metadata": null,
760
+ "publish": null,
761
+ "authors": [],
762
+ "categories": [],
763
+ "keywords": [],
764
+ "readme": null,
765
+ "repository": null,
766
+ "homepage": null,
767
+ "documentation": null,
768
+ "edition": "2021",
769
+ "links": null,
770
+ "default_run": null,
771
+ "rust_version": null
772
+ }
773
+ ],
774
+ "workspace_members": [
775
+ "basic 0.1.0 (path+file:///example)"
776
+ ],
777
+ "workspace_default_members": [
778
+ "basic 0.1.0 (path+file:///example)"
779
+ ],
780
+ "resolve": {
781
+ "nodes": [
782
+ {
783
+ "id": "basic 0.1.0 (path+file:///example)",
784
+ "dependencies": [],
785
+ "deps": [],
786
+ "features": []
787
+ }
788
+ ],
789
+ "root": "basic 0.1.0 (path+file:///example)"
790
+ },
791
+ "target_directory": "/example/target",
792
+ "version": 1,
793
+ "workspace_root": "/example",
794
+ "metadata": null
795
+ }
796
+ "# ;
797
+
798
+ let meta: Metadata = serde_json:: from_str ( json) . unwrap ( ) ;
799
+
800
+ assert ! ( meta. workspace_default_members. is_available( ) ) ;
801
+ assert ! ( !meta. workspace_default_members. is_missing( ) ) ;
802
+ }
803
+
804
+ #[ test]
805
+ fn workspace_default_members_is_missing ( ) {
806
+ // generated with cargo +1.70.0 metadata --format-version 1
807
+ let json = r#"
808
+ {
809
+ "packages": [
810
+ {
811
+ "name": "basic",
812
+ "version": "0.1.0",
813
+ "id": "basic 0.1.0 (path+file:///example)",
814
+ "license": null,
815
+ "license_file": null,
816
+ "description": null,
817
+ "source": null,
818
+ "dependencies": [],
819
+ "targets": [
820
+ {
821
+ "kind": [
822
+ "lib"
823
+ ],
824
+ "crate_types": [
825
+ "lib"
826
+ ],
827
+ "name": "basic",
828
+ "src_path": "/example/src/lib.rs",
829
+ "edition": "2021",
830
+ "doc": true,
831
+ "doctest": true,
832
+ "test": true
833
+ }
834
+ ],
835
+ "features": {},
836
+ "manifest_path": "/example/Cargo.toml",
837
+ "metadata": null,
838
+ "publish": null,
839
+ "authors": [],
840
+ "categories": [],
841
+ "keywords": [],
842
+ "readme": null,
843
+ "repository": null,
844
+ "homepage": null,
845
+ "documentation": null,
846
+ "edition": "2021",
847
+ "links": null,
848
+ "default_run": null,
849
+ "rust_version": null
850
+ }
851
+ ],
852
+ "workspace_members": [
853
+ "basic 0.1.0 (path+file:///example)"
854
+ ],
855
+ "resolve": {
856
+ "nodes": [
857
+ {
858
+ "id": "basic 0.1.0 (path+file:///example)",
859
+ "dependencies": [],
860
+ "deps": [],
861
+ "features": []
862
+ }
863
+ ],
864
+ "root": "basic 0.1.0 (path+file:///example)"
865
+ },
866
+ "target_directory": "/example/target",
867
+ "version": 1,
868
+ "workspace_root": "/example",
869
+ "metadata": null
870
+ }
871
+ "# ;
872
+
873
+ let meta: Metadata = serde_json:: from_str ( json) . unwrap ( ) ;
874
+
875
+ assert ! ( !meta. workspace_default_members. is_available( ) ) ;
876
+ assert ! ( meta. workspace_default_members. is_missing( ) ) ;
877
+ }
878
+
727
879
#[ test]
728
880
fn test_unknown_target_kind_and_crate_type ( ) {
729
881
// Both kind and crate_type set to a type not yet known
0 commit comments