1pub use test_r_macro::add_test;
2pub use test_r_macro::always_capture;
3pub use test_r_macro::always_ensure_time;
4pub use test_r_macro::always_report_time;
5pub use test_r_macro::bench;
6pub use test_r_macro::define_matrix_dimension;
7pub use test_r_macro::flaky;
8pub use test_r_macro::hosted_rpc;
9pub use test_r_macro::ignore_detached_panics;
10pub use test_r_macro::inherit_test_dep;
11pub use test_r_macro::never_capture;
12pub use test_r_macro::never_ensure_time;
13pub use test_r_macro::never_report_time;
14pub use test_r_macro::non_flaky;
15pub use test_r_macro::sequential;
16pub use test_r_macro::sequential_suite;
17pub use test_r_macro::tag;
18pub use test_r_macro::tag_suite;
19pub use test_r_macro::test;
20pub use test_r_macro::test_dep;
21pub use test_r_macro::test_gen;
22pub use test_r_macro::timeout;
23pub use test_r_macro::timeout_suite;
24pub use test_r_macro::uses_test_r as enable;
25
26#[cfg(feature = "tokio")]
27pub use test_r_core::bench::AsyncBencher;
28pub use test_r_core::bench::Bencher;
29#[cfg(feature = "tokio")]
30pub use test_r_core::spawn::spawn;
31pub use test_r_core::spawn::spawn_thread;
32
33pub use test_r_core::internal::{AsyncHostedDep, CloneableDep, HostedDep, HostedRpcDep};
34pub use test_r_core::worker_index;
35
36pub mod core {
37 use std::time::Duration;
38 pub use test_r_core::internal::{
39 AsyncHostedDep, CaptureControl, CloneableCodec, CloneableDep, DepScope,
40 DependencyConstructor, DependencyView, DetachedPanicPolicy, DynamicTestRegistration,
41 FailureCause, FlakinessControl, GeneratedTest, HostedBothShared, HostedDep,
42 HostedRpcChannel, HostedRpcDep, HostedRpcDispatcher, HostedRpcError, HostedRpcOwnerCell,
43 HostedRpcTransport, InProcessHostedRpcTransport, ReportTimeControl, RpcFactory,
44 ShouldPanic, TestFunction, TestGeneratorFunction, TestProperties, TestReturnValue,
45 TestType, WorkerReconstructor,
46 };
47 pub use test_r_core::*;
48
49 #[allow(clippy::too_many_arguments)]
50 pub fn register_test(
51 name: &str,
52 module_path: &str,
53 is_ignored: bool,
54 should_panic: ShouldPanic,
55 test_type: TestType,
56 timeout: Option<Duration>,
57 flakiness_control: FlakinessControl,
58 capture_control: CaptureControl,
59 tags: Vec<String>,
60 report_time_control: ReportTimeControl,
61 ensure_time_control: ReportTimeControl,
62 detached_panic_policy: DetachedPanicPolicy,
63 run: TestFunction,
64 dependencies: Option<Vec<String>>,
65 ) {
66 let (crate_name, module_path) = split_module_path(module_path);
67
68 internal::REGISTERED_TESTS
69 .lock()
70 .unwrap()
71 .push(internal::RegisteredTest {
72 name: name.to_string(),
73 crate_name,
74 module_path,
75 run,
76 props: internal::TestProperties {
77 should_panic,
78 test_type,
79 timeout,
80 flakiness_control,
81 capture_control,
82 report_time_control,
83 ensure_time_control,
84 tags,
85 is_ignored,
86 detached_panic_policy,
87 },
88 dependencies,
89 });
90 }
91
92 pub fn register_dependency_constructor(
93 name: &str,
94 module_path: &str,
95 cons: DependencyConstructor,
96 dependencies: Vec<String>,
97 ) {
98 register_dependency_constructor_with_scope(
99 name,
100 module_path,
101 cons,
102 dependencies,
103 DepScope::Shared,
104 None,
105 None,
106 None,
107 None,
108 )
109 }
110
111 #[allow(clippy::too_many_arguments)]
112 pub fn register_dependency_constructor_with_scope(
113 name: &str,
114 module_path: &str,
115 cons: DependencyConstructor,
116 dependencies: Vec<String>,
117 scope: DepScope,
118 worker_fn: Option<WorkerReconstructor>,
119 cloneable_codec: Option<CloneableCodec>,
120 hosted_codec: Option<CloneableCodec>,
121 rpc_factory: Option<RpcFactory>,
122 ) {
123 register_dependency_constructor_with_scope_and_companions(
124 name,
125 module_path,
126 cons,
127 dependencies,
128 scope,
129 worker_fn,
130 cloneable_codec,
131 hosted_codec,
132 rpc_factory,
133 Vec::new(),
134 )
135 }
136
137 #[allow(clippy::too_many_arguments)]
143 pub fn register_dependency_constructor_with_scope_and_companions(
144 name: &str,
145 module_path: &str,
146 cons: DependencyConstructor,
147 dependencies: Vec<String>,
148 scope: DepScope,
149 worker_fn: Option<WorkerReconstructor>,
150 cloneable_codec: Option<CloneableCodec>,
151 hosted_codec: Option<CloneableCodec>,
152 rpc_factory: Option<RpcFactory>,
153 companions: Vec<String>,
154 ) {
155 let (crate_name, module_path) = split_module_path(module_path);
156
157 internal::REGISTERED_DEPENDENCY_CONSTRUCTORS
158 .lock()
159 .unwrap()
160 .push(internal::RegisteredDependency {
161 name: name.to_string(),
162 crate_name,
163 module_path,
164 constructor: cons,
165 dependencies,
166 scope,
167 worker_fn,
168 cloneable_codec,
169 hosted_codec,
170 rpc_factory,
171 companions,
172 });
173 }
174
175 pub fn register_suite_sequential(name: &str, module_path: &str) {
176 let (crate_name, module_path) = split_module_path(module_path);
177
178 internal::REGISTERED_TESTSUITE_PROPS.lock().unwrap().push(
179 internal::RegisteredTestSuiteProperty::Sequential {
180 name: name.to_string(),
181 crate_name,
182 module_path,
183 },
184 );
185 }
186
187 pub fn register_suite_timeout(name: &str, module_path: &str, timeout: Duration) {
188 let (crate_name, module_path) = split_module_path(module_path);
189
190 internal::REGISTERED_TESTSUITE_PROPS.lock().unwrap().push(
191 internal::RegisteredTestSuiteProperty::Timeout {
192 name: name.to_string(),
193 crate_name,
194 module_path,
195 timeout,
196 },
197 );
198 }
199
200 pub fn register_suite_tag(name: &str, module_path: &str, tag: String) {
201 let (crate_name, module_path) = split_module_path(module_path);
202
203 internal::REGISTERED_TESTSUITE_PROPS.lock().unwrap().push(
204 internal::RegisteredTestSuiteProperty::Tag {
205 name: name.to_string(),
206 crate_name,
207 module_path,
208 tag,
209 },
210 );
211 }
212
213 pub fn register_test_generator(
214 name: &str,
215 module_path: &str,
216 is_ignored: bool,
217 run: TestGeneratorFunction,
218 ) {
219 let (crate_name, module_path) = split_module_path(module_path);
220
221 internal::REGISTERED_TEST_GENERATORS.lock().unwrap().push(
222 internal::RegisteredTestGenerator {
223 name: name.to_string(),
224 crate_name,
225 module_path,
226 run,
227 is_ignored,
228 },
229 );
230 }
231
232 fn split_module_path(module_path: &str) -> (String, String) {
233 let (crate_name, module_path) =
234 if let Some((crate_name, module_path)) = module_path.split_once("::") {
235 (crate_name.to_string(), module_path.to_string())
236 } else {
237 (module_path.to_string(), String::new())
238 };
239 (crate_name, module_path)
240 }
241}
242
243pub use ::ctor;