fixture_data/
nextest_tests.rs

1// Copyright (c) The nextest Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Information about the "nextest-tests" fixture.
5//!
6//! TODO: need a better name than "nextest-tests".
7
8use crate::models::{
9    TestCaseFixture, TestCaseFixtureProperty, TestCaseFixtureStatus, TestSuiteFixture,
10    TestSuiteFixtureProperty,
11};
12use iddqd::{IdOrdMap, id_ord_map};
13use nextest_metadata::{BuildPlatform, RustBinaryId};
14use std::sync::LazyLock;
15
16pub static EXPECTED_TEST_SUITES: LazyLock<IdOrdMap<TestSuiteFixture>> = LazyLock::new(|| {
17    id_ord_map! {
18        // Integration tests
19        TestSuiteFixture::new(
20            "nextest-tests::basic",
21            "basic",
22            BuildPlatform::Target,
23            id_ord_map! {
24                TestCaseFixture::new("test_cargo_env_vars", TestCaseFixtureStatus::Pass)
25                    .with_property(TestCaseFixtureProperty::NotInDefaultSetUnix),
26                TestCaseFixture::new("test_cwd", TestCaseFixtureStatus::Pass),
27                TestCaseFixture::new("test_execute_bin", TestCaseFixtureStatus::Pass),
28                TestCaseFixture::new("test_failure_assert", TestCaseFixtureStatus::Fail),
29                TestCaseFixture::new("test_failure_error", TestCaseFixtureStatus::Fail),
30                TestCaseFixture::new("test_failure_should_panic", TestCaseFixtureStatus::Fail),
31                TestCaseFixture::new(
32                    "test_flaky_mod_4",
33                    TestCaseFixtureStatus::Flaky { pass_attempt: 4 },
34                )
35                .with_property(TestCaseFixtureProperty::NotInDefaultSet),
36                TestCaseFixture::new(
37                    "test_flaky_mod_6",
38                    TestCaseFixtureStatus::Flaky { pass_attempt: 6 },
39                )
40                .with_property(TestCaseFixtureProperty::NotInDefaultSet),
41                TestCaseFixture::new("test_ignored", TestCaseFixtureStatus::IgnoredPass),
42                TestCaseFixture::new("test_ignored_fail", TestCaseFixtureStatus::IgnoredFail),
43                TestCaseFixture::new("test_result_failure", TestCaseFixtureStatus::Fail),
44                TestCaseFixture::new("test_slow_timeout", TestCaseFixtureStatus::IgnoredPass),
45                TestCaseFixture::new("test_slow_timeout_2", TestCaseFixtureStatus::IgnoredPass),
46                TestCaseFixture::new(
47                    "test_slow_timeout_subprocess",
48                    TestCaseFixtureStatus::IgnoredPass,
49                ),
50                TestCaseFixture::new("test_stdin_closed", TestCaseFixtureStatus::Pass),
51                TestCaseFixture::new("test_subprocess_doesnt_exit", TestCaseFixtureStatus::Leak),
52                TestCaseFixture::new("test_subprocess_doesnt_exit_fail", TestCaseFixtureStatus::FailLeak),
53                TestCaseFixture::new("test_subprocess_doesnt_exit_leak_fail", TestCaseFixtureStatus::LeakFail),
54                TestCaseFixture::new("test_success", TestCaseFixtureStatus::Pass),
55                TestCaseFixture::new("test_success_should_panic", TestCaseFixtureStatus::Pass),
56            },
57        ),
58        TestSuiteFixture::new(
59            "nextest-tests::other",
60            "other",
61            BuildPlatform::Target,
62            id_ord_map! {
63                TestCaseFixture::new("other_test_success", TestCaseFixtureStatus::Pass),
64            },
65        ),
66        TestSuiteFixture::new(
67            "nextest-tests::segfault",
68            "segfault",
69            BuildPlatform::Target,
70            id_ord_map! {
71                TestCaseFixture::new("test_segfault", TestCaseFixtureStatus::Segfault),
72            },
73        ),
74        // Unit tests
75        TestSuiteFixture::new(
76            "nextest-tests",
77            "nextest-tests",
78            BuildPlatform::Target,
79            id_ord_map! {
80                TestCaseFixture::new("tests::call_dylib_add_two", TestCaseFixtureStatus::Pass),
81                TestCaseFixture::new("tests::unit_test_success", TestCaseFixtureStatus::Pass),
82            },
83        ),
84        // Binary tests
85        TestSuiteFixture::new(
86            "nextest-tests::bin/nextest-tests",
87            "nextest-tests",
88            BuildPlatform::Target,
89            id_ord_map! {
90                // This is a fake test name produced by wrapper.rs.
91                TestCaseFixture::new("fake_test_name", TestCaseFixtureStatus::IgnoredPass),
92                TestCaseFixture::new("tests::bin_success", TestCaseFixtureStatus::Pass),
93            },
94        ),
95        TestSuiteFixture::new(
96            "nextest-tests::bin/other",
97            "other",
98            BuildPlatform::Target,
99            id_ord_map! {
100                TestCaseFixture::new("tests::other_bin_success", TestCaseFixtureStatus::Pass),
101            },
102        ),
103        TestSuiteFixture::new(
104            "nextest-tests::bin/wrapper",
105            "wrapper",
106            BuildPlatform::Target,
107            IdOrdMap::new(),
108        ),
109        // Example tests
110        TestSuiteFixture::new(
111            "nextest-tests::example/nextest-tests",
112            "nextest-tests",
113            BuildPlatform::Target,
114            id_ord_map! {
115                // This is a fake test name produced by wrapper.rs.
116                TestCaseFixture::new("fake_test_name", TestCaseFixtureStatus::IgnoredPass),
117                TestCaseFixture::new("tests::example_success", TestCaseFixtureStatus::Pass),
118            },
119        ),
120        TestSuiteFixture::new(
121            "nextest-tests::example/other",
122            "other",
123            BuildPlatform::Target,
124            id_ord_map! {
125                TestCaseFixture::new("tests::other_example_success", TestCaseFixtureStatus::Pass),
126            },
127        ),
128        // Benchmarks
129        TestSuiteFixture::new(
130            "nextest-tests::bench/my-bench",
131            "my-bench",
132            BuildPlatform::Target,
133            id_ord_map! {
134                TestCaseFixture::new("bench_add_two", TestCaseFixtureStatus::Pass),
135                TestCaseFixture::new("tests::test_execute_bin", TestCaseFixtureStatus::Pass),
136            },
137        ),
138        // Proc-macro tests
139        TestSuiteFixture::new(
140            "nextest-derive",
141            "nextest-derive",
142            BuildPlatform::Host,
143            id_ord_map! {
144                TestCaseFixture::new("it_works", TestCaseFixtureStatus::Pass),
145            },
146        ),
147        // Dynamic library tests
148        TestSuiteFixture::new(
149            "cdylib-link",
150            "cdylib-link",
151            BuildPlatform::Target,
152            id_ord_map! {
153                TestCaseFixture::new("test_multiply_two", TestCaseFixtureStatus::Pass)
154                    .with_property(TestCaseFixtureProperty::MatchesTestMultiplyTwo),
155            },
156        ),
157        TestSuiteFixture::new(
158            "dylib-test",
159            "dylib-test",
160            BuildPlatform::Target,
161            IdOrdMap::new(),
162        ),
163        TestSuiteFixture::new(
164            "cdylib-example",
165            "cdylib-example",
166            BuildPlatform::Target,
167            id_ord_map! {
168                TestCaseFixture::new("tests::test_multiply_two_cdylib", TestCaseFixtureStatus::Pass)
169                    .with_property(TestCaseFixtureProperty::MatchesCdylib)
170                    .with_property(TestCaseFixtureProperty::MatchesTestMultiplyTwo),
171            },
172        )
173        .with_property(TestSuiteFixtureProperty::NotInDefaultSet),
174        // Build script tests
175        TestSuiteFixture::new(
176            "with-build-script",
177            "with-build-script",
178            BuildPlatform::Target,
179            id_ord_map! {
180                TestCaseFixture::new("tests::test_build_script_vars_set", TestCaseFixtureStatus::Pass),
181                TestCaseFixture::new("tests::test_out_dir_present", TestCaseFixtureStatus::Pass),
182            }
183        ),
184        TestSuiteFixture::new(
185            "proc-macro-test",
186            "proc-macro-test",
187            BuildPlatform::Host,
188            IdOrdMap::new(),
189        ),
190    }
191});
192
193pub fn get_expected_test(binary_id: &RustBinaryId, test_name: &str) -> &'static TestCaseFixture {
194    let v = EXPECTED_TEST_SUITES
195        .get(binary_id)
196        .unwrap_or_else(|| panic!("binary id {binary_id} not found"));
197    v.test_cases
198        .iter()
199        .find(|fixture| fixture.name == test_name)
200        .unwrap_or_else(|| panic!("for binary id {binary_id}, test name {test_name} not found"))
201}