fixtures/
json.rs

1// Copyright (c) The cargo-guppy Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4use crate::{
5    details::{FixtureDetails, LinkDetails, PackageDetails, PlatformResults},
6    package_id,
7};
8use ahash::AHashMap;
9use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
10use guppy::{
11    errors::{FeatureBuildStage, FeatureGraphWarning},
12    graph::{BuildTargetId, BuildTargetKind, PackageGraph},
13    platform::{EnabledTernary, Platform, TargetFeatures},
14    CargoMetadata, DependencyKind,
15};
16use once_cell::sync::{Lazy, OnceCell};
17use std::{collections::BTreeMap, fs};
18
19// Metadata along with interesting crate names.
20pub static METADATA1_PATH: &str = "../small/metadata1.json";
21pub static METADATA1_TESTCRATE: &str = "testcrate 0.1.0 (path+file:///fakepath/testcrate)";
22pub static METADATA1_DATATEST: &str =
23    "datatest 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)";
24pub static METADATA1_REGION: &str =
25    "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)";
26pub static METADATA1_DTOA: &str =
27    "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)";
28
29pub static METADATA2_PATH: &str = "../small/metadata2.json";
30pub static METADATA2_TESTCRATE: &str =
31    "testworkspace-crate 0.1.0 (path+file:///Users/fakeuser/local/testworkspace/testcrate)";
32pub static METADATA2_WALKDIR: &str =
33    "walkdir 2.2.9 (path+file:///Users/fakeuser/local/testworkspace/walkdir)";
34pub static METADATA2_QUOTE: &str = "quote 1.0.2 (path+file:///Users/fakeuser/local/quote)";
35
36pub static METADATA_BUILDDEP_PATH: &str = "../small/builddep.json";
37
38pub static METADATA_DUPS_PATH: &str = "../small/metadata_dups.json";
39pub static METADATA_DUPS_TESTCRATE: &str =
40    "testcrate-dups 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcrate-dups)";
41pub static METADATA_DUPS_LAZY_STATIC_1: &str =
42    "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)";
43pub static METADATA_DUPS_LAZY_STATIC_02: &str =
44    "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)";
45pub static METADATA_DUPS_BYTES_03: &str =
46    "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)";
47pub static METADATA_DUPS_BYTES_05: &str =
48    "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)";
49
50pub static METADATA_CYCLE1_PATH: &str = "../small/metadata_cycle1.json";
51pub static METADATA_CYCLE1_BASE: &str =
52    "testcycles-base 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-base)";
53pub static METADATA_CYCLE1_HELPER: &str =
54    "testcycles-helper 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcycles/testcycles-helper)";
55
56pub static METADATA_CYCLE2_PATH: &str = "../small/metadata_cycle2.json";
57pub static METADATA_CYCLE2_UPPER_A: &str =
58    "upper-a 0.1.0 (path+file:///Users/fakeuser/local/testcrates/cycle2/upper-a)";
59pub static METADATA_CYCLE2_UPPER_B: &str =
60    "upper-b 0.1.0 (path+file:///Users/fakeuser/local/testcrates/cycle2/upper-b)";
61pub static METADATA_CYCLE2_LOWER_A: &str =
62    "lower-a 0.1.0 (path+file:///Users/fakeuser/local/testcrates/cycle2/lower-a)";
63pub static METADATA_CYCLE2_LOWER_B: &str =
64    "lower-b 0.1.0 (path+file:///Users/fakeuser/local/testcrates/cycle2/lower-b)";
65
66pub static METADATA_CYCLE_FEATURES_PATH: &str = "../small/metadata_cycle_features.json";
67pub static METADATA_CYCLE_FEATURES_BASE: &str =
68    "testcycles-base 0.1.0 (path+file:///fakepath/testcycles-features/testcycles-base)";
69pub static METADATA_CYCLE_FEATURES_HELPER: &str =
70    "testcycles-helper 0.1.0 (path+file:///fakepath/testcycles-features/testcycles-helper)";
71
72pub static METADATA_TARGETS1_PATH: &str = "../small/metadata_targets1.json";
73pub static METADATA_TARGETS1_TESTCRATE: &str =
74    "testcrate-targets 0.1.0 (path+file:///Users/fakeuser/local/testcrates/testcrate-targets)";
75pub static METADATA_TARGETS1_LAZY_STATIC_1: &str =
76    "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)";
77pub static METADATA_TARGETS1_LAZY_STATIC_02: &str =
78    "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)";
79pub static METADATA_TARGETS1_LAZY_STATIC_01: &str =
80    "lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)";
81pub static METADATA_TARGETS1_BYTES: &str =
82    "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)";
83pub static METADATA_TARGETS1_DEP_A: &str =
84    "dep-a 0.1.0 (path+file:///Users/fakeuser/local/testcrates/dep-a)";
85
86pub static METADATA_BUILD_TARGETS1_PATH: &str = "../small/metadata_build_targets1.json";
87pub static METADATA_BUILD_TARGETS1_TESTCRATE: &str =
88    "testcrate 0.1.0 (path+file:///Users/fakeuser/local/testcrates/test-build-targets)";
89
90pub static METADATA_PROC_MACRO1_PATH: &str = "../small/metadata_proc_macro1.json";
91pub static METADATA_PROC_MACRO1_MACRO: &str =
92    "macro 0.1.0 (path+file:///Users/fakeuser/local/testcrates/proc-macro/macro)";
93pub static METADATA_PROC_MACRO1_NORMAL_USER: &str =
94    "normal-user 0.1.0 (path+file:///Users/fakeuser/local/testcrates/proc-macro/normal-user)";
95pub static METADATA_PROC_MACRO1_BUILD_USER: &str =
96    "build-user 0.1.0 (path+file:///Users/fakeuser/local/testcrates/proc-macro/build-user)";
97pub static METADATA_PROC_MACRO1_DEV_USER: &str =
98    "dev-user 0.1.0 (path+file:///Users/fakeuser/local/testcrates/proc-macro/dev-user)";
99
100pub static METADATA_ALTERNATE_REGISTRIES_PATH: &str = "../small/alternate-registries.json";
101pub static METADATA_ALTERNATE_REGISTRY_URL: &str = "https://github.com/fakeorg/crates.io-index";
102
103pub static METADATA_WEAK_NAMESPACED_FEATURES_PATH: &str = "../small/weak-namespaced-features.json";
104pub static METADATA_WEAK_NAMESPACED_ID: &str =
105    "namespaced-weak 0.1.0 (path+file:///home/fakeuser/dev/tmp/test-workspaces/namespaced-weak)";
106pub static METADATA_WEAK_NAMESPACED_SMALLVEC: &str =
107    "smallvec 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)";
108pub static METADATA_WEAK_NAMESPACED_ARRAYVEC: &str =
109    "arrayvec 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)";
110pub static METADATA_WEAK_NAMESPACED_TINYVEC: &str =
111    "tinyvec 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)";
112
113pub static METADATA_LIBRA_PATH: &str = "../large/metadata_libra.json";
114pub static METADATA_LIBRA_ADMISSION_CONTROL_SERVICE: &str =
115    "admission-control-service 0.1.0 (path+file:///Users/fakeuser/local/libra/admission_control/admission-control-service)";
116pub static METADATA_LIBRA_COMPILER: &str =
117    "compiler 0.1.0 (path+file:///Users/fakeuser/local/libra/language/compiler)";
118pub static METADATA_LIBRA_E2E_TESTS: &str =
119    "language-e2e-tests 0.1.0 (path+file:///Users/fakeuser/local/libra/language/e2e-tests)";
120pub static METADATA_LIBRA_EXECUTOR: &str =
121    "executor 0.1.0 (path+file:///Users/fakeuser/local/libra/execution/executor)";
122pub static METADATA_LIBRA_EXECUTOR_UTILS: &str =
123    "executor-utils 0.1.0 (path+file:///Users/fakeuser/local/libra/execution/executor-utils)";
124pub static METADATA_LIBRA_COST_SYNTHESIS: &str =
125    "cost-synthesis 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/cost-synthesis)";
126pub static METADATA_LIBRA_FUNCTIONAL_TESTS: &str =
127    "functional_tests 0.1.0 (path+file:///Users/fakeuser/local/libra/language/functional_tests)";
128pub static METADATA_LIBRA_FUNCTIONAL_HYPHEN_TESTS: &str =
129    "functional-tests 0.1.0 (path+file:///Users/fakeuser/local/libra/language/functional-tests)";
130pub static METADATA_LIBRA_LIBRA_VM: &str =
131    "libra-vm 0.1.0 (path+file:///Users/fakeuser/local/libra/language/libra-vm)";
132pub static METADATA_LIBRA_MOVE_LANG: &str =
133    "move-lang 0.0.1 (path+file:///Users/fakeuser/local/libra/language/move-lang)";
134pub static METADATA_LIBRA_MOVE_LANG_STDLIB: &str =
135    "move-lang-stdlib 0.1.0 (path+file:///Users/fakeuser/local/libra/language/move-lang/stdlib)";
136pub static METADATA_LIBRA_MOVE_VM_RUNTIME: &str =
137    "move-vm-runtime 0.1.0 (path+file:///Users/fakeuser/local/libra/language/move-vm/runtime)";
138pub static METADATA_LIBRA_STDLIB: &str =
139    "stdlib 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stdlib)";
140pub static METADATA_LIBRA_TEST_GENERATION: &str =
141    "test-generation 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/test-generation)";
142pub static METADATA_LIBRA_TRANSACTION_BUILDER: &str =
143    "transaction-builder 0.1.0 (path+file:///Users/fakeuser/local/libra/language/transaction-builder)";
144pub static METADATA_LIBRA_VM_GENESIS: &str =
145    "vm-genesis 0.1.0 (path+file:///Users/fakeuser/local/libra/language/tools/vm-genesis)";
146pub static METADATA_LIBRA_LANGUAGE_BENCHMARKS: &str =
147    "language_benchmarks 0.1.0 (path+file:///Users/fakeuser/local/libra/language/benchmarks)";
148pub static METADATA_LIBRA_TREE_HEAP: &str =
149    "tree_heap 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stackless-bytecode/tree_heap)";
150pub static METADATA_LIBRA_LAZY_STATIC: &str =
151    "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)";
152pub static METADATA_LIBRA_BACKTRACE: &str =
153    "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)";
154pub static METADATA_LIBRA_CFG_IF: &str =
155    "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)";
156
157pub static METADATA_LIBRA_F0091A4_PATH: &str = "../large/metadata_libra_f0091a4.json";
158
159pub static METADATA_LIBRA_9FFD93B_PATH: &str = "../large/metadata_libra_9ffd93b.json";
160
161pub static MNEMOS_B3B4DA9_PATH: &str = "../large/mnemos_b3b4da9.json";
162
163pub static HYPER_UTIL_7AFB1ED_PATH: &str = "../large/hyper_util_7afb1ed.json";
164
165pub static METADATA_GUPPY_78CB7E8_PATH: &str = "../guppy/metadata_guppy_78cb7e8.json";
166
167pub static METADATA_GUPPY_869476C_PATH: &str = "../guppy/metadata_guppy_869476c.json";
168
169pub static METADATA_GUPPY_C9B4F76_PATH: &str = "../guppy/metadata_guppy_c9b4f76.json";
170
171pub static METADATA_GUPPY_44B62FA_PATH: &str = "../guppy/metadata_guppy_44b62fa.json";
172pub static METADATA_GUPPY_CARGO_GUPPY: &str =
173    "cargo-guppy 0.1.0 (path+file:///home/fakeuser/dev/cargo-guppy/cargo-guppy)";
174
175pub static FAKE_AUTHOR: &str = "Fake Author <fakeauthor@example.com>";
176
177macro_rules! define_fixtures {
178    ($($name: ident => $json_path: ident,)*) => {
179        impl JsonFixture {
180            // Access all fixtures.
181            pub fn all_fixtures() -> &'static BTreeMap<&'static str, JsonFixture> {
182                // Provide a list of all fixtures.
183                static ALL_FIXTURES: Lazy<BTreeMap<&'static str, JsonFixture>> = Lazy::new(|| {
184                    let mut map = BTreeMap::new();
185
186                    $(map.insert(
187                        stringify!($name),
188                        JsonFixture::new(stringify!($name), $json_path, FixtureDetails::$name()),
189                    );)*
190
191                    map
192                });
193
194                &*ALL_FIXTURES
195            }
196
197            // Access individual fixtures if the name is known.
198            $(pub fn $name() -> &'static Self {
199                &JsonFixture::all_fixtures()[stringify!($name)]
200            })*
201        }
202    };
203}
204
205define_fixtures! {
206    metadata1 => METADATA1_PATH,
207    metadata2 => METADATA2_PATH,
208    metadata_builddep => METADATA_BUILDDEP_PATH,
209    metadata_dups => METADATA_DUPS_PATH,
210    metadata_cycle1 => METADATA_CYCLE1_PATH,
211    metadata_cycle2 => METADATA_CYCLE2_PATH,
212    metadata_cycle_features => METADATA_CYCLE_FEATURES_PATH,
213    metadata_targets1 => METADATA_TARGETS1_PATH,
214    metadata_build_targets1 => METADATA_BUILD_TARGETS1_PATH,
215    metadata_proc_macro1 => METADATA_PROC_MACRO1_PATH,
216    metadata_alternate_registries => METADATA_ALTERNATE_REGISTRIES_PATH,
217    metadata_weak_namespaced_features => METADATA_WEAK_NAMESPACED_FEATURES_PATH,
218    metadata_libra => METADATA_LIBRA_PATH,
219    metadata_libra_f0091a4 => METADATA_LIBRA_F0091A4_PATH,
220    metadata_libra_9ffd93b => METADATA_LIBRA_9FFD93B_PATH,
221    mnemos_b3b4da9 => MNEMOS_B3B4DA9_PATH,
222    hyper_util_7afb1ed => HYPER_UTIL_7AFB1ED_PATH,
223    metadata_guppy_78cb7e8 => METADATA_GUPPY_78CB7E8_PATH,
224    metadata_guppy_869476c => METADATA_GUPPY_869476C_PATH,
225    metadata_guppy_c9b4f76 => METADATA_GUPPY_C9B4F76_PATH,
226    metadata_guppy_44b62fa => METADATA_GUPPY_44B62FA_PATH,
227}
228
229pub struct JsonFixture {
230    name: &'static str,
231    workspace_path: Utf8PathBuf,
232    abs_path: Utf8PathBuf,
233    json_graph: OnceCell<(String, PackageGraph)>,
234    details: FixtureDetails,
235}
236
237impl JsonFixture {
238    fn new(name: &'static str, rel_path: &'static str, details: FixtureDetails) -> Self {
239        let rel_path = Utf8Path::new(rel_path);
240        let fixtures_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR"));
241        // rel_path is relative to this dir.
242        let mut abs_path = fixtures_dir.join("src");
243        abs_path.push(rel_path);
244        let abs_path = Utf8PathBuf::from_path_buf(
245            abs_path
246                .canonicalize()
247                .expect("fixture path canonicalization succeeded"),
248        )
249        .expect("valid UTF-8 path");
250
251        let workspace_root = fixtures_dir.parent().expect("up to workspace root");
252        let workspace_path = Utf8PathBuf::from_path_buf(
253            pathdiff::diff_paths(&abs_path, workspace_root)
254                .expect("both abs_path and workspace root are absolute"),
255        )
256        .expect("diff of UTF-8 paths is UTF-8");
257
258        // No symlinks in this repo, so normalize this path.
259        let workspace_path = normalize_assuming_no_symlinks(workspace_path);
260
261        Self {
262            name,
263            workspace_path,
264            abs_path,
265            json_graph: OnceCell::new(),
266            details,
267        }
268    }
269
270    /// Lookup a fixture by name, or `None` if the name wasn't found.
271    pub fn by_name(name: &str) -> Option<&'static Self> {
272        Self::all_fixtures().get(name)
273    }
274
275    /// Returns the name of this fixture.
276    pub fn name(&self) -> &'static str {
277        self.name
278    }
279
280    /// Returns the absolute path of this fixture.
281    pub fn abs_path(&self) -> &Utf8Path {
282        &self.abs_path
283    }
284
285    /// Returns the path of this fixture, relative to the workspace root.
286    pub fn workspace_path(&self) -> &Utf8Path {
287        &self.workspace_path
288    }
289
290    /// Returns the unparsed JSON string for this fixture.
291    pub fn json(&self) -> &str {
292        self.init_graph().0
293    }
294
295    /// Returns the package graph for this fixture.
296    pub fn graph(&self) -> &PackageGraph {
297        self.init_graph().1
298    }
299
300    /// Returns the test details for this fixture.
301    pub fn details(&self) -> &FixtureDetails {
302        &self.details
303    }
304
305    /// Verifies that the parsed metadata matches known details.
306    pub fn verify(&self) {
307        let graph = self.graph();
308
309        graph.verify().expect("graph verification should succeed");
310
311        // Check that all external sources parse correctly in all graphs.
312        for package in graph.packages() {
313            let source = package.source();
314            if source.is_external() {
315                let external = source
316                    .parse_external()
317                    .unwrap_or_else(|| panic!("cannot parse external source {}", source));
318                assert_eq!(
319                    format!("{}", external),
320                    source.external_source().expect("is_external is true"),
321                    "roundtrip with ExternalSource"
322                );
323            }
324        }
325
326        self.details.assert_cycles(graph, "cycles");
327
328        self.details.assert_workspace(graph.workspace());
329        self.details.assert_topo(graph);
330
331        for id in self.details.known_ids() {
332            let msg = format!("error while verifying package '{}'", id);
333            let metadata = graph.metadata(id).expect(&msg);
334            self.details.assert_metadata(id, metadata, &msg);
335
336            // Check for build targets.
337            if self.details.has_build_targets(id) {
338                self.details.assert_build_targets(metadata, &msg);
339            }
340
341            // Check for direct dependency queries.
342            if self.details.has_deps(id) {
343                self.details.assert_deps(graph, id, &msg);
344            }
345            if self.details.has_reverse_deps(id) {
346                self.details.assert_reverse_deps(graph, id, &msg);
347            }
348
349            // Check for transitive dependency queries. Use both ID based and edge-based queries.
350            if self.details.has_transitive_deps(id) {
351                self.details.assert_transitive_deps(
352                    graph,
353                    id,
354                    &format!("{} (transitive deps)", msg),
355                );
356            }
357            if self.details.has_transitive_reverse_deps(id) {
358                self.details.assert_transitive_reverse_deps(
359                    graph,
360                    id,
361                    &format!("{} (transitive reverse deps)", msg),
362                );
363            }
364
365            // Check for named features.
366            if self.details.has_named_features(id) {
367                self.details
368                    .assert_named_features(graph, id, &format!("{} (named features)", msg));
369            }
370        }
371
372        self.details.assert_link_details(graph, "link details");
373
374        // Tests for the feature graph.
375        self.details
376            .assert_feature_graph_warnings(graph, "feature graph warnings");
377    }
378
379    fn init_graph(&self) -> (&str, &PackageGraph) {
380        let (json, package_graph) = self.json_graph.get_or_init(|| {
381            let json = fs::read_to_string(&self.abs_path)
382                .unwrap_or_else(|err| panic!("reading file '{}' failed: {}", self.abs_path, err));
383            let graph = Self::parse_graph(&json);
384            (json, graph)
385        });
386        (json.as_str(), package_graph)
387    }
388
389    fn parse_graph(json: &str) -> PackageGraph {
390        let metadata =
391            CargoMetadata::parse_json(json).expect("parsing metadata JSON should succeed");
392        PackageGraph::from_metadata(metadata).expect("constructing package graph should succeed")
393    }
394}
395
396// Thanks to @porglezomp on Twitter for this simple normalization method.
397fn normalize_assuming_no_symlinks(p: impl AsRef<Utf8Path>) -> Utf8PathBuf {
398    let mut out = Utf8PathBuf::new();
399    for c in p.as_ref().components() {
400        match c {
401            Utf8Component::ParentDir => {
402                out.pop();
403            }
404            c => out.push(c),
405        }
406    }
407    out
408}
409
410// Some clones in here make the code more uniform overall.
411#[allow(clippy::redundant_clone)]
412impl FixtureDetails {
413    // Specific fixtures follow.
414
415    pub(crate) fn metadata1() -> Self {
416        let mut details = AHashMap::new();
417
418        PackageDetails::new(
419            METADATA1_TESTCRATE,
420            "testcrate",
421            "0.1.0",
422            vec![FAKE_AUTHOR],
423            None,
424            None,
425        )
426        .with_workspace_path("")
427        .with_build_targets(vec![(
428            BuildTargetId::Binary("testcrate"),
429            BuildTargetKind::Binary,
430            "src/main.rs",
431        )])
432        .with_deps(vec![("datatest", METADATA1_DATATEST)])
433        .with_reverse_deps(vec![])
434        .insert_into(&mut details);
435
436        #[rustfmt::skip]
437        let datatest_deps =
438            vec![
439                ("ctor", "ctor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)"),
440                ("datatest-derive", "datatest-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)"),
441                ("regex", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)"),
442                ("region", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)"),
443                ("serde", "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)"),
444                ("serde_yaml", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)"),
445                ("version_check", "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)"),
446                // walkdir was replaced with [replace] (see metadata1.toml) -- ensure that the
447                // *replaced* version shows up here, not the regular one.
448                ("walkdir", "walkdir 2.2.9 (git+https://github.com/BurntSushi/walkdir?tag=2.2.9#7c7013259eb9db400b3e5c7bc60330ca08068826)"),
449                ("yaml-rust", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)")
450            ];
451
452        static LIB_TYPE: Lazy<Vec<String>> = Lazy::new(|| vec!["lib".into()]);
453
454        PackageDetails::new(
455            METADATA1_DATATEST,
456            "datatest",
457            "0.4.2",
458            vec!["Ivan Dubrov <ivan@commure.com>"],
459            Some("Data-driven tests in Rust\n"),
460            Some("MIT/Apache-2.0"),
461        )
462        .with_crates_io()
463        .with_build_targets(vec![
464            (
465                BuildTargetId::Library,
466                BuildTargetKind::LibraryOrExample(&LIB_TYPE),
467                "src/lib.rs",
468            ),
469            (
470                BuildTargetId::BuildScript,
471                BuildTargetKind::Binary,
472                "build.rs",
473            ),
474            (
475                BuildTargetId::Test("bench"),
476                BuildTargetKind::Binary,
477                "tests/bench.rs",
478            ),
479            (
480                BuildTargetId::Test("datatest"),
481                BuildTargetKind::Binary,
482                "tests/datatest.rs",
483            ),
484            (
485                BuildTargetId::Test("datatest_stable"),
486                BuildTargetKind::Binary,
487                "tests/datatest_stable.rs",
488            ),
489            (
490                BuildTargetId::Test("datatest_stable_unsafe"),
491                BuildTargetKind::Binary,
492                "tests/datatest_stable_unsafe.rs",
493            ),
494            (
495                BuildTargetId::Test("unicode"),
496                BuildTargetKind::Binary,
497                "tests/unicode.rs",
498            ),
499        ])
500        .with_deps(datatest_deps)
501        .with_reverse_deps(vec![("datatest", METADATA1_TESTCRATE)])
502        .insert_into(&mut details);
503
504        Self::new(details).with_workspace_members(vec![("", METADATA1_TESTCRATE)])
505    }
506
507    pub(crate) fn metadata2() -> Self {
508        let mut details = AHashMap::new();
509
510        PackageDetails::new(
511            METADATA2_TESTCRATE,
512            "testworkspace-crate",
513            "0.1.0",
514            vec![FAKE_AUTHOR],
515            None,
516            None,
517        )
518        .with_workspace_path("testcrate")
519        .with_deps(vec![
520            (
521                "datatest",
522                "datatest 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
523            ),
524            // There are three instances of walkdir in the dependencies -- ensure they all
525            // link up correctly.
526            ("walkdir", METADATA2_WALKDIR),
527            (
528                "walkdir-crates-io",
529                "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
530            ),
531            (
532                "walkdir-nuevo",
533                "walkdir 0.1.0 (path+file:///Users/fakeuser/local/walkdir)",
534            ),
535        ])
536        .with_reverse_deps(vec![])
537        .insert_into(&mut details);
538
539        PackageDetails::new(
540            METADATA2_WALKDIR,
541            "walkdir",
542            "2.2.9",
543            vec![FAKE_AUTHOR],
544            None,
545            None,
546        )
547        .with_workspace_path("walkdir")
548        .with_deps(vec![])
549        .with_reverse_deps(vec![("walkdir", METADATA2_TESTCRATE)])
550        .insert_into(&mut details);
551
552        // quote was replaced with [patch].
553        PackageDetails::new(
554            METADATA2_QUOTE,
555            "quote",
556            "1.0.2",
557            vec!["David Tolnay <dtolnay@gmail.com>"],
558            Some("Quasi-quoting macro quote!(...)"),
559            Some("MIT OR Apache-2.0"),
560        )
561        .with_local_path("../quote")
562        .with_deps(vec![(
563            "proc-macro2",
564            "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
565        )])
566        .with_reverse_deps(vec![
567            (
568                "quote",
569                "ctor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
570            ),
571            (
572                "quote",
573                "datatest-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
574            ),
575            (
576                "quote",
577                "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
578            ),
579        ])
580        .with_named_features(vec!["default", "proc-macro"])
581        .insert_into(&mut details);
582
583        Self::new(details).with_workspace_members(vec![
584            ("testcrate", METADATA2_TESTCRATE),
585            ("walkdir", METADATA2_WALKDIR),
586        ])
587    }
588
589    pub(crate) fn metadata_builddep() -> Self {
590        let details = AHashMap::new();
591
592        Self::new(details)
593    }
594
595    pub(crate) fn metadata_dups() -> Self {
596        let mut details = AHashMap::new();
597
598        PackageDetails::new(
599            METADATA_DUPS_TESTCRATE,
600            "testcrate-dups",
601            "0.1.0",
602            vec![FAKE_AUTHOR],
603            None,
604            None,
605        )
606        .with_workspace_path("")
607        .with_deps(vec![
608            ("lazy_static", METADATA_DUPS_LAZY_STATIC_1),
609            ("lazy_static", METADATA_DUPS_LAZY_STATIC_02),
610            ("bytes-package", METADATA_DUPS_BYTES_03),
611            ("bytes-package", METADATA_DUPS_BYTES_05),
612        ])
613        .insert_into(&mut details);
614
615        Self::new(details).with_workspace_members(vec![("", METADATA_DUPS_TESTCRATE)])
616    }
617
618    pub(crate) fn metadata_cycle1() -> Self {
619        let mut details = AHashMap::new();
620
621        PackageDetails::new(
622            METADATA_CYCLE1_BASE,
623            "testcycles-base",
624            "0.1.0",
625            vec![FAKE_AUTHOR],
626            None,
627            None,
628        )
629        .with_workspace_path("")
630        .with_deps(vec![("testcycles-helper", METADATA_CYCLE1_HELPER)])
631        .with_transitive_deps(vec![METADATA_CYCLE1_BASE, METADATA_CYCLE1_HELPER])
632        .with_transitive_reverse_deps(vec![METADATA_CYCLE1_BASE, METADATA_CYCLE1_HELPER])
633        .insert_into(&mut details);
634
635        PackageDetails::new(
636            METADATA_CYCLE1_HELPER,
637            "testcycles-helper",
638            "0.1.0",
639            vec![FAKE_AUTHOR],
640            None,
641            None,
642        )
643        .with_local_path("../testcycles-helper")
644        .with_deps(vec![("testcycles-base", METADATA_CYCLE1_BASE)])
645        .with_transitive_deps(vec![METADATA_CYCLE1_BASE, METADATA_CYCLE1_HELPER])
646        .with_transitive_reverse_deps(vec![METADATA_CYCLE1_BASE, METADATA_CYCLE1_HELPER])
647        .insert_into(&mut details);
648
649        Self::new(details)
650            .with_workspace_members(vec![("", METADATA_CYCLE1_BASE)])
651            .with_cycles(vec![vec![METADATA_CYCLE1_HELPER, METADATA_CYCLE1_BASE]])
652    }
653
654    pub(crate) fn metadata_cycle2() -> Self {
655        // upper-a <-> upper-b
656        //                |
657        //                v
658        //             lower-a <-> lower-b
659        let mut details = AHashMap::new();
660
661        // upper-a
662        PackageDetails::new(
663            METADATA_CYCLE2_UPPER_A,
664            "upper-a",
665            "0.1.0",
666            vec![FAKE_AUTHOR],
667            None,
668            None,
669        )
670        .with_workspace_path("upper-a")
671        .with_deps(vec![("upper-b", METADATA_CYCLE2_UPPER_B)])
672        .with_reverse_deps(vec![("upper-a", METADATA_CYCLE2_UPPER_B)])
673        .with_transitive_deps(vec![
674            METADATA_CYCLE2_UPPER_A,
675            METADATA_CYCLE2_UPPER_B,
676            METADATA_CYCLE2_LOWER_A,
677            METADATA_CYCLE2_LOWER_B,
678        ])
679        .with_transitive_reverse_deps(vec![METADATA_CYCLE2_UPPER_A, METADATA_CYCLE2_UPPER_B])
680        .insert_into(&mut details);
681
682        // upper-b
683        PackageDetails::new(
684            METADATA_CYCLE2_UPPER_B,
685            "upper-b",
686            "0.1.0",
687            vec![FAKE_AUTHOR],
688            None,
689            None,
690        )
691        .with_workspace_path("upper-b")
692        .with_deps(vec![
693            ("upper-a", METADATA_CYCLE2_UPPER_A),
694            ("lower-a", METADATA_CYCLE2_LOWER_A),
695        ])
696        .with_reverse_deps(vec![("upper-b", METADATA_CYCLE2_UPPER_A)])
697        .with_transitive_deps(vec![
698            METADATA_CYCLE2_UPPER_A,
699            METADATA_CYCLE2_UPPER_B,
700            METADATA_CYCLE2_LOWER_A,
701            METADATA_CYCLE2_LOWER_B,
702        ])
703        .with_transitive_reverse_deps(vec![METADATA_CYCLE2_UPPER_A, METADATA_CYCLE2_UPPER_B])
704        .insert_into(&mut details);
705
706        // lower-a
707        PackageDetails::new(
708            METADATA_CYCLE2_LOWER_A,
709            "lower-a",
710            "0.1.0",
711            vec![FAKE_AUTHOR],
712            None,
713            None,
714        )
715        .with_workspace_path("lower-a")
716        .with_deps(vec![("lower-b", METADATA_CYCLE2_LOWER_B)])
717        .with_reverse_deps(vec![
718            ("lower-a", METADATA_CYCLE2_UPPER_B),
719            ("lower-a", METADATA_CYCLE2_LOWER_B),
720        ])
721        .with_transitive_deps(vec![METADATA_CYCLE2_LOWER_A, METADATA_CYCLE2_LOWER_B])
722        .with_transitive_reverse_deps(vec![
723            METADATA_CYCLE2_UPPER_A,
724            METADATA_CYCLE2_UPPER_B,
725            METADATA_CYCLE2_LOWER_A,
726            METADATA_CYCLE2_LOWER_B,
727        ])
728        .insert_into(&mut details);
729
730        // lower-b
731        PackageDetails::new(
732            METADATA_CYCLE2_LOWER_B,
733            "lower-b",
734            "0.1.0",
735            vec![FAKE_AUTHOR],
736            None,
737            None,
738        )
739        .with_workspace_path("lower-b")
740        .with_deps(vec![("lower-a", METADATA_CYCLE2_LOWER_A)])
741        .with_reverse_deps(vec![("lower-b", METADATA_CYCLE2_LOWER_A)])
742        .with_transitive_deps(vec![METADATA_CYCLE2_LOWER_A, METADATA_CYCLE2_LOWER_B])
743        .with_transitive_reverse_deps(vec![
744            METADATA_CYCLE2_UPPER_A,
745            METADATA_CYCLE2_UPPER_B,
746            METADATA_CYCLE2_LOWER_A,
747            METADATA_CYCLE2_LOWER_B,
748        ])
749        .insert_into(&mut details);
750
751        Self::new(details)
752            .with_workspace_members(vec![
753                ("upper-a", METADATA_CYCLE2_UPPER_A),
754                ("upper-b", METADATA_CYCLE2_UPPER_B),
755                ("lower-a", METADATA_CYCLE2_LOWER_A),
756                ("lower-b", METADATA_CYCLE2_LOWER_B),
757            ])
758            .with_cycles(vec![
759                // upper-b dev-depends on upper-a, and upper-a normal-depends on upper-b.
760                vec![METADATA_CYCLE2_UPPER_A, METADATA_CYCLE2_UPPER_B],
761                // lower-b dev-depends on lower-a, and lower-a normal-depends on lower-b.
762                vec![METADATA_CYCLE2_LOWER_A, METADATA_CYCLE2_LOWER_B],
763            ])
764    }
765
766    pub(crate) fn metadata_cycle_features() -> Self {
767        let details = AHashMap::new();
768
769        Self::new(details)
770            .with_workspace_members(vec![
771                ("testcycles-base", METADATA_CYCLE_FEATURES_BASE),
772                ("testcycles-helper", METADATA_CYCLE_FEATURES_HELPER),
773            ])
774            .with_cycles(vec![vec![
775                METADATA_CYCLE_FEATURES_HELPER,
776                METADATA_CYCLE_FEATURES_BASE,
777            ]])
778    }
779
780    pub(crate) fn metadata_targets1() -> Self {
781        // In the testcrate:
782        //
783        // ```
784        // [dependencies]
785        // lazy_static = "1"
786        // bytes = { version = "0.5", default-features = false, features = ["serde"] }
787        // dep-a = { path = "../dep-a", optional = true }
788        //
789        // [target.'cfg(not(windows))'.dependencies]
790        // lazy_static = "0.2"
791        // dep-a = { path = "../dep-a", features = ["foo"] }
792        //
793        // [target.'cfg(windows)'.dev-dependencies]
794        // lazy_static = "0.1"
795        //
796        // [target.'cfg(target_arch = "x86")'.dependencies]
797        // bytes = { version = "=0.5.3", optional = false }
798        // dep-a = { path = "../dep-a", features = ["bar"] }
799        //
800        // [target.x86_64-unknown-linux-gnu.build-dependencies]
801        // bytes = { version = "0.5.2", optional = true, default-features = false, features = ["std"] }
802        //
803        // # Platform-specific dev-dependencies.
804        //
805        // [target.'cfg(any(target_feature = "sse2", target_feature = "atomics"))'.dev-dependencies]
806        // dep-a = { path = "../dep-a", default-features = false, features = ["baz"] }
807        //
808        // [target.'cfg(all(unix, not(target_feature = "sse")))'.dev-dependencies]
809        // dep-a = { path = "../dep-a" }
810        //
811        // [target.'cfg(any(unix, target_feature = "sse"))'.dev-dependencies]
812        // dep-a = { path = "../dep-a", default-features = false, features = ["quux"] }
813        //
814        // # Platform-specific build dependencies.
815        //
816        // [target.'cfg(target_feature = "sse")'.build-dependencies]
817        // dep-a = { path = "../dep-a", default-features = false, features = ["foo"] }
818        //
819        // # any -- evaluates to true for unix.
820        // [target.'cfg(any(unix, target_feature = "sse"))'.build-dependencies]
821        // dep-a = { path = "../dep-a", optional = true, default-features = true }
822        //
823        // # all -- evaluates to unknown on unixes if the target features are unknown.
824        // # Evaluates to false on Windows whether target features are known or not.
825        // [target.'cfg(all(unix, target_feature = "sse"))'.build-dependencies]
826        // dep-a = { path = "../dep-a", optional = true, default-features = false, features = ["bar"] }
827        // ```
828        let mut details = AHashMap::new();
829
830        PackageDetails::new(
831            METADATA_TARGETS1_TESTCRATE,
832            "testcrate-targets",
833            "0.1.0",
834            vec![FAKE_AUTHOR],
835            None,
836            None,
837        )
838        .with_workspace_path("")
839        .with_deps(vec![
840            ("lazy_static", METADATA_TARGETS1_LAZY_STATIC_1),
841            ("lazy_static", METADATA_TARGETS1_LAZY_STATIC_02),
842            ("lazy_static", METADATA_TARGETS1_LAZY_STATIC_01),
843            ("bytes", METADATA_TARGETS1_BYTES),
844            ("dep-a", METADATA_TARGETS1_DEP_A),
845        ])
846        .insert_into(&mut details);
847
848        let x86_64_linux =
849            Platform::new("x86_64-unknown-linux-gnu", TargetFeatures::Unknown).unwrap();
850        let i686_windows = Platform::new(
851            "i686-pc-windows-msvc",
852            TargetFeatures::features(["sse", "sse2"].iter().copied()),
853        )
854        .unwrap();
855        let x86_64_windows =
856            Platform::new("x86_64-pc-windows-msvc", TargetFeatures::Unknown).unwrap();
857
858        let mut link_details = AHashMap::new();
859
860        use EnabledTernary::*;
861
862        // testcrate -> lazy_static 1.
863        LinkDetails::new(
864            package_id(METADATA_TARGETS1_TESTCRATE),
865            package_id(METADATA_TARGETS1_LAZY_STATIC_1),
866        )
867        .with_platform_status(
868            DependencyKind::Normal,
869            x86_64_linux.clone(),
870            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled)),
871        )
872        .with_platform_status(
873            DependencyKind::Normal,
874            i686_windows.clone(),
875            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled)),
876        )
877        .insert_into(&mut link_details);
878
879        // testcrate -> lazy_static 0.2.
880        // Included on not-Windows.
881        LinkDetails::new(
882            package_id(METADATA_TARGETS1_TESTCRATE),
883            package_id(METADATA_TARGETS1_LAZY_STATIC_02),
884        )
885        .with_platform_status(
886            DependencyKind::Normal,
887            x86_64_linux.clone(),
888            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled)),
889        )
890        .with_platform_status(
891            DependencyKind::Normal,
892            i686_windows.clone(),
893            PlatformResults::new((Disabled, Disabled), (Disabled, Disabled)),
894        )
895        .insert_into(&mut link_details);
896
897        // testcrate -> lazy_static 0.1.
898        // Included as a dev-dependency on Windows.
899        LinkDetails::new(
900            package_id(METADATA_TARGETS1_TESTCRATE),
901            package_id(METADATA_TARGETS1_LAZY_STATIC_01),
902        )
903        .with_platform_status(
904            DependencyKind::Development,
905            x86_64_linux.clone(),
906            PlatformResults::new((Disabled, Disabled), (Disabled, Disabled)),
907        )
908        .with_platform_status(
909            DependencyKind::Development,
910            i686_windows.clone(),
911            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled)),
912        )
913        .insert_into(&mut link_details);
914
915        // testcrate -> bytes.
916        // As a normal dependency, this is always built but default-features varies.
917        // As a build dependency, it is only present on Linux.
918        LinkDetails::new(
919            package_id(METADATA_TARGETS1_TESTCRATE),
920            package_id(METADATA_TARGETS1_BYTES),
921        )
922        .with_platform_status(
923            DependencyKind::Normal,
924            x86_64_linux.clone(),
925            PlatformResults::new((Enabled, Enabled), (Disabled, Disabled))
926                .with_feature_status("serde", (Enabled, Enabled))
927                .with_feature_status("std", (Disabled, Disabled)),
928        )
929        .with_platform_status(
930            DependencyKind::Normal,
931            i686_windows.clone(),
932            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled))
933                .with_feature_status("serde", (Enabled, Enabled))
934                .with_feature_status("std", (Disabled, Disabled)),
935        )
936        .with_features(DependencyKind::Normal, vec!["serde"])
937        .with_platform_status(
938            DependencyKind::Build,
939            x86_64_linux.clone(),
940            PlatformResults::new((Disabled, Enabled), (Disabled, Disabled))
941                .with_feature_status("serde", (Disabled, Disabled))
942                .with_feature_status("std", (Disabled, Enabled)),
943        )
944        .with_platform_status(
945            DependencyKind::Build,
946            i686_windows.clone(),
947            PlatformResults::new((Disabled, Disabled), (Disabled, Disabled))
948                .with_feature_status("serde", (Disabled, Disabled))
949                .with_feature_status("std", (Disabled, Disabled)),
950        )
951        .with_features(DependencyKind::Build, vec!["std"])
952        .insert_into(&mut link_details);
953
954        // testcrate -> dep-a.
955        // As a normal dependency, this is optionally built by default, but on not-Windows or on x86
956        // it is required.
957        // As a dev dependency, it is present if sse2 or atomics are turned on.
958        LinkDetails::new(
959            package_id(METADATA_TARGETS1_TESTCRATE),
960            package_id(METADATA_TARGETS1_DEP_A),
961        )
962        .with_platform_status(
963            DependencyKind::Normal,
964            x86_64_linux.clone(),
965            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled))
966                .with_feature_status("foo", (Enabled, Enabled))
967                .with_feature_status("bar", (Disabled, Disabled))
968                .with_feature_status("baz", (Disabled, Disabled))
969                .with_feature_status("quux", (Disabled, Disabled)),
970        )
971        .with_platform_status(
972            DependencyKind::Normal,
973            i686_windows.clone(),
974            PlatformResults::new((Enabled, Enabled), (Enabled, Enabled))
975                .with_feature_status("foo", (Disabled, Disabled))
976                .with_feature_status("bar", (Enabled, Enabled))
977                .with_feature_status("baz", (Disabled, Disabled))
978                .with_feature_status("quux", (Disabled, Disabled)),
979        )
980        .with_platform_status(
981            DependencyKind::Normal,
982            x86_64_windows.clone(),
983            PlatformResults::new((Disabled, Enabled), (Disabled, Enabled))
984                .with_feature_status("foo", (Disabled, Disabled))
985                .with_feature_status("bar", (Disabled, Disabled))
986                .with_feature_status("baz", (Disabled, Disabled))
987                .with_feature_status("quux", (Disabled, Disabled)),
988        )
989        .with_platform_status(
990            DependencyKind::Development,
991            x86_64_linux.clone(),
992            // x86_64_linux uses TargetFeature::Unknown.
993            PlatformResults::new((Enabled, Enabled), (Unknown, Unknown))
994                .with_feature_status("foo", (Disabled, Disabled))
995                .with_feature_status("bar", (Disabled, Disabled))
996                .with_feature_status("baz", (Unknown, Unknown))
997                .with_feature_status("quux", (Enabled, Enabled)),
998        )
999        .with_platform_status(
1000            DependencyKind::Development,
1001            i686_windows.clone(),
1002            // i686_windows turns on sse and sse2.
1003            PlatformResults::new((Enabled, Enabled), (Disabled, Disabled))
1004                .with_feature_status("foo", (Disabled, Disabled))
1005                .with_feature_status("bar", (Disabled, Disabled))
1006                .with_feature_status("baz", (Enabled, Enabled))
1007                .with_feature_status("quux", (Enabled, Enabled)),
1008        )
1009        .with_platform_status(
1010            DependencyKind::Development,
1011            x86_64_windows.clone(),
1012            // x86_64_windows uses TargetFeatures::Unknown.
1013            PlatformResults::new((Unknown, Unknown), (Disabled, Disabled))
1014                .with_feature_status("foo", (Disabled, Disabled))
1015                .with_feature_status("bar", (Disabled, Disabled))
1016                .with_feature_status("baz", (Unknown, Unknown))
1017                .with_feature_status("quux", (Unknown, Unknown)),
1018        )
1019        .with_platform_status(
1020            DependencyKind::Build,
1021            x86_64_linux.clone(),
1022            // x86_64_linux uses TargetFeature::Unknown.
1023            PlatformResults::new((Unknown, Enabled), (Disabled, Enabled))
1024                .with_feature_status("foo", (Unknown, Unknown))
1025                .with_feature_status("bar", (Disabled, Unknown))
1026                .with_feature_status("baz", (Disabled, Disabled))
1027                .with_feature_status("quux", (Disabled, Disabled)),
1028        )
1029        .with_platform_status(
1030            DependencyKind::Build,
1031            i686_windows.clone(),
1032            // i686_windows turns on sse and sse2.
1033            PlatformResults::new((Enabled, Enabled), (Disabled, Enabled))
1034                .with_feature_status("foo", (Enabled, Enabled))
1035                .with_feature_status("bar", (Disabled, Disabled))
1036                .with_feature_status("baz", (Disabled, Disabled))
1037                .with_feature_status("quux", (Disabled, Disabled)),
1038        )
1039        .with_platform_status(
1040            DependencyKind::Build,
1041            x86_64_windows.clone(),
1042            // x86_64_windows uses TargetFeatures::Unknown.
1043            PlatformResults::new((Unknown, Unknown), (Disabled, Unknown))
1044                .with_feature_status("foo", (Unknown, Unknown))
1045                .with_feature_status("bar", (Disabled, Disabled))
1046                .with_feature_status("baz", (Disabled, Disabled))
1047                .with_feature_status("quux", (Disabled, Disabled)),
1048        )
1049        .insert_into(&mut link_details);
1050
1051        Self::new(details)
1052            .with_workspace_members(vec![("", METADATA_TARGETS1_TESTCRATE)])
1053            .with_link_details(link_details)
1054    }
1055
1056    pub(crate) fn metadata_build_targets1() -> Self {
1057        // [package]
1058        // name = "testcrate"
1059        // version = "0.1.0"
1060        // authors = ["Fake Author <fakeauthor@example.com>"]
1061        // edition = "2018"
1062        // build = "build.rs"
1063        //
1064        // [lib]
1065        // name = "bench1"
1066        // crate-type = ["cdylib", "bin"]
1067        //
1068        // [[bench]]
1069        // name = "bench1"
1070        // path = "src/main.rs"
1071        //
1072        // [[bench]]
1073        // name = "bench2"
1074        // path = "src/main2.rs"
1075        //
1076        // [[example]]
1077        // name = "example1"
1078        // path = "src/lib.rs"
1079        // crate-type = ["rlib", "dylib"]
1080
1081        let mut details = AHashMap::new();
1082
1083        static BIN_CDYLIB_TYPES: Lazy<Vec<String>> =
1084            Lazy::new(|| vec!["bin".into(), "cdylib".into()]);
1085        static DYLIB_RLIB_TYPES: Lazy<Vec<String>> =
1086            Lazy::new(|| vec!["dylib".into(), "rlib".into()]);
1087
1088        PackageDetails::new(
1089            METADATA_BUILD_TARGETS1_TESTCRATE,
1090            "testcrate",
1091            "0.1.0",
1092            vec![FAKE_AUTHOR],
1093            None,
1094            None,
1095        )
1096        .with_workspace_path("")
1097        .with_build_targets(vec![
1098            (
1099                BuildTargetId::Library,
1100                BuildTargetKind::LibraryOrExample(&BIN_CDYLIB_TYPES),
1101                "src/lib.rs",
1102            ),
1103            (
1104                BuildTargetId::BuildScript,
1105                BuildTargetKind::Binary,
1106                "build.rs",
1107            ),
1108            (
1109                BuildTargetId::Binary("testcrate"),
1110                BuildTargetKind::Binary,
1111                "src/main.rs",
1112            ),
1113            (
1114                BuildTargetId::Example("example1"),
1115                BuildTargetKind::LibraryOrExample(&DYLIB_RLIB_TYPES),
1116                "src/lib.rs",
1117            ),
1118            (
1119                BuildTargetId::Benchmark("bench1"),
1120                BuildTargetKind::Binary,
1121                "src/main.rs",
1122            ),
1123            (
1124                BuildTargetId::Benchmark("bench2"),
1125                BuildTargetKind::Binary,
1126                "src/main2.rs",
1127            ),
1128        ])
1129        .insert_into(&mut details);
1130
1131        Self::new(details)
1132    }
1133
1134    pub(crate) fn metadata_proc_macro1() -> Self {
1135        let mut details = AHashMap::new();
1136
1137        PackageDetails::new(
1138            METADATA_PROC_MACRO1_MACRO,
1139            "macro",
1140            "0.1.0",
1141            vec![FAKE_AUTHOR],
1142            None,
1143            None,
1144        )
1145        .with_workspace_path("macro")
1146        .with_reverse_deps(vec![
1147            ("macro", METADATA_PROC_MACRO1_NORMAL_USER),
1148            ("macro", METADATA_PROC_MACRO1_BUILD_USER),
1149            ("macro", METADATA_PROC_MACRO1_DEV_USER),
1150        ])
1151        .insert_into(&mut details);
1152
1153        Self::new(details)
1154    }
1155
1156    pub(crate) fn metadata_alternate_registries() -> Self {
1157        let details = AHashMap::new();
1158        Self::new(details)
1159    }
1160
1161    pub(crate) fn metadata_weak_namespaced_features() -> Self {
1162        let details = AHashMap::new();
1163        Self::new(details)
1164    }
1165
1166    pub(crate) fn metadata_libra() -> Self {
1167        let mut details = AHashMap::new();
1168
1169        PackageDetails::new(
1170            METADATA_LIBRA_E2E_TESTS,
1171            "language-e2e-tests",
1172            "0.1.0",
1173            vec!["Libra Association <opensource@libra.org>"],
1174            Some("Libra language e2e tests"),
1175            Some("Apache-2.0"),
1176        )
1177        .with_workspace_path("language/e2e-tests")
1178        .with_transitive_reverse_deps(vec![
1179            METADATA_LIBRA_E2E_TESTS,
1180            METADATA_LIBRA_COST_SYNTHESIS,
1181            METADATA_LIBRA_FUNCTIONAL_TESTS,
1182            METADATA_LIBRA_TEST_GENERATION,
1183            METADATA_LIBRA_LANGUAGE_BENCHMARKS,
1184            METADATA_LIBRA_TREE_HEAP,
1185        ])
1186        .insert_into(&mut details);
1187
1188        PackageDetails::new(
1189            METADATA_LIBRA_LAZY_STATIC,
1190            "lazy_static",
1191            "1.4.0",
1192            vec!["Marvin Löbel <loebel.marvin@gmail.com>"],
1193            Some("A macro for declaring lazily evaluated statics in Rust."),
1194            Some("MIT/Apache-2.0"),
1195        )
1196        .with_crates_io()
1197        .with_transitive_deps(vec![
1198            METADATA_LIBRA_LAZY_STATIC,
1199            "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
1200            // lazy_static also has doc-comment as a dev-dependency, but that isn't part of the
1201            // resolved graph so it won't appear here.
1202        ])
1203        .insert_into(&mut details);
1204
1205        #[rustfmt::skip]
1206        let workspace_members = vec![
1207            ("admission_control/admission-control-proto", "admission-control-proto 0.1.0 (path+file:///Users/fakeuser/local/libra/admission_control/admission-control-proto)"),
1208            ("admission_control/admission-control-service", METADATA_LIBRA_ADMISSION_CONTROL_SERVICE),
1209            ("benchmark", "benchmark 0.1.0 (path+file:///Users/fakeuser/local/libra/benchmark)"),
1210            ("client", "client 0.1.0 (path+file:///Users/fakeuser/local/libra/client)"),
1211            ("client/libra_wallet", "libra-wallet 0.1.0 (path+file:///Users/fakeuser/local/libra/client/libra_wallet)"),
1212            ("common/bounded-executor", "bounded-executor 0.1.0 (path+file:///Users/fakeuser/local/libra/common/bounded-executor)"),
1213            ("common/channel", "channel 0.1.0 (path+file:///Users/fakeuser/local/libra/common/channel)"),
1214            ("common/crash-handler", "crash-handler 0.1.0 (path+file:///Users/fakeuser/local/libra/common/crash-handler)"),
1215            ("common/datatest-stable", "datatest-stable 0.1.0 (path+file:///Users/fakeuser/local/libra/common/datatest-stable)"),
1216            ("common/debug-interface", "debug-interface 0.1.0 (path+file:///Users/fakeuser/local/libra/common/debug-interface)"),
1217            ("common/executable-helpers", "executable-helpers 0.1.0 (path+file:///Users/fakeuser/local/libra/common/executable-helpers)"),
1218            ("common/failure-ext", "libra-failure-ext 0.1.0 (path+file:///Users/fakeuser/local/libra/common/failure-ext)"),
1219            ("common/failure-ext/failure-macros", "libra-failure-macros 0.1.0 (path+file:///Users/fakeuser/local/libra/common/failure-ext/failure-macros)"),
1220            ("common/futures-semaphore", "futures-semaphore 0.1.0 (path+file:///Users/fakeuser/local/libra/common/futures-semaphore)"),
1221            ("common/grpc-helpers", "grpc-helpers 0.1.0 (path+file:///Users/fakeuser/local/libra/common/grpc-helpers)"),
1222            ("common/lcs", "libra-canonical-serialization 0.1.0 (path+file:///Users/fakeuser/local/libra/common/lcs)"),
1223            ("common/logger", "libra-logger 0.1.0 (path+file:///Users/fakeuser/local/libra/common/logger)"),
1224            ("common/metrics", "libra-metrics 0.1.0 (path+file:///Users/fakeuser/local/libra/common/metrics)"),
1225            ("common/nibble", "libra-nibble 0.1.0 (path+file:///Users/fakeuser/local/libra/common/nibble)"),
1226            ("common/proptest-helpers", "libra-proptest-helpers 0.1.0 (path+file:///Users/fakeuser/local/libra/common/proptest-helpers)"),
1227            ("common/prost-ext", "libra-prost-ext 0.1.0 (path+file:///Users/fakeuser/local/libra/common/prost-ext)"),
1228            ("common/tools", "libra-tools 0.1.0 (path+file:///Users/fakeuser/local/libra/common/tools)"),
1229            ("config", "libra-config 0.1.0 (path+file:///Users/fakeuser/local/libra/config)"),
1230            ("config/config-builder", "config-builder 0.1.0 (path+file:///Users/fakeuser/local/libra/config/config-builder)"),
1231            ("config/generate-keypair", "generate-keypair 0.1.0 (path+file:///Users/fakeuser/local/libra/config/generate-keypair)"),
1232            ("consensus", "consensus 0.1.0 (path+file:///Users/fakeuser/local/libra/consensus)"),
1233            ("consensus/consensus-types", "consensus-types 0.1.0 (path+file:///Users/fakeuser/local/libra/consensus/consensus-types)"),
1234            ("consensus/safety-rules", "safety-rules 0.1.0 (path+file:///Users/fakeuser/local/libra/consensus/safety-rules)"),
1235            ("crypto/crypto", "libra-crypto 0.1.0 (path+file:///Users/fakeuser/local/libra/crypto/crypto)"),
1236            ("crypto/crypto-derive", "libra-crypto-derive 0.1.0 (path+file:///Users/fakeuser/local/libra/crypto/crypto-derive)"),
1237            ("crypto/secret-service", "secret-service 0.1.0 (path+file:///Users/fakeuser/local/libra/crypto/secret-service)"),
1238            ("executor", "executor 0.1.0 (path+file:///Users/fakeuser/local/libra/executor)"),
1239            ("language/benchmarks", METADATA_LIBRA_LANGUAGE_BENCHMARKS),
1240            ("language/bytecode-verifier", "bytecode-verifier 0.1.0 (path+file:///Users/fakeuser/local/libra/language/bytecode-verifier)"),
1241            ("language/bytecode-verifier/bytecode_verifier_tests", "bytecode_verifier_tests 0.1.0 (path+file:///Users/fakeuser/local/libra/language/bytecode-verifier/bytecode_verifier_tests)"),
1242            ("language/bytecode-verifier/invalid-mutations", "invalid-mutations 0.1.0 (path+file:///Users/fakeuser/local/libra/language/bytecode-verifier/invalid-mutations)"),
1243            ("language/compiler", METADATA_LIBRA_COMPILER),
1244            ("language/compiler/bytecode-source-map", "bytecode-source-map 0.1.0 (path+file:///Users/fakeuser/local/libra/language/compiler/bytecode-source-map)"),
1245            ("language/compiler/ir-to-bytecode", "ir-to-bytecode 0.1.0 (path+file:///Users/fakeuser/local/libra/language/compiler/ir-to-bytecode)"),
1246            ("language/compiler/ir-to-bytecode/syntax", "ir-to-bytecode-syntax 0.1.0 (path+file:///Users/fakeuser/local/libra/language/compiler/ir-to-bytecode/syntax)"),
1247            ("language/e2e-tests", METADATA_LIBRA_E2E_TESTS),
1248            ("language/functional_tests", METADATA_LIBRA_FUNCTIONAL_TESTS),
1249            ("language/stackless-bytecode/bytecode-to-boogie", "bytecode-to-boogie 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stackless-bytecode/bytecode-to-boogie)"),
1250            ("language/stackless-bytecode/generator", "stackless-bytecode-generator 0.1.0 (path+file:///Users/fakeuser/local/libra/language/stackless-bytecode/generator)"),
1251            ("language/stackless-bytecode/tree_heap", METADATA_LIBRA_TREE_HEAP),
1252            ("language/stdlib", METADATA_LIBRA_STDLIB),
1253            ("language/tools/cost-synthesis", METADATA_LIBRA_COST_SYNTHESIS),
1254            ("language/tools/test-generation", METADATA_LIBRA_TEST_GENERATION),
1255            ("language/transaction-builder", METADATA_LIBRA_TRANSACTION_BUILDER),
1256            ("language/vm", "vm 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm)"),
1257            ("language/vm/serializer_tests", "serializer_tests 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm/serializer_tests)"),
1258            ("language/vm/vm-genesis", "vm-genesis 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm/vm-genesis)"),
1259            ("language/vm/vm-runtime", "vm-runtime 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm/vm-runtime)"),
1260            ("language/vm/vm-runtime/vm-cache-map", "vm-cache-map 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm/vm-runtime/vm-cache-map)"),
1261            ("language/vm/vm-runtime/vm-runtime-types", "vm-runtime-types 0.1.0 (path+file:///Users/fakeuser/local/libra/language/vm/vm-runtime/vm-runtime-types)"),
1262            ("libra-node", "libra-node 0.1.0 (path+file:///Users/fakeuser/local/libra/libra-node)"),
1263            ("libra-swarm", "libra-swarm 0.1.0 (path+file:///Users/fakeuser/local/libra/libra-swarm)"),
1264            ("mempool", "libra-mempool 0.1.0 (path+file:///Users/fakeuser/local/libra/mempool)"),
1265            ("mempool/mempool-shared-proto", "libra-mempool-shared-proto 0.1.0 (path+file:///Users/fakeuser/local/libra/mempool/mempool-shared-proto)"),
1266            ("network", "network 0.1.0 (path+file:///Users/fakeuser/local/libra/network)"),
1267            ("network/memsocket", "memsocket 0.1.0 (path+file:///Users/fakeuser/local/libra/network/memsocket)"),
1268            ("network/netcore", "netcore 0.1.0 (path+file:///Users/fakeuser/local/libra/network/netcore)"),
1269            ("network/noise", "noise 0.1.0 (path+file:///Users/fakeuser/local/libra/network/noise)"),
1270            ("network/socket-bench-server", "socket-bench-server 0.1.0 (path+file:///Users/fakeuser/local/libra/network/socket-bench-server)"),
1271            ("state-synchronizer", "state-synchronizer 0.1.0 (path+file:///Users/fakeuser/local/libra/state-synchronizer)"),
1272            ("storage/accumulator", "accumulator 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/accumulator)"),
1273            ("storage/jellyfish-merkle", "jellyfish-merkle 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/jellyfish-merkle)"),
1274            ("storage/libradb", "libradb 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/libradb)"),
1275            ("storage/schemadb", "schemadb 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/schemadb)"),
1276            ("storage/scratchpad", "scratchpad 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/scratchpad)"),
1277            ("storage/state-view", "libra-state-view 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/state-view)"),
1278            ("storage/storage-client", "storage-client 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/storage-client)"),
1279            ("storage/storage-proto", "storage-proto 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/storage-proto)"),
1280            ("storage/storage-service", "storage-service 0.1.0 (path+file:///Users/fakeuser/local/libra/storage/storage-service)"),
1281            ("testsuite", "testsuite 0.1.0 (path+file:///Users/fakeuser/local/libra/testsuite)"),
1282            ("testsuite/cluster-test", "cluster-test 0.1.0 (path+file:///Users/fakeuser/local/libra/testsuite/cluster-test)"),
1283            ("testsuite/libra-fuzzer", "libra-fuzzer 0.1.0 (path+file:///Users/fakeuser/local/libra/testsuite/libra-fuzzer)"),
1284            ("types", "libra-types 0.1.0 (path+file:///Users/fakeuser/local/libra/types)"),
1285            ("vm-validator", "vm-validator 0.1.0 (path+file:///Users/fakeuser/local/libra/vm-validator)"),
1286            ("x", "x 0.1.0 (path+file:///Users/fakeuser/local/libra/x)"),
1287        ];
1288
1289        Self::new(details)
1290            .with_workspace_members(workspace_members)
1291            .with_feature_graph_warnings(vec![
1292                // See https://github.com/alexcrichton/cfg-if/issues/22 for more.
1293                FeatureGraphWarning::MissingFeature {
1294                    stage: FeatureBuildStage::AddNamedFeatureEdges {
1295                        package_id: package_id(METADATA_LIBRA_BACKTRACE),
1296                        from_feature: "rustc-dep-of-std".to_string(),
1297                    },
1298                    package_id: package_id(METADATA_LIBRA_CFG_IF),
1299                    feature_name: "rustc-dep-of-std".to_string(),
1300                },
1301            ])
1302    }
1303
1304    pub(crate) fn metadata_libra_f0091a4() -> Self {
1305        let details = AHashMap::new();
1306
1307        Self::new(details).with_cycles(vec![vec![
1308            METADATA_LIBRA_FUNCTIONAL_HYPHEN_TESTS,
1309            METADATA_LIBRA_E2E_TESTS,
1310            METADATA_LIBRA_VM_GENESIS,
1311            METADATA_LIBRA_MOVE_LANG_STDLIB,
1312            METADATA_LIBRA_MOVE_LANG,
1313        ]])
1314    }
1315
1316    pub(crate) fn metadata_libra_9ffd93b() -> Self {
1317        let details = AHashMap::new();
1318
1319        Self::new(details).with_cycles(vec![
1320            vec![METADATA_LIBRA_EXECUTOR_UTILS, METADATA_LIBRA_EXECUTOR],
1321            vec![
1322                METADATA_LIBRA_FUNCTIONAL_HYPHEN_TESTS,
1323                METADATA_LIBRA_E2E_TESTS,
1324                METADATA_LIBRA_VM_GENESIS,
1325                METADATA_LIBRA_TRANSACTION_BUILDER,
1326                METADATA_LIBRA_LIBRA_VM,
1327                METADATA_LIBRA_MOVE_VM_RUNTIME,
1328                METADATA_LIBRA_COMPILER,
1329                METADATA_LIBRA_STDLIB,
1330                METADATA_LIBRA_MOVE_LANG,
1331            ],
1332        ])
1333    }
1334
1335    pub(crate) fn mnemos_b3b4da9() -> Self {
1336        let details = AHashMap::new();
1337
1338        Self::new(details)
1339    }
1340
1341    pub(crate) fn hyper_util_7afb1ed() -> Self {
1342        let details = AHashMap::new();
1343
1344        Self::new(details)
1345    }
1346
1347    pub(crate) fn metadata_guppy_78cb7e8() -> Self {
1348        let details = AHashMap::new();
1349
1350        Self::new(details)
1351    }
1352
1353    pub(crate) fn metadata_guppy_869476c() -> Self {
1354        let details = AHashMap::new();
1355
1356        Self::new(details)
1357    }
1358
1359    pub(crate) fn metadata_guppy_c9b4f76() -> Self {
1360        let details = AHashMap::new();
1361
1362        Self::new(details)
1363    }
1364
1365    pub(crate) fn metadata_guppy_44b62fa() -> Self {
1366        let details = AHashMap::new();
1367
1368        Self::new(details)
1369    }
1370}