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::inherit_test_dep;
9pub use test_r_macro::never_capture;
10pub use test_r_macro::never_ensure_time;
11pub use test_r_macro::never_report_time;
12pub use test_r_macro::non_flaky;
13pub use test_r_macro::sequential;
14pub use test_r_macro::sequential_suite;
15pub use test_r_macro::tag;
16pub use test_r_macro::tag_suite;
17pub use test_r_macro::test;
18pub use test_r_macro::test_dep;
19pub use test_r_macro::test_gen;
20pub use test_r_macro::timeout;
21pub use test_r_macro::uses_test_r as enable;
22
23#[cfg(feature = "tokio")]
24pub use test_r_core::bench::AsyncBencher;
25pub use test_r_core::bench::Bencher;
26
27pub mod core {
28 use std::time::Duration;
29 pub use test_r_core::internal::{
30 CaptureControl, DependencyConstructor, DependencyView, DynamicTestRegistration,
31 FlakinessControl, GeneratedTest, ReportTimeControl, ShouldPanic, TestFunction,
32 TestGeneratorFunction, TestProperties, TestReturnValue, TestType,
33 };
34 pub use test_r_core::*;
35
36 #[allow(clippy::too_many_arguments)]
37 pub fn register_test(
38 name: &str,
39 module_path: &str,
40 is_ignored: bool,
41 should_panic: ShouldPanic,
42 test_type: TestType,
43 timeout: Option<Duration>,
44 flakiness_control: FlakinessControl,
45 capture_control: CaptureControl,
46 tags: Vec<String>,
47 report_time_control: ReportTimeControl,
48 ensure_time_control: ReportTimeControl,
49 run: TestFunction,
50 ) {
51 let (crate_name, module_path) = split_module_path(module_path);
52
53 internal::REGISTERED_TESTS
54 .lock()
55 .unwrap()
56 .push(internal::RegisteredTest {
57 name: name.to_string(),
58 crate_name,
59 module_path,
60 run,
61 props: internal::TestProperties {
62 should_panic,
63 test_type,
64 timeout,
65 flakiness_control,
66 capture_control,
67 report_time_control,
68 ensure_time_control,
69 tags,
70 is_ignored,
71 },
72 });
73 }
74
75 pub fn register_dependency_constructor(
76 name: &str,
77 module_path: &str,
78 cons: DependencyConstructor,
79 dependencies: Vec<String>,
80 ) {
81 let (crate_name, module_path) = split_module_path(module_path);
82
83 internal::REGISTERED_DEPENDENCY_CONSTRUCTORS
84 .lock()
85 .unwrap()
86 .push(internal::RegisteredDependency {
87 name: name.to_string(),
88 crate_name,
89 module_path,
90 constructor: cons,
91 dependencies,
92 });
93 }
94
95 pub fn register_suite_sequential(name: &str, module_path: &str) {
96 let (crate_name, module_path) = split_module_path(module_path);
97
98 internal::REGISTERED_TESTSUITE_PROPS.lock().unwrap().push(
99 internal::RegisteredTestSuiteProperty::Sequential {
100 name: name.to_string(),
101 crate_name,
102 module_path,
103 },
104 );
105 }
106
107 pub fn register_suite_tag(name: &str, module_path: &str, tag: String) {
108 let (crate_name, module_path) = split_module_path(module_path);
109
110 internal::REGISTERED_TESTSUITE_PROPS.lock().unwrap().push(
111 internal::RegisteredTestSuiteProperty::Tag {
112 name: name.to_string(),
113 crate_name,
114 module_path,
115 tag,
116 },
117 );
118 }
119
120 pub fn register_test_generator(
121 name: &str,
122 module_path: &str,
123 is_ignored: bool,
124 run: TestGeneratorFunction,
125 ) {
126 let (crate_name, module_path) = split_module_path(module_path);
127
128 internal::REGISTERED_TEST_GENERATORS.lock().unwrap().push(
129 internal::RegisteredTestGenerator {
130 name: name.to_string(),
131 crate_name,
132 module_path,
133 run,
134 is_ignored,
135 },
136 );
137 }
138
139 fn split_module_path(module_path: &str) -> (String, String) {
140 let (crate_name, module_path) =
141 if let Some((crate_name, module_path)) = module_path.split_once("::") {
142 (crate_name.to_string(), module_path.to_string())
143 } else {
144 (module_path.to_string(), String::new())
145 };
146 (crate_name, module_path)
147 }
148}
149
150pub use ::ctor;