diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:13:50 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:26:52 +1000 |
| commit | 84ac80f1921afc243d71fd0caaa4f2838c294102 (patch) | |
| tree | 29006db815bf547dfd0129910b23b8c54675bd98 /library/test | |
| parent | 118f9350c5b902e462a6dcc4325670f3da701600 (diff) | |
| download | rust-84ac80f1921afc243d71fd0caaa4f2838c294102.tar.gz rust-84ac80f1921afc243d71fd0caaa4f2838c294102.zip | |
Reformat `use` declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
Diffstat (limited to 'library/test')
| -rw-r--r-- | library/test/src/bench.rs | 19 | ||||
| -rw-r--r-- | library/test/src/cli.rs | 2 | ||||
| -rw-r--r-- | library/test/src/console.rs | 24 | ||||
| -rw-r--r-- | library/test/src/formatters/json.rs | 14 | ||||
| -rw-r--r-- | library/test/src/formatters/junit.rs | 13 | ||||
| -rw-r--r-- | library/test/src/formatters/mod.rs | 13 | ||||
| -rw-r--r-- | library/test/src/formatters/pretty.rs | 16 | ||||
| -rw-r--r-- | library/test/src/formatters/terse.rs | 17 | ||||
| -rw-r--r-- | library/test/src/helpers/concurrency.rs | 3 | ||||
| -rw-r--r-- | library/test/src/helpers/shuffle.rs | 5 | ||||
| -rw-r--r-- | library/test/src/lib.rs | 49 | ||||
| -rw-r--r-- | library/test/src/stats/tests.rs | 3 | ||||
| -rw-r--r-- | library/test/src/term.rs | 3 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/mod.rs | 12 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/parm.rs | 4 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/parser/compiled.rs | 3 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/searcher.rs | 3 | ||||
| -rw-r--r-- | library/test/src/term/win.rs | 3 | ||||
| -rw-r--r-- | library/test/src/test_result.rs | 6 | ||||
| -rw-r--r-- | library/test/src/tests.rs | 4 | ||||
| -rw-r--r-- | library/test/src/time.rs | 6 | ||||
| -rw-r--r-- | library/test/src/types.rs | 9 |
22 files changed, 107 insertions, 124 deletions
diff --git a/library/test/src/bench.rs b/library/test/src/bench.rs index 9f34f54c3d6..b71def3b032 100644 --- a/library/test/src/bench.rs +++ b/library/test/src/bench.rs @@ -1,19 +1,16 @@ //! Benchmarking module. -use super::{ - event::CompletedTest, - options::BenchMode, - test_result::TestResult, - types::{TestDesc, TestId}, - Sender, -}; - -use crate::stats; -use std::cmp; -use std::io; use std::panic::{catch_unwind, AssertUnwindSafe}; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; +use std::{cmp, io}; + +use super::event::CompletedTest; +use super::options::BenchMode; +use super::test_result::TestResult; +use super::types::{TestDesc, TestId}; +use super::Sender; +use crate::stats; /// An identity function that *__hints__* to the compiler to be maximally pessimistic about what /// `black_box` could do. diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index b7d24405b77..4ccd825bf8d 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -1,11 +1,11 @@ //! Module converting command-line arguments into test configuration. use std::env; +use std::io::{self, IsTerminal}; use std::path::PathBuf; use super::options::{ColorConfig, Options, OutputFormat, RunIgnored}; use super::time::TestTimeOptions; -use std::io::{self, IsTerminal}; #[derive(Debug)] pub struct TestOpts { diff --git a/library/test/src/console.rs b/library/test/src/console.rs index 7e224d60d9d..4d4cdcf4d7b 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -5,19 +5,19 @@ use std::io; use std::io::prelude::Write; use std::time::Instant; -use super::{ - bench::fmt_bench_samples, - cli::TestOpts, - event::{CompletedTest, TestEvent}, - filter_tests, - formatters::{JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter}, - helpers::{concurrency::get_concurrency, metrics::MetricMap}, - options::{Options, OutputFormat}, - run_tests, term, - test_result::TestResult, - time::{TestExecTime, TestSuiteExecTime}, - types::{NamePadding, TestDesc, TestDescAndFn}, +use super::bench::fmt_bench_samples; +use super::cli::TestOpts; +use super::event::{CompletedTest, TestEvent}; +use super::formatters::{ + JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter, }; +use super::helpers::concurrency::get_concurrency; +use super::helpers::metrics::MetricMap; +use super::options::{Options, OutputFormat}; +use super::test_result::TestResult; +use super::time::{TestExecTime, TestSuiteExecTime}; +use super::types::{NamePadding, TestDesc, TestDescAndFn}; +use super::{filter_tests, run_tests, term}; /// Generic wrapper over stdout. pub enum OutputLocation<T> { diff --git a/library/test/src/formatters/json.rs b/library/test/src/formatters/json.rs index 6245aae17c4..aa1c50641cb 100644 --- a/library/test/src/formatters/json.rs +++ b/library/test/src/formatters/json.rs @@ -1,12 +1,12 @@ -use std::{borrow::Cow, io, io::prelude::Write}; +use std::borrow::Cow; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - test_result::TestResult, - time, - types::TestDesc, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::TestDesc; pub(crate) struct JsonFormatter<T> { out: OutputLocation<T>, diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index a211ebf1ded..96b43200840 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -1,13 +1,12 @@ -use std::io::{self, prelude::Write}; +use std::io::prelude::Write; +use std::io::{self}; use std::time::Duration; use super::OutputFormatter; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - test_result::TestResult, - time, - types::{TestDesc, TestType}, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::{TestDesc, TestType}; pub struct JunitFormatter<T> { out: OutputLocation<T>, diff --git a/library/test/src/formatters/mod.rs b/library/test/src/formatters/mod.rs index bc6ffebc1d3..f1225fecfef 100644 --- a/library/test/src/formatters/mod.rs +++ b/library/test/src/formatters/mod.rs @@ -1,11 +1,10 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState}, - test_result::TestResult, - time, - types::{TestDesc, TestName}, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::{TestDesc, TestName}; mod json; mod junit; diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 22654a3400b..7089eae4330 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -1,14 +1,12 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - bench::fmt_bench_samples, - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - term, - test_result::TestResult, - time, - types::TestDesc, -}; +use crate::bench::fmt_bench_samples; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::types::TestDesc; +use crate::{term, time}; pub(crate) struct PrettyFormatter<T> { out: OutputLocation<T>, diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index 875c66e5fa3..534aa2f3311 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -1,15 +1,12 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - bench::fmt_bench_samples, - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - term, - test_result::TestResult, - time, - types::NamePadding, - types::TestDesc, -}; +use crate::bench::fmt_bench_samples; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::types::{NamePadding, TestDesc}; +use crate::{term, time}; // We insert a '\n' when the output hits 100 columns in quiet mode. 88 test // result chars leaves 12 chars for a progress count like " 11704/12853". diff --git a/library/test/src/helpers/concurrency.rs b/library/test/src/helpers/concurrency.rs index 1854c6a7652..b1545cbec43 100644 --- a/library/test/src/helpers/concurrency.rs +++ b/library/test/src/helpers/concurrency.rs @@ -1,7 +1,8 @@ //! Helper module which helps to determine amount of threads to be used //! during tests execution. -use std::{env, num::NonZero, thread}; +use std::num::NonZero; +use std::{env, thread}; pub fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { diff --git a/library/test/src/helpers/shuffle.rs b/library/test/src/helpers/shuffle.rs index 2ac3bfbd4d6..14389eb0e37 100644 --- a/library/test/src/helpers/shuffle.rs +++ b/library/test/src/helpers/shuffle.rs @@ -1,8 +1,9 @@ -use crate::cli::TestOpts; -use crate::types::{TestDescAndFn, TestId, TestName}; use std::hash::{DefaultHasher, Hasher}; use std::time::{SystemTime, UNIX_EPOCH}; +use crate::cli::TestOpts; +use crate::types::{TestDescAndFn, TestId, TestName}; + pub fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> { opts.shuffle_seed.or_else(|| { if opts.shuffle { diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 71cb796b937..516e3f1300e 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -25,45 +25,39 @@ #![feature(test)] #![allow(internal_features)] +pub use cli::TestOpts; + pub use self::bench::{black_box, Bencher}; pub use self::console::run_tests_console; pub use self::options::{ColorConfig, Options, OutputFormat, RunIgnored, ShouldPanic}; pub use self::types::TestName::*; pub use self::types::*; pub use self::ColorConfig::*; -pub use cli::TestOpts; // Module to be used by rustc to compile tests in libtest pub mod test { - pub use crate::{ - assert_test_result, - bench::Bencher, - cli::{parse_opts, TestOpts}, - filter_tests, - helpers::metrics::{Metric, MetricMap}, - options::{Options, RunIgnored, RunStrategy, ShouldPanic}, - run_test, test_main, test_main_static, - test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}, - time::{TestExecTime, TestTimeOptions}, - types::{ - DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, - TestDescAndFn, TestId, TestName, TestType, - }, + pub use crate::bench::Bencher; + pub use crate::cli::{parse_opts, TestOpts}; + pub use crate::helpers::metrics::{Metric, MetricMap}; + pub use crate::options::{Options, RunIgnored, RunStrategy, ShouldPanic}; + pub use crate::test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}; + pub use crate::time::{TestExecTime, TestTimeOptions}; + pub use crate::types::{ + DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, + TestDescAndFn, TestId, TestName, TestType, }; + pub use crate::{assert_test_result, filter_tests, run_test, test_main, test_main_static}; } -use std::{ - collections::VecDeque, - env, io, - io::prelude::Write, - mem::ManuallyDrop, - panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}, - process::{self, Command, Termination}, - sync::mpsc::{channel, Sender}, - sync::{Arc, Mutex}, - thread, - time::{Duration, Instant}, -}; +use std::collections::VecDeque; +use std::io::prelude::Write; +use std::mem::ManuallyDrop; +use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}; +use std::process::{self, Command, Termination}; +use std::sync::mpsc::{channel, Sender}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use std::{env, io, thread}; pub mod bench; mod cli; @@ -82,6 +76,7 @@ mod types; mod tests; use core::any::Any; + use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::shuffle::{get_shuffle_seed, shuffle_tests}; diff --git a/library/test/src/stats/tests.rs b/library/test/src/stats/tests.rs index 3a6e8401bf1..4b209dcf214 100644 --- a/library/test/src/stats/tests.rs +++ b/library/test/src/stats/tests.rs @@ -1,10 +1,11 @@ use super::*; extern crate test; -use self::test::test::Bencher; use std::io; use std::io::prelude::*; +use self::test::test::Bencher; + // Test vectors generated from R, using the script src/etc/stat-test-vectors.r. macro_rules! assert_approx_eq { diff --git a/library/test/src/term.rs b/library/test/src/term.rs index a14b0d4f5a9..e736e85d469 100644 --- a/library/test/src/term.rs +++ b/library/test/src/term.rs @@ -12,7 +12,8 @@ #![deny(missing_docs)] -use std::io::{self, prelude::*}; +use std::io::prelude::*; +use std::io::{self}; pub(crate) use terminfo::TerminfoTerminal; #[cfg(windows)] diff --git a/library/test/src/term/terminfo/mod.rs b/library/test/src/term/terminfo/mod.rs index 67ba89410cd..67eec3ca50f 100644 --- a/library/test/src/term/terminfo/mod.rs +++ b/library/test/src/term/terminfo/mod.rs @@ -1,20 +1,18 @@ //! Terminfo database interface. use std::collections::HashMap; -use std::env; -use std::error; -use std::fmt; use std::fs::File; -use std::io::{self, prelude::*, BufReader}; +use std::io::prelude::*; +use std::io::{self, BufReader}; use std::path::Path; - -use super::color; -use super::Terminal; +use std::{env, error, fmt}; use parm::{expand, Param, Variables}; use parser::compiled::{msys_terminfo, parse}; use searcher::get_dbpath_for_term; +use super::{color, Terminal}; + /// A parsed terminfo database entry. #[allow(unused)] #[derive(Debug)] diff --git a/library/test/src/term/terminfo/parm.rs b/library/test/src/term/terminfo/parm.rs index c5b4ef01893..529ec0c36e4 100644 --- a/library/test/src/term/terminfo/parm.rs +++ b/library/test/src/term/terminfo/parm.rs @@ -1,10 +1,10 @@ //! Parameterized string expansion +use std::iter::repeat; + use self::Param::*; use self::States::*; -use std::iter::repeat; - #[cfg(test)] mod tests; diff --git a/library/test/src/term/terminfo/parser/compiled.rs b/library/test/src/term/terminfo/parser/compiled.rs index 5d40b7988b5..e687b3be41f 100644 --- a/library/test/src/term/terminfo/parser/compiled.rs +++ b/library/test/src/term/terminfo/parser/compiled.rs @@ -2,11 +2,12 @@ //! ncurses-compatible compiled terminfo format parsing (term(5)) -use super::super::TermInfo; use std::collections::HashMap; use std::io; use std::io::prelude::*; +use super::super::TermInfo; + #[cfg(test)] mod tests; diff --git a/library/test/src/term/terminfo/searcher.rs b/library/test/src/term/terminfo/searcher.rs index 8b8df34b079..1b29598cf80 100644 --- a/library/test/src/term/terminfo/searcher.rs +++ b/library/test/src/term/terminfo/searcher.rs @@ -2,9 +2,8 @@ //! //! Does not support hashed database, only filesystem! -use std::env; -use std::fs; use std::path::PathBuf; +use std::{env, fs}; #[cfg(test)] mod tests; diff --git a/library/test/src/term/win.rs b/library/test/src/term/win.rs index 65764c0ffc1..ce9cad37f30 100644 --- a/library/test/src/term/win.rs +++ b/library/test/src/term/win.rs @@ -5,8 +5,7 @@ use std::io; use std::io::prelude::*; -use super::color; -use super::Terminal; +use super::{color, Terminal}; /// A Terminal implementation that uses the Win32 Console API. pub(crate) struct WinConsole<T> { diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index 98c54f038da..c5f4b03bfc9 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -1,16 +1,14 @@ use std::any::Any; -use std::process::ExitStatus; - #[cfg(unix)] use std::os::unix::process::ExitStatusExt; +use std::process::ExitStatus; +pub use self::TestResult::*; use super::bench::BenchSamples; use super::options::ShouldPanic; use super::time; use super::types::TestDesc; -pub use self::TestResult::*; - // Return code for secondary process. // Start somewhere other than 0 so we know the return code means what we think // it means. diff --git a/library/test/src/tests.rs b/library/test/src/tests.rs index 43a906ad298..ba2f35362c5 100644 --- a/library/test/src/tests.rs +++ b/library/test/src/tests.rs @@ -1,5 +1,4 @@ use super::*; - use crate::{ console::OutputLocation, formatters::PrettyFormatter, @@ -237,8 +236,9 @@ fn test_should_panic_bad_message() { #[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_non_string_message_type() { - use crate::tests::TrFailedMsg; use std::any::TypeId; + + use crate::tests::TrFailedMsg; fn f() -> Result<(), String> { std::panic::panic_any(1i32); } diff --git a/library/test/src/time.rs b/library/test/src/time.rs index 7fd69d7f7e7..02ae050db55 100644 --- a/library/test/src/time.rs +++ b/library/test/src/time.rs @@ -5,10 +5,9 @@ //! - Provide helpers for `report-time` and `measure-time` options. //! - Provide newtypes for executions times. -use std::env; -use std::fmt; use std::str::FromStr; use std::time::{Duration, Instant}; +use std::{env, fmt}; use super::types::{TestDesc, TestType}; @@ -24,9 +23,10 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60; /// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means /// warn time, and 200 means critical time. pub mod time_constants { - use super::TEST_WARN_TIMEOUT_S; use std::time::Duration; + use super::TEST_WARN_TIMEOUT_S; + /// Environment variable for overriding default threshold for unit-tests. pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT"; diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 6a7035a8e29..c3be3466cb9 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -4,15 +4,14 @@ use std::borrow::Cow; use std::fmt; use std::sync::mpsc::Sender; -use super::__rust_begin_short_backtrace; -use super::bench::Bencher; -use super::event::CompletedTest; -use super::options; - pub use NamePadding::*; pub use TestFn::*; pub use TestName::*; +use super::bench::Bencher; +use super::event::CompletedTest; +use super::{__rust_begin_short_backtrace, options}; + /// Type of the test according to the [Rust book](https://doc.rust-lang.org/cargo/guide/tests.html) /// conventions. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
