Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 72d09bd

Browse files
committedJan 10, 2025·
test: add #![warn(unreachable_pub)]
1 parent abb4d6c commit 72d09bd

File tree

16 files changed

+80
-79
lines changed

16 files changed

+80
-79
lines changed
 

‎library/test/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl TestOpts {
4444
}
4545

4646
/// Result of parsing the options.
47-
pub type OptRes = Result<TestOpts, String>;
47+
pub(crate) type OptRes = Result<TestOpts, String>;
4848
/// Result of parsing the option part.
4949
type OptPartRes<T> = Result<T, String>;
5050

‎library/test/src/console.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::types::{NamePadding, TestDesc, TestDescAndFn};
2020
use super::{filter_tests, run_tests, term};
2121

2222
/// Generic wrapper over stdout.
23-
pub enum OutputLocation<T> {
23+
pub(crate) enum OutputLocation<T> {
2424
Pretty(Box<term::StdoutTerminal>),
2525
Raw(T),
2626
}
@@ -41,15 +41,15 @@ impl<T: Write> Write for OutputLocation<T> {
4141
}
4242
}
4343

44-
pub struct ConsoleTestDiscoveryState {
44+
pub(crate) struct ConsoleTestDiscoveryState {
4545
pub log_out: Option<File>,
4646
pub tests: usize,
4747
pub benchmarks: usize,
4848
pub ignored: usize,
4949
}
5050

5151
impl ConsoleTestDiscoveryState {
52-
pub fn new(opts: &TestOpts) -> io::Result<ConsoleTestDiscoveryState> {
52+
pub(crate) fn new(opts: &TestOpts) -> io::Result<ConsoleTestDiscoveryState> {
5353
let log_out = match opts.logfile {
5454
Some(ref path) => Some(File::create(path)?),
5555
None => None,
@@ -58,7 +58,7 @@ impl ConsoleTestDiscoveryState {
5858
Ok(ConsoleTestDiscoveryState { log_out, tests: 0, benchmarks: 0, ignored: 0 })
5959
}
6060

61-
pub fn write_log<F, S>(&mut self, msg: F) -> io::Result<()>
61+
pub(crate) fn write_log<F, S>(&mut self, msg: F) -> io::Result<()>
6262
where
6363
S: AsRef<str>,
6464
F: FnOnce() -> S,
@@ -74,7 +74,7 @@ impl ConsoleTestDiscoveryState {
7474
}
7575
}
7676

77-
pub struct ConsoleTestState {
77+
pub(crate) struct ConsoleTestState {
7878
pub log_out: Option<File>,
7979
pub total: usize,
8080
pub passed: usize,
@@ -92,7 +92,7 @@ pub struct ConsoleTestState {
9292
}
9393

9494
impl ConsoleTestState {
95-
pub fn new(opts: &TestOpts) -> io::Result<ConsoleTestState> {
95+
pub(crate) fn new(opts: &TestOpts) -> io::Result<ConsoleTestState> {
9696
let log_out = match opts.logfile {
9797
Some(ref path) => Some(File::create(path)?),
9898
None => None,
@@ -116,7 +116,7 @@ impl ConsoleTestState {
116116
})
117117
}
118118

119-
pub fn write_log<F, S>(&mut self, msg: F) -> io::Result<()>
119+
pub(crate) fn write_log<F, S>(&mut self, msg: F) -> io::Result<()>
120120
where
121121
S: AsRef<str>,
122122
F: FnOnce() -> S,
@@ -131,7 +131,7 @@ impl ConsoleTestState {
131131
}
132132
}
133133

134-
pub fn write_log_result(
134+
pub(crate) fn write_log_result(
135135
&mut self,
136136
test: &TestDesc,
137137
result: &TestResult,
@@ -170,7 +170,7 @@ impl ConsoleTestState {
170170
}
171171

172172
// List the tests to console, and optionally to logfile. Filters are honored.
173-
pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Result<()> {
173+
pub(crate) fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Result<()> {
174174
let output = match term::stdout() {
175175
None => OutputLocation::Raw(io::stdout().lock()),
176176
Some(t) => OutputLocation::Pretty(t),

‎library/test/src/formatters/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) struct JsonFormatter<T> {
1313
}
1414

1515
impl<T: Write> JsonFormatter<T> {
16-
pub fn new(out: OutputLocation<T>) -> Self {
16+
pub(crate) fn new(out: OutputLocation<T>) -> Self {
1717
Self { out }
1818
}
1919

‎library/test/src/formatters/junit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use crate::test_result::TestResult;
88
use crate::time;
99
use crate::types::{TestDesc, TestType};
1010

11-
pub struct JunitFormatter<T> {
11+
pub(crate) struct JunitFormatter<T> {
1212
out: OutputLocation<T>,
1313
results: Vec<(TestDesc, TestResult, Duration, Vec<u8>)>,
1414
}
1515

1616
impl<T: Write> JunitFormatter<T> {
17-
pub fn new(out: OutputLocation<T>) -> Self {
17+
pub(crate) fn new(out: OutputLocation<T>) -> Self {
1818
Self { out, results: Vec::new() }
1919
}
2020

‎library/test/src/formatters/pretty.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) struct PrettyFormatter<T> {
2020
}
2121

2222
impl<T: Write> PrettyFormatter<T> {
23-
pub fn new(
23+
pub(crate) fn new(
2424
out: OutputLocation<T>,
2525
use_color: bool,
2626
max_name_len: usize,
@@ -31,43 +31,43 @@ impl<T: Write> PrettyFormatter<T> {
3131
}
3232

3333
#[cfg(test)]
34-
pub fn output_location(&self) -> &OutputLocation<T> {
34+
pub(crate) fn output_location(&self) -> &OutputLocation<T> {
3535
&self.out
3636
}
3737

38-
pub fn write_ok(&mut self) -> io::Result<()> {
38+
pub(crate) fn write_ok(&mut self) -> io::Result<()> {
3939
self.write_short_result("ok", term::color::GREEN)
4040
}
4141

42-
pub fn write_failed(&mut self) -> io::Result<()> {
42+
pub(crate) fn write_failed(&mut self) -> io::Result<()> {
4343
self.write_short_result("FAILED", term::color::RED)
4444
}
4545

46-
pub fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> {
46+
pub(crate) fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> {
4747
if let Some(message) = message {
4848
self.write_short_result(&format!("ignored, {message}"), term::color::YELLOW)
4949
} else {
5050
self.write_short_result("ignored", term::color::YELLOW)
5151
}
5252
}
5353

54-
pub fn write_time_failed(&mut self) -> io::Result<()> {
54+
pub(crate) fn write_time_failed(&mut self) -> io::Result<()> {
5555
self.write_short_result("FAILED (time limit exceeded)", term::color::RED)
5656
}
5757

58-
pub fn write_bench(&mut self) -> io::Result<()> {
58+
pub(crate) fn write_bench(&mut self) -> io::Result<()> {
5959
self.write_pretty("bench", term::color::CYAN)
6060
}
6161

62-
pub fn write_short_result(
62+
pub(crate) fn write_short_result(
6363
&mut self,
6464
result: &str,
6565
color: term::color::Color,
6666
) -> io::Result<()> {
6767
self.write_pretty(result, color)
6868
}
6969

70-
pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> {
70+
pub(crate) fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> {
7171
match self.out {
7272
OutputLocation::Pretty(ref mut term) => {
7373
if self.use_color {
@@ -86,7 +86,7 @@ impl<T: Write> PrettyFormatter<T> {
8686
}
8787
}
8888

89-
pub fn write_plain<S: AsRef<str>>(&mut self, s: S) -> io::Result<()> {
89+
pub(crate) fn write_plain<S: AsRef<str>>(&mut self, s: S) -> io::Result<()> {
9090
let s = s.as_ref();
9191
self.out.write_all(s.as_bytes())?;
9292
self.out.flush()
@@ -154,15 +154,15 @@ impl<T: Write> PrettyFormatter<T> {
154154
Ok(())
155155
}
156156

157-
pub fn write_successes(&mut self, state: &ConsoleTestState) -> io::Result<()> {
157+
pub(crate) fn write_successes(&mut self, state: &ConsoleTestState) -> io::Result<()> {
158158
self.write_results(&state.not_failures, "successes")
159159
}
160160

161-
pub fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
161+
pub(crate) fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
162162
self.write_results(&state.failures, "failures")
163163
}
164164

165-
pub fn write_time_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
165+
pub(crate) fn write_time_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
166166
self.write_results(&state.time_failures, "failures (time limit exceeded)")
167167
}
168168

‎library/test/src/formatters/terse.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) struct TerseFormatter<T> {
2525
}
2626

2727
impl<T: Write> TerseFormatter<T> {
28-
pub fn new(
28+
pub(crate) fn new(
2929
out: OutputLocation<T>,
3030
use_color: bool,
3131
max_name_len: usize,
@@ -42,11 +42,11 @@ impl<T: Write> TerseFormatter<T> {
4242
}
4343
}
4444

45-
pub fn write_ok(&mut self) -> io::Result<()> {
45+
pub(crate) fn write_ok(&mut self) -> io::Result<()> {
4646
self.write_short_result(".", term::color::GREEN)
4747
}
4848

49-
pub fn write_failed(&mut self, name: &str) -> io::Result<()> {
49+
pub(crate) fn write_failed(&mut self, name: &str) -> io::Result<()> {
5050
// Put failed tests on their own line and include the test name, so that it's faster
5151
// to see which test failed without having to wait for them all to run.
5252

@@ -62,15 +62,15 @@ impl<T: Write> TerseFormatter<T> {
6262
self.write_plain("\n")
6363
}
6464

65-
pub fn write_ignored(&mut self) -> io::Result<()> {
65+
pub(crate) fn write_ignored(&mut self) -> io::Result<()> {
6666
self.write_short_result("i", term::color::YELLOW)
6767
}
6868

69-
pub fn write_bench(&mut self) -> io::Result<()> {
69+
pub(crate) fn write_bench(&mut self) -> io::Result<()> {
7070
self.write_pretty("bench", term::color::CYAN)
7171
}
7272

73-
pub fn write_short_result(
73+
pub(crate) fn write_short_result(
7474
&mut self,
7575
result: &str,
7676
color: term::color::Color,
@@ -95,7 +95,7 @@ impl<T: Write> TerseFormatter<T> {
9595
Ok(())
9696
}
9797

98-
pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> {
98+
pub(crate) fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> {
9999
match self.out {
100100
OutputLocation::Pretty(ref mut term) => {
101101
if self.use_color {
@@ -114,13 +114,13 @@ impl<T: Write> TerseFormatter<T> {
114114
}
115115
}
116116

117-
pub fn write_plain<S: AsRef<str>>(&mut self, s: S) -> io::Result<()> {
117+
pub(crate) fn write_plain<S: AsRef<str>>(&mut self, s: S) -> io::Result<()> {
118118
let s = s.as_ref();
119119
self.out.write_all(s.as_bytes())?;
120120
self.out.flush()
121121
}
122122

123-
pub fn write_outputs(&mut self, state: &ConsoleTestState) -> io::Result<()> {
123+
pub(crate) fn write_outputs(&mut self, state: &ConsoleTestState) -> io::Result<()> {
124124
self.write_plain("\nsuccesses:\n")?;
125125
let mut successes = Vec::new();
126126
let mut stdouts = String::new();
@@ -146,7 +146,7 @@ impl<T: Write> TerseFormatter<T> {
146146
Ok(())
147147
}
148148

149-
pub fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
149+
pub(crate) fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
150150
self.write_plain("\nfailures:\n")?;
151151
let mut failures = Vec::new();
152152
let mut fail_out = String::new();

‎library/test/src/helpers/concurrency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::num::NonZero;
55
use std::{env, thread};
66

7-
pub fn get_concurrency() -> usize {
7+
pub(crate) fn get_concurrency() -> usize {
88
if let Ok(value) = env::var("RUST_TEST_THREADS") {
99
match value.parse::<NonZero<usize>>().ok() {
1010
Some(n) => n.get(),

‎library/test/src/helpers/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Module with common helpers not directly related to tests
22
//! but used in `libtest`.
33
4-
pub mod concurrency;
5-
pub mod metrics;
6-
pub mod shuffle;
4+
pub(crate) mod concurrency;
5+
pub(crate) mod metrics;
6+
pub(crate) mod shuffle;

‎library/test/src/helpers/shuffle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
44
use crate::cli::TestOpts;
55
use crate::types::{TestDescAndFn, TestId, TestName};
66

7-
pub fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> {
7+
pub(crate) fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> {
88
opts.shuffle_seed.or_else(|| {
99
if opts.shuffle {
1010
Some(
@@ -19,7 +19,7 @@ pub fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> {
1919
})
2020
}
2121

22-
pub fn shuffle_tests(shuffle_seed: u64, tests: &mut [(TestId, TestDescAndFn)]) {
22+
pub(crate) fn shuffle_tests(shuffle_seed: u64, tests: &mut [(TestId, TestDescAndFn)]) {
2323
let test_names: Vec<&TestName> = tests.iter().map(|test| &test.1.desc.name).collect();
2424
let test_names_hash = calculate_hash(&test_names);
2525
let mut rng = Rng::new(shuffle_seed, test_names_hash);

‎library/test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![feature(thread_spawn_hook)]
2828
#![allow(internal_features)]
2929
#![warn(rustdoc::unescaped_backticks)]
30+
#![warn(unreachable_pub)]
3031

3132
pub use cli::TestOpts;
3233

‎library/test/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
/// Number of times to run a benchmarked function
44
#[derive(Clone, PartialEq, Eq)]
5-
pub enum BenchMode {
5+
pub(crate) enum BenchMode {
66
Auto,
77
Single,
88
}

‎library/test/src/stats/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,13 @@ fn test_sum_f64_between_ints_that_sum_to_0() {
573573
}
574574

575575
#[bench]
576-
pub fn sum_three_items(b: &mut Bencher) {
576+
fn sum_three_items(b: &mut Bencher) {
577577
b.iter(|| {
578578
[1e20f64, 1.5f64, -1e20f64].sum();
579579
})
580580
}
581581
#[bench]
582-
pub fn sum_many_f64(b: &mut Bencher) {
582+
fn sum_many_f64(b: &mut Bencher) {
583583
let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60];
584584
let v = (0..500).map(|i| nums[i % 5]).collect::<Vec<_>>();
585585

@@ -589,4 +589,4 @@ pub fn sum_many_f64(b: &mut Bencher) {
589589
}
590590

591591
#[bench]
592-
pub fn no_iter(_: &mut Bencher) {}
592+
fn no_iter(_: &mut Bencher) {}

‎library/test/src/term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(crate) mod color {
6262

6363
/// A terminal with similar capabilities to an ANSI Terminal
6464
/// (foreground/background colors etc).
65-
pub trait Terminal: Write {
65+
pub(crate) trait Terminal: Write {
6666
/// Sets the foreground color to the given color.
6767
///
6868
/// If the color is a bright color, but the terminal only supports 8 colors,

‎library/test/src/test_result.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::types::TestDesc;
1212
// Return code for secondary process.
1313
// Start somewhere other than 0 so we know the return code means what we think
1414
// it means.
15-
pub const TR_OK: i32 = 50;
15+
pub(crate) const TR_OK: i32 = 50;
1616

1717
// On Windows we use __fastfail to abort, which is documented to use this
1818
// exception code.
@@ -39,7 +39,7 @@ pub enum TestResult {
3939

4040
/// Creates a `TestResult` depending on the raw result of test execution
4141
/// and associated data.
42-
pub fn calc_result<'a>(
42+
pub(crate) fn calc_result<'a>(
4343
desc: &TestDesc,
4444
task_result: Result<(), &'a (dyn Any + 'static + Send)>,
4545
time_opts: Option<&time::TestTimeOptions>,
@@ -93,7 +93,7 @@ pub fn calc_result<'a>(
9393
}
9494

9595
/// Creates a `TestResult` depending on the exit code of test subprocess.
96-
pub fn get_result_from_exit_code(
96+
pub(crate) fn get_result_from_exit_code(
9797
desc: &TestDesc,
9898
status: ExitStatus,
9999
time_opts: Option<&time::TestTimeOptions>,

‎library/test/src/tests.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
7878
}
7979

8080
#[test]
81-
pub fn do_not_run_ignored_tests() {
81+
fn do_not_run_ignored_tests() {
8282
fn f() -> Result<(), String> {
8383
panic!();
8484
}
@@ -106,7 +106,7 @@ pub fn do_not_run_ignored_tests() {
106106
}
107107

108108
#[test]
109-
pub fn ignored_tests_result_in_ignored() {
109+
fn ignored_tests_result_in_ignored() {
110110
fn f() -> Result<(), String> {
111111
Ok(())
112112
}
@@ -479,7 +479,7 @@ fn parse_include_ignored_flag() {
479479
}
480480

481481
#[test]
482-
pub fn filter_for_ignored_option() {
482+
fn filter_for_ignored_option() {
483483
// When we run ignored tests the test filter should filter out all the
484484
// unignored tests and flip the ignore flag on the rest to false
485485

@@ -496,7 +496,7 @@ pub fn filter_for_ignored_option() {
496496
}
497497

498498
#[test]
499-
pub fn run_include_ignored_option() {
499+
fn run_include_ignored_option() {
500500
// When we "--include-ignored" tests, the ignore flag should be set to false on
501501
// all tests and no test filtered out
502502

@@ -513,7 +513,7 @@ pub fn run_include_ignored_option() {
513513
}
514514

515515
#[test]
516-
pub fn exclude_should_panic_option() {
516+
fn exclude_should_panic_option() {
517517
let mut opts = TestOpts::new();
518518
opts.run_tests = true;
519519
opts.exclude_should_panic = true;
@@ -544,7 +544,7 @@ pub fn exclude_should_panic_option() {
544544
}
545545

546546
#[test]
547-
pub fn exact_filter_match() {
547+
fn exact_filter_match() {
548548
fn tests() -> Vec<TestDescAndFn> {
549549
["base", "base::test", "base::test1", "base::test2"]
550550
.into_iter()
@@ -667,7 +667,7 @@ fn sample_tests() -> Vec<TestDescAndFn> {
667667
}
668668

669669
#[test]
670-
pub fn shuffle_tests() {
670+
fn shuffle_tests() {
671671
let mut opts = TestOpts::new();
672672
opts.shuffle = true;
673673

@@ -686,7 +686,7 @@ pub fn shuffle_tests() {
686686
}
687687

688688
#[test]
689-
pub fn shuffle_tests_with_seed() {
689+
fn shuffle_tests_with_seed() {
690690
let mut opts = TestOpts::new();
691691
opts.shuffle = true;
692692

@@ -704,7 +704,7 @@ pub fn shuffle_tests_with_seed() {
704704
}
705705

706706
#[test]
707-
pub fn order_depends_on_more_than_seed() {
707+
fn order_depends_on_more_than_seed() {
708708
let mut opts = TestOpts::new();
709709
opts.shuffle = true;
710710

@@ -732,7 +732,7 @@ pub fn order_depends_on_more_than_seed() {
732732
}
733733

734734
#[test]
735-
pub fn test_metricmap_compare() {
735+
fn test_metricmap_compare() {
736736
let mut m1 = MetricMap::new();
737737
let mut m2 = MetricMap::new();
738738
m1.insert_metric("in-both-noise", 1000.0, 200.0);
@@ -755,15 +755,15 @@ pub fn test_metricmap_compare() {
755755
}
756756

757757
#[test]
758-
pub fn test_bench_once_no_iter() {
758+
fn test_bench_once_no_iter() {
759759
fn f(_: &mut Bencher) -> Result<(), String> {
760760
Ok(())
761761
}
762762
bench::run_once(f).unwrap();
763763
}
764764

765765
#[test]
766-
pub fn test_bench_once_iter() {
766+
fn test_bench_once_iter() {
767767
fn f(b: &mut Bencher) -> Result<(), String> {
768768
b.iter(|| {});
769769
Ok(())
@@ -772,7 +772,7 @@ pub fn test_bench_once_iter() {
772772
}
773773

774774
#[test]
775-
pub fn test_bench_no_iter() {
775+
fn test_bench_no_iter() {
776776
fn f(_: &mut Bencher) -> Result<(), String> {
777777
Ok(())
778778
}
@@ -799,7 +799,7 @@ pub fn test_bench_no_iter() {
799799
}
800800

801801
#[test]
802-
pub fn test_bench_iter() {
802+
fn test_bench_iter() {
803803
fn f(b: &mut Bencher) -> Result<(), String> {
804804
b.iter(|| {});
805805
Ok(())

‎library/test/src/time.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{env, fmt};
1111

1212
use super::types::{TestDesc, TestType};
1313

14-
pub const TEST_WARN_TIMEOUT_S: u64 = 60;
14+
pub(crate) const TEST_WARN_TIMEOUT_S: u64 = 60;
1515

1616
/// This small module contains constants used by `report-time` option.
1717
/// Those constants values will be used if corresponding environment variables are not set.
@@ -22,42 +22,42 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60;
2222
///
2323
/// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means
2424
/// warn time, and 200 means critical time.
25-
pub mod time_constants {
25+
pub(crate) mod time_constants {
2626
use std::time::Duration;
2727

2828
use super::TEST_WARN_TIMEOUT_S;
2929

3030
/// Environment variable for overriding default threshold for unit-tests.
31-
pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT";
31+
pub(crate) const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT";
3232

3333
// Unit tests are supposed to be really quick.
34-
pub const UNIT_WARN: Duration = Duration::from_millis(50);
35-
pub const UNIT_CRITICAL: Duration = Duration::from_millis(100);
34+
pub(crate) const UNIT_WARN: Duration = Duration::from_millis(50);
35+
pub(crate) const UNIT_CRITICAL: Duration = Duration::from_millis(100);
3636

3737
/// Environment variable for overriding default threshold for unit-tests.
38-
pub const INTEGRATION_ENV_NAME: &str = "RUST_TEST_TIME_INTEGRATION";
38+
pub(crate) const INTEGRATION_ENV_NAME: &str = "RUST_TEST_TIME_INTEGRATION";
3939

4040
// Integration tests may have a lot of work, so they can take longer to execute.
41-
pub const INTEGRATION_WARN: Duration = Duration::from_millis(500);
42-
pub const INTEGRATION_CRITICAL: Duration = Duration::from_millis(1000);
41+
pub(crate) const INTEGRATION_WARN: Duration = Duration::from_millis(500);
42+
pub(crate) const INTEGRATION_CRITICAL: Duration = Duration::from_millis(1000);
4343

4444
/// Environment variable for overriding default threshold for unit-tests.
45-
pub const DOCTEST_ENV_NAME: &str = "RUST_TEST_TIME_DOCTEST";
45+
pub(crate) const DOCTEST_ENV_NAME: &str = "RUST_TEST_TIME_DOCTEST";
4646

4747
// Doctests are similar to integration tests, because they can include a lot of
4848
// initialization code.
49-
pub const DOCTEST_WARN: Duration = INTEGRATION_WARN;
50-
pub const DOCTEST_CRITICAL: Duration = INTEGRATION_CRITICAL;
49+
pub(crate) const DOCTEST_WARN: Duration = INTEGRATION_WARN;
50+
pub(crate) const DOCTEST_CRITICAL: Duration = INTEGRATION_CRITICAL;
5151

5252
// Do not suppose anything about unknown tests, base limits on the
5353
// `TEST_WARN_TIMEOUT_S` constant.
54-
pub const UNKNOWN_WARN: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S);
55-
pub const UNKNOWN_CRITICAL: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S * 2);
54+
pub(crate) const UNKNOWN_WARN: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S);
55+
pub(crate) const UNKNOWN_CRITICAL: Duration = Duration::from_secs(TEST_WARN_TIMEOUT_S * 2);
5656
}
5757

5858
/// Returns an `Instance` object denoting when the test should be considered
5959
/// timed out.
60-
pub fn get_default_test_timeout() -> Instant {
60+
pub(crate) fn get_default_test_timeout() -> Instant {
6161
Instant::now() + Duration::from_secs(TEST_WARN_TIMEOUT_S)
6262
}
6363

@@ -73,7 +73,7 @@ impl fmt::Display for TestExecTime {
7373

7474
/// The measured execution time of the whole test suite.
7575
#[derive(Debug, Clone, Default, PartialEq)]
76-
pub struct TestSuiteExecTime(pub Duration);
76+
pub(crate) struct TestSuiteExecTime(pub Duration);
7777

7878
impl fmt::Display for TestSuiteExecTime {
7979
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

0 commit comments

Comments
 (0)
Please sign in to comment.