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(
51                    "test_flaky_slow_timeout_mod_3",
52                    TestCaseFixtureStatus::IgnoredFail
53                ),
54                TestCaseFixture::new("test_stdin_closed", TestCaseFixtureStatus::Pass),
55                TestCaseFixture::new("test_subprocess_doesnt_exit", TestCaseFixtureStatus::Leak),
56                TestCaseFixture::new("test_subprocess_doesnt_exit_fail", TestCaseFixtureStatus::FailLeak),
57                TestCaseFixture::new("test_subprocess_doesnt_exit_leak_fail", TestCaseFixtureStatus::LeakFail),
58                TestCaseFixture::new("test_success", TestCaseFixtureStatus::Pass),
59                TestCaseFixture::new("test_success_should_panic", TestCaseFixtureStatus::Pass),
60            },
61        ),
62        TestSuiteFixture::new(
63            "nextest-tests::other",
64            "other",
65            BuildPlatform::Target,
66            id_ord_map! {
67                TestCaseFixture::new("other_test_success", TestCaseFixtureStatus::Pass),
68            },
69        ),
70        TestSuiteFixture::new(
71            "nextest-tests::segfault",
72            "segfault",
73            BuildPlatform::Target,
74            id_ord_map! {
75                TestCaseFixture::new("test_segfault", TestCaseFixtureStatus::Segfault),
76            },
77        ),
78        // Unit tests
79        TestSuiteFixture::new(
80            "nextest-tests",
81            "nextest-tests",
82            BuildPlatform::Target,
83            id_ord_map! {
84                TestCaseFixture::new("tests::call_dylib_add_two", TestCaseFixtureStatus::Pass),
85                TestCaseFixture::new("tests::unit_test_success", TestCaseFixtureStatus::Pass),
86            },
87        ),
88        // Binary tests
89        TestSuiteFixture::new(
90            "nextest-tests::bin/nextest-tests",
91            "nextest-tests",
92            BuildPlatform::Target,
93            id_ord_map! {
94                // This is a fake test name produced by wrapper.rs.
95                TestCaseFixture::new("fake_test_name", TestCaseFixtureStatus::IgnoredPass),
96                TestCaseFixture::new("tests::bin_success", TestCaseFixtureStatus::Pass),
97            },
98        ),
99        TestSuiteFixture::new(
100            "nextest-tests::bin/other",
101            "other",
102            BuildPlatform::Target,
103            id_ord_map! {
104                TestCaseFixture::new("tests::other_bin_success", TestCaseFixtureStatus::Pass),
105            },
106        ),
107        TestSuiteFixture::new(
108            "nextest-tests::bin/wrapper",
109            "wrapper",
110            BuildPlatform::Target,
111            IdOrdMap::new(),
112        ),
113        // Example tests
114        TestSuiteFixture::new(
115            "nextest-tests::example/nextest-tests",
116            "nextest-tests",
117            BuildPlatform::Target,
118            id_ord_map! {
119                // This is a fake test name produced by wrapper.rs.
120                TestCaseFixture::new("fake_test_name", TestCaseFixtureStatus::IgnoredPass),
121                TestCaseFixture::new("tests::example_success", TestCaseFixtureStatus::Pass),
122            },
123        ),
124        TestSuiteFixture::new(
125            "nextest-tests::example/other",
126            "other",
127            BuildPlatform::Target,
128            id_ord_map! {
129                TestCaseFixture::new("tests::other_example_success", TestCaseFixtureStatus::Pass),
130            },
131        ),
132        // Benchmarks
133        TestSuiteFixture::new(
134            "nextest-tests::bench/my-bench",
135            "my-bench",
136            BuildPlatform::Target,
137            id_ord_map! {
138                TestCaseFixture::new("bench_add_two", TestCaseFixtureStatus::Pass),
139                TestCaseFixture::new("tests::test_execute_bin", TestCaseFixtureStatus::Pass),
140            },
141        ),
142        // Proc-macro tests
143        TestSuiteFixture::new(
144            "nextest-derive",
145            "nextest-derive",
146            BuildPlatform::Host,
147            id_ord_map! {
148                TestCaseFixture::new("it_works", TestCaseFixtureStatus::Pass),
149            },
150        ),
151        // Dynamic library tests
152        TestSuiteFixture::new(
153            "cdylib-link",
154            "cdylib-link",
155            BuildPlatform::Target,
156            id_ord_map! {
157                TestCaseFixture::new("test_multiply_two", TestCaseFixtureStatus::Pass)
158                    .with_property(TestCaseFixtureProperty::MatchesTestMultiplyTwo),
159            },
160        ),
161        TestSuiteFixture::new(
162            "dylib-test",
163            "dylib-test",
164            BuildPlatform::Target,
165            IdOrdMap::new(),
166        ),
167        TestSuiteFixture::new(
168            "cdylib-example",
169            "cdylib-example",
170            BuildPlatform::Target,
171            id_ord_map! {
172                TestCaseFixture::new("tests::test_multiply_two_cdylib", TestCaseFixtureStatus::Pass)
173                    .with_property(TestCaseFixtureProperty::MatchesCdylib)
174                    .with_property(TestCaseFixtureProperty::MatchesTestMultiplyTwo),
175            },
176        )
177        .with_property(TestSuiteFixtureProperty::NotInDefaultSet)
178        .with_property(TestSuiteFixtureProperty::MatchesCdylibExample),
179        // Build script tests
180        TestSuiteFixture::new(
181            "with-build-script",
182            "with-build-script",
183            BuildPlatform::Target,
184            id_ord_map! {
185                TestCaseFixture::new("tests::test_build_script_vars_set", TestCaseFixtureStatus::Pass),
186                TestCaseFixture::new("tests::test_out_dir_present", TestCaseFixtureStatus::Pass),
187            }
188        ),
189        TestSuiteFixture::new(
190            "proc-macro-test",
191            "proc-macro-test",
192            BuildPlatform::Host,
193            IdOrdMap::new(),
194        ),
195    }
196});
197
198pub fn get_expected_test(binary_id: &RustBinaryId, test_name: &str) -> &'static TestCaseFixture {
199    let v = EXPECTED_TEST_SUITES
200        .get(binary_id)
201        .unwrap_or_else(|| panic!("binary id {binary_id} not found"));
202    v.test_cases
203        .iter()
204        .find(|fixture| fixture.name == test_name)
205        .unwrap_or_else(|| panic!("for binary id {binary_id}, test name {test_name} not found"))
206}