1use crate::CommandError;
5use camino::{Utf8Path, Utf8PathBuf};
6use serde::{Deserialize, Serialize};
7use smol_str::SmolStr;
8use std::{
9 borrow::Cow,
10 cmp::Ordering,
11 collections::{BTreeMap, BTreeSet},
12 fmt::{self, Write as _},
13 path::PathBuf,
14 process::Command,
15};
16use target_spec::summaries::PlatformSummary;
17
18#[derive(Clone, Debug, Default)]
20pub struct ListCommand {
21 cargo_path: Option<Box<Utf8Path>>,
22 manifest_path: Option<Box<Utf8Path>>,
23 current_dir: Option<Box<Utf8Path>>,
24 args: Vec<Box<str>>,
25}
26
27impl ListCommand {
28 pub fn new() -> Self {
32 Self::default()
33 }
34
35 pub fn cargo_path(&mut self, path: impl Into<Utf8PathBuf>) -> &mut Self {
38 self.cargo_path = Some(path.into().into());
39 self
40 }
41
42 pub fn manifest_path(&mut self, path: impl Into<Utf8PathBuf>) -> &mut Self {
44 self.manifest_path = Some(path.into().into());
45 self
46 }
47
48 pub fn current_dir(&mut self, path: impl Into<Utf8PathBuf>) -> &mut Self {
50 self.current_dir = Some(path.into().into());
51 self
52 }
53
54 pub fn add_arg(&mut self, arg: impl Into<String>) -> &mut Self {
56 self.args.push(arg.into().into());
57 self
58 }
59
60 pub fn add_args(&mut self, args: impl IntoIterator<Item = impl Into<String>>) -> &mut Self {
62 for arg in args {
63 self.add_arg(arg.into());
64 }
65 self
66 }
67
68 pub fn cargo_command(&self) -> Command {
71 let cargo_path: PathBuf = self.cargo_path.as_ref().map_or_else(
72 || std::env::var_os("CARGO").map_or("cargo".into(), PathBuf::from),
73 |path| PathBuf::from(path.as_std_path()),
74 );
75
76 let mut command = Command::new(cargo_path);
77 if let Some(path) = &self.manifest_path.as_deref() {
78 command.args(["--manifest-path", path.as_str()]);
79 }
80 if let Some(current_dir) = &self.current_dir.as_deref() {
81 command.current_dir(current_dir);
82 }
83
84 command.args(["nextest", "list", "--message-format=json"]);
85
86 command.args(self.args.iter().map(|s| s.as_ref()));
87 command
88 }
89
90 pub fn exec(&self) -> Result<TestListSummary, CommandError> {
92 let mut command = self.cargo_command();
93 let output = command.output().map_err(CommandError::Exec)?;
94
95 if !output.status.success() {
96 let exit_code = output.status.code();
98 let stderr = output.stderr;
99 return Err(CommandError::CommandFailed { exit_code, stderr });
100 }
101
102 serde_json::from_slice(&output.stdout).map_err(CommandError::Json)
104 }
105
106 pub fn exec_binaries_only(&self) -> Result<BinaryListSummary, CommandError> {
109 let mut command = self.cargo_command();
110 command.arg("--list-type=binaries-only");
111 let output = command.output().map_err(CommandError::Exec)?;
112
113 if !output.status.success() {
114 let exit_code = output.status.code();
116 let stderr = output.stderr;
117 return Err(CommandError::CommandFailed { exit_code, stderr });
118 }
119
120 serde_json::from_slice(&output.stdout).map_err(CommandError::Json)
122 }
123}
124
125#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
127#[serde(rename_all = "kebab-case")]
128#[non_exhaustive]
129pub struct TestListSummary {
130 pub rust_build_meta: RustBuildMetaSummary,
132
133 pub test_count: usize,
135
136 pub rust_suites: BTreeMap<RustBinaryId, RustTestSuiteSummary>,
139}
140
141impl TestListSummary {
142 pub fn new(rust_build_meta: RustBuildMetaSummary) -> Self {
144 Self {
145 rust_build_meta,
146 test_count: 0,
147 rust_suites: BTreeMap::new(),
148 }
149 }
150 pub fn parse_json(json: impl AsRef<str>) -> Result<Self, serde_json::Error> {
152 serde_json::from_str(json.as_ref())
153 }
154}
155
156#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
158#[serde(rename_all = "kebab-case")]
159pub enum BuildPlatform {
160 Target,
162
163 Host,
165}
166
167impl fmt::Display for BuildPlatform {
168 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169 match self {
170 Self::Target => write!(f, "target"),
171 Self::Host => write!(f, "host"),
172 }
173 }
174}
175
176#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
180#[serde(rename_all = "kebab-case")]
181pub struct RustTestBinarySummary {
182 pub binary_id: RustBinaryId,
184
185 pub binary_name: String,
187
188 pub package_id: String,
192
193 pub kind: RustTestBinaryKind,
195
196 pub binary_path: Utf8PathBuf,
198
199 pub build_platform: BuildPlatform,
202}
203
204#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
209#[serde(transparent)]
210pub struct RustTestBinaryKind(pub Cow<'static, str>);
211
212impl RustTestBinaryKind {
213 #[inline]
215 pub fn new(kind: impl Into<Cow<'static, str>>) -> Self {
216 Self(kind.into())
217 }
218
219 #[inline]
221 pub const fn new_const(kind: &'static str) -> Self {
222 Self(Cow::Borrowed(kind))
223 }
224
225 pub fn as_str(&self) -> &str {
227 &self.0
228 }
229
230 pub const LIB: Self = Self::new_const("lib");
232
233 pub const TEST: Self = Self::new_const("test");
235
236 pub const BENCH: Self = Self::new_const("bench");
238
239 pub const BIN: Self = Self::new_const("bin");
241
242 pub const EXAMPLE: Self = Self::new_const("example");
244
245 pub const PROC_MACRO: Self = Self::new_const("proc-macro");
247}
248
249impl fmt::Display for RustTestBinaryKind {
250 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251 write!(f, "{}", self.0)
252 }
253}
254
255#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
257#[serde(rename_all = "kebab-case")]
258pub struct BinaryListSummary {
259 pub rust_build_meta: RustBuildMetaSummary,
261
262 pub rust_binaries: BTreeMap<RustBinaryId, RustTestBinarySummary>,
264}
265
266#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
270#[serde(transparent)]
271pub struct RustBinaryId(SmolStr);
272
273impl fmt::Display for RustBinaryId {
274 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
275 f.write_str(&self.0)
276 }
277}
278
279impl RustBinaryId {
280 #[inline]
282 pub fn new(id: &str) -> Self {
283 Self(id.into())
284 }
285
286 pub fn from_parts(package_name: &str, kind: &RustTestBinaryKind, target_name: &str) -> Self {
330 let mut id = package_name.to_owned();
331 if kind == &RustTestBinaryKind::LIB || kind == &RustTestBinaryKind::PROC_MACRO {
333 } else if kind == &RustTestBinaryKind::TEST {
335 id.push_str("::");
338 id.push_str(target_name);
339 } else {
340 write!(id, "::{kind}/{target_name}").unwrap();
344 }
345
346 Self(id.into())
347 }
348
349 #[inline]
351 pub fn as_str(&self) -> &str {
352 &self.0
353 }
354
355 #[inline]
357 pub fn len(&self) -> usize {
358 self.0.len()
359 }
360
361 #[inline]
363 pub fn is_empty(&self) -> bool {
364 self.0.is_empty()
365 }
366
367 #[inline]
369 pub fn components(&self) -> RustBinaryIdComponents<'_> {
370 RustBinaryIdComponents::new(self)
371 }
372}
373
374impl<S> From<S> for RustBinaryId
375where
376 S: AsRef<str>,
377{
378 #[inline]
379 fn from(s: S) -> Self {
380 Self(s.as_ref().into())
381 }
382}
383
384impl Ord for RustBinaryId {
385 fn cmp(&self, other: &RustBinaryId) -> Ordering {
386 self.components().cmp(&other.components())
391 }
392}
393
394impl PartialOrd for RustBinaryId {
395 fn partial_cmp(&self, other: &RustBinaryId) -> Option<Ordering> {
396 Some(self.cmp(other))
397 }
398}
399
400#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
406pub struct RustBinaryIdComponents<'a> {
407 pub package_name: &'a str,
409
410 pub binary_name_and_kind: RustBinaryIdNameAndKind<'a>,
412}
413
414impl<'a> RustBinaryIdComponents<'a> {
415 fn new(id: &'a RustBinaryId) -> Self {
416 let mut parts = id.as_str().splitn(2, "::");
417
418 let package_name = parts
419 .next()
420 .expect("splitn(2) returns at least 1 component");
421 let binary_name_and_kind = if let Some(suffix) = parts.next() {
422 let mut parts = suffix.splitn(2, '/');
423
424 let part1 = parts
425 .next()
426 .expect("splitn(2) returns at least 1 component");
427 if let Some(binary_name) = parts.next() {
428 RustBinaryIdNameAndKind::NameAndKind {
429 kind: part1,
430 binary_name,
431 }
432 } else {
433 RustBinaryIdNameAndKind::NameOnly { binary_name: part1 }
434 }
435 } else {
436 RustBinaryIdNameAndKind::None
437 };
438
439 Self {
440 package_name,
441 binary_name_and_kind,
442 }
443 }
444}
445
446#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
450pub enum RustBinaryIdNameAndKind<'a> {
451 None,
453
454 NameOnly {
456 binary_name: &'a str,
458 },
459
460 NameAndKind {
462 kind: &'a str,
464
465 binary_name: &'a str,
467 },
468}
469
470#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
476#[serde(transparent)]
477pub struct TestCaseName(SmolStr);
478
479impl fmt::Display for TestCaseName {
480 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
481 f.write_str(&self.0)
482 }
483}
484
485impl TestCaseName {
486 #[inline]
488 pub fn new(name: &str) -> Self {
489 Self(name.into())
490 }
491
492 #[inline]
494 pub fn as_str(&self) -> &str {
495 &self.0
496 }
497
498 #[inline]
500 pub fn as_bytes(&self) -> &[u8] {
501 self.0.as_bytes()
502 }
503
504 #[inline]
506 pub fn len(&self) -> usize {
507 self.0.len()
508 }
509
510 #[inline]
512 pub fn is_empty(&self) -> bool {
513 self.0.is_empty()
514 }
515
516 #[inline]
518 pub fn contains(&self, pattern: &str) -> bool {
519 self.0.contains(pattern)
520 }
521
522 #[inline]
541 pub fn components(&self) -> std::str::Split<'_, &str> {
542 self.0.split("::")
543 }
544
545 #[inline]
562 pub fn module_path_and_name(&self) -> (Option<&str>, &str) {
563 match self.0.rsplit_once("::") {
564 Some((module_path, name)) => (Some(module_path), name),
565 None => (None, &self.0),
566 }
567 }
568}
569
570impl AsRef<str> for TestCaseName {
571 #[inline]
572 fn as_ref(&self) -> &str {
573 &self.0
574 }
575}
576
577#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
579#[serde(rename_all = "kebab-case")]
580pub struct RustBuildMetaSummary {
581 pub target_directory: Utf8PathBuf,
583
584 pub base_output_directories: BTreeSet<Utf8PathBuf>,
586
587 pub non_test_binaries: BTreeMap<String, BTreeSet<RustNonTestBinarySummary>>,
589
590 #[serde(default)]
595 pub build_script_out_dirs: BTreeMap<String, Utf8PathBuf>,
596
597 pub linked_paths: BTreeSet<Utf8PathBuf>,
599
600 #[serde(default)]
604 pub platforms: Option<BuildPlatformsSummary>,
605
606 #[serde(default)]
610 pub target_platforms: Vec<PlatformSummary>,
611
612 #[serde(default)]
617 pub target_platform: Option<String>,
618}
619
620#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
623#[serde(rename_all = "kebab-case")]
624pub struct RustNonTestBinarySummary {
625 pub name: String,
627
628 pub kind: RustNonTestBinaryKind,
630
631 pub path: Utf8PathBuf,
633}
634
635#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
637#[serde(rename_all = "kebab-case")]
638pub struct BuildPlatformsSummary {
639 pub host: HostPlatformSummary,
641
642 pub targets: Vec<TargetPlatformSummary>,
646}
647
648#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
650#[serde(rename_all = "kebab-case")]
651pub struct HostPlatformSummary {
652 pub platform: PlatformSummary,
654
655 pub libdir: PlatformLibdirSummary,
657}
658
659#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
661#[serde(rename_all = "kebab-case")]
662pub struct TargetPlatformSummary {
663 pub platform: PlatformSummary,
665
666 pub libdir: PlatformLibdirSummary,
670}
671
672#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
674#[serde(tag = "status", rename_all = "kebab-case")]
675pub enum PlatformLibdirSummary {
676 Available {
678 path: Utf8PathBuf,
680 },
681
682 Unavailable {
684 reason: PlatformLibdirUnavailable,
686 },
687}
688
689#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
695pub struct PlatformLibdirUnavailable(pub Cow<'static, str>);
696
697impl PlatformLibdirUnavailable {
698 pub const RUSTC_FAILED: Self = Self::new_const("rustc-failed");
700
701 pub const RUSTC_OUTPUT_ERROR: Self = Self::new_const("rustc-output-error");
704
705 pub const OLD_SUMMARY: Self = Self::new_const("old-summary");
708
709 pub const NOT_IN_ARCHIVE: Self = Self::new_const("not-in-archive");
712
713 pub const fn new_const(reason: &'static str) -> Self {
715 Self(Cow::Borrowed(reason))
716 }
717
718 pub fn new(reason: impl Into<Cow<'static, str>>) -> Self {
720 Self(reason.into())
721 }
722
723 pub fn as_str(&self) -> &str {
725 &self.0
726 }
727}
728
729#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
734#[serde(transparent)]
735pub struct RustNonTestBinaryKind(pub Cow<'static, str>);
736
737impl RustNonTestBinaryKind {
738 #[inline]
740 pub fn new(kind: impl Into<Cow<'static, str>>) -> Self {
741 Self(kind.into())
742 }
743
744 #[inline]
746 pub const fn new_const(kind: &'static str) -> Self {
747 Self(Cow::Borrowed(kind))
748 }
749
750 pub fn as_str(&self) -> &str {
752 &self.0
753 }
754
755 pub const DYLIB: Self = Self::new_const("dylib");
758
759 pub const BIN_EXE: Self = Self::new_const("bin-exe");
761}
762
763impl fmt::Display for RustNonTestBinaryKind {
764 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
765 write!(f, "{}", self.0)
766 }
767}
768
769#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
773#[serde(rename_all = "kebab-case")]
774pub struct RustTestSuiteSummary {
775 pub package_name: String,
777
778 #[serde(flatten)]
780 pub binary: RustTestBinarySummary,
781
782 pub cwd: Utf8PathBuf,
784
785 #[serde(default = "listed_status")]
790 pub status: RustTestSuiteStatusSummary,
791
792 #[serde(rename = "testcases")]
794 pub test_cases: BTreeMap<TestCaseName, RustTestCaseSummary>,
795}
796
797fn listed_status() -> RustTestSuiteStatusSummary {
798 RustTestSuiteStatusSummary::LISTED
799}
800
801#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
805#[serde(transparent)]
806pub struct RustTestSuiteStatusSummary(pub Cow<'static, str>);
807
808impl RustTestSuiteStatusSummary {
809 #[inline]
811 pub fn new(kind: impl Into<Cow<'static, str>>) -> Self {
812 Self(kind.into())
813 }
814
815 #[inline]
817 pub const fn new_const(kind: &'static str) -> Self {
818 Self(Cow::Borrowed(kind))
819 }
820
821 pub fn as_str(&self) -> &str {
823 &self.0
824 }
825
826 pub const LISTED: Self = Self::new_const("listed");
829
830 pub const SKIPPED: Self = Self::new_const("skipped");
835
836 pub const SKIPPED_DEFAULT_FILTER: Self = Self::new_const("skipped-default-filter");
840}
841
842#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
846#[serde(rename_all = "kebab-case")]
847pub struct RustTestCaseSummary {
848 pub kind: Option<RustTestKind>,
853
854 pub ignored: bool,
858
859 pub filter_match: FilterMatch,
863}
864
865#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
869#[serde(transparent)]
870pub struct RustTestKind(pub Cow<'static, str>);
871
872impl RustTestKind {
873 #[inline]
875 pub fn new(kind: impl Into<Cow<'static, str>>) -> Self {
876 Self(kind.into())
877 }
878
879 #[inline]
881 pub const fn new_const(kind: &'static str) -> Self {
882 Self(Cow::Borrowed(kind))
883 }
884
885 pub fn as_str(&self) -> &str {
887 &self.0
888 }
889
890 pub const TEST: Self = Self::new_const("test");
892
893 pub const BENCH: Self = Self::new_const("bench");
895}
896
897#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
899#[serde(rename_all = "kebab-case", tag = "status")]
900pub enum FilterMatch {
901 Matches,
903
904 Mismatch {
906 reason: MismatchReason,
908 },
909}
910
911impl FilterMatch {
912 pub fn is_match(&self) -> bool {
914 matches!(self, FilterMatch::Matches)
915 }
916}
917
918#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
920#[serde(rename_all = "kebab-case")]
921#[non_exhaustive]
922pub enum MismatchReason {
923 NotBenchmark,
925
926 Ignored,
928
929 String,
931
932 Expression,
934
935 Partition,
937
938 RerunAlreadyPassed,
940
941 DefaultFilter,
945}
946
947impl fmt::Display for MismatchReason {
948 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
949 match self {
950 MismatchReason::NotBenchmark => write!(f, "is not a benchmark"),
951 MismatchReason::Ignored => write!(f, "does not match the run-ignored option"),
952 MismatchReason::String => write!(f, "does not match the provided string filters"),
953 MismatchReason::Expression => {
954 write!(f, "does not match the provided expression filters")
955 }
956 MismatchReason::Partition => write!(f, "is in a different partition"),
957 MismatchReason::RerunAlreadyPassed => write!(f, "already passed"),
958 MismatchReason::DefaultFilter => {
959 write!(f, "is filtered out by the profile's default-filter")
960 }
961 }
962 }
963}
964
965#[cfg(feature = "proptest1")]
968mod proptest_impls {
969 use super::*;
970 use proptest::prelude::*;
971
972 impl Arbitrary for RustBinaryId {
973 type Parameters = ();
974 type Strategy = BoxedStrategy<Self>;
975
976 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
977 any::<String>().prop_map(|s| RustBinaryId::new(&s)).boxed()
978 }
979 }
980
981 impl Arbitrary for TestCaseName {
982 type Parameters = ();
983 type Strategy = BoxedStrategy<Self>;
984
985 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
986 any::<String>().prop_map(|s| TestCaseName::new(&s)).boxed()
987 }
988 }
989
990 impl Arbitrary for MismatchReason {
991 type Parameters = ();
992 type Strategy = BoxedStrategy<Self>;
993
994 fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
995 prop_oneof![
996 Just(MismatchReason::NotBenchmark),
997 Just(MismatchReason::Ignored),
998 Just(MismatchReason::String),
999 Just(MismatchReason::Expression),
1000 Just(MismatchReason::Partition),
1001 Just(MismatchReason::DefaultFilter),
1002 Just(MismatchReason::RerunAlreadyPassed),
1003 ]
1004 .boxed()
1005 }
1006 }
1007}
1008
1009#[cfg(test)]
1010mod tests {
1011 use super::*;
1012 use test_case::test_case;
1013
1014 #[test_case(r#"{
1015 "target-directory": "/foo",
1016 "base-output-directories": [],
1017 "non-test-binaries": {},
1018 "linked-paths": []
1019 }"#, RustBuildMetaSummary {
1020 target_directory: "/foo".into(),
1021 base_output_directories: BTreeSet::new(),
1022 non_test_binaries: BTreeMap::new(),
1023 build_script_out_dirs: BTreeMap::new(),
1024 linked_paths: BTreeSet::new(),
1025 target_platform: None,
1026 target_platforms: vec![],
1027 platforms: None,
1028 }; "no target platform")]
1029 #[test_case(r#"{
1030 "target-directory": "/foo",
1031 "base-output-directories": [],
1032 "non-test-binaries": {},
1033 "linked-paths": [],
1034 "target-platform": "x86_64-unknown-linux-gnu"
1035 }"#, RustBuildMetaSummary {
1036 target_directory: "/foo".into(),
1037 base_output_directories: BTreeSet::new(),
1038 non_test_binaries: BTreeMap::new(),
1039 build_script_out_dirs: BTreeMap::new(),
1040 linked_paths: BTreeSet::new(),
1041 target_platform: Some("x86_64-unknown-linux-gnu".to_owned()),
1042 target_platforms: vec![],
1043 platforms: None,
1044 }; "single target platform specified")]
1045 fn test_deserialize_old_rust_build_meta(input: &str, expected: RustBuildMetaSummary) {
1046 let build_meta: RustBuildMetaSummary =
1047 serde_json::from_str(input).expect("input deserialized correctly");
1048 assert_eq!(
1049 build_meta, expected,
1050 "deserialized input matched expected output"
1051 );
1052 }
1053
1054 #[test]
1055 fn test_binary_id_ord() {
1056 let empty = RustBinaryId::new("");
1057 let foo = RustBinaryId::new("foo");
1058 let bar = RustBinaryId::new("bar");
1059 let foo_name1 = RustBinaryId::new("foo::name1");
1060 let foo_name2 = RustBinaryId::new("foo::name2");
1061 let bar_name = RustBinaryId::new("bar::name");
1062 let foo_bin_name1 = RustBinaryId::new("foo::bin/name1");
1063 let foo_bin_name2 = RustBinaryId::new("foo::bin/name2");
1064 let bar_bin_name = RustBinaryId::new("bar::bin/name");
1065 let foo_proc_macro_name = RustBinaryId::new("foo::proc_macro/name");
1066 let bar_proc_macro_name = RustBinaryId::new("bar::proc_macro/name");
1067
1068 let sorted_ids = [
1070 empty,
1071 bar,
1072 bar_name,
1073 bar_bin_name,
1074 bar_proc_macro_name,
1075 foo,
1076 foo_name1,
1077 foo_name2,
1078 foo_bin_name1,
1079 foo_bin_name2,
1080 foo_proc_macro_name,
1081 ];
1082
1083 for (i, id) in sorted_ids.iter().enumerate() {
1084 for (j, other_id) in sorted_ids.iter().enumerate() {
1085 let expected = i.cmp(&j);
1086 assert_eq!(
1087 id.cmp(other_id),
1088 expected,
1089 "comparing {id:?} to {other_id:?} gave {expected:?}"
1090 );
1091 }
1092 }
1093 }
1094}