Skip to content

Commit a415574

Browse files
committed
Move TestResult and co to their own module
1 parent 5983ba8 commit a415574

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

src/dependencies.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use std::{
1111
};
1212

1313
use crate::{
14-
build_aux, status_emitter::StatusEmitter, Config, Errored, Mode, OutputConflictHandling,
14+
build_aux, status_emitter::StatusEmitter, test_result::Errored, Config, Mode,
15+
OutputConflictHandling,
1516
};
1617

1718
#[derive(Default, Debug)]
@@ -300,7 +301,7 @@ impl<'a> BuildManager<'a> {
300301
};
301302
build.done(
302303
&res.as_ref()
303-
.map(|_| crate::TestOk::Ok)
304+
.map(|_| crate::test_result::TestOk::Ok)
304305
.map_err(|()| Errored {
305306
command: Command::new(what.description()),
306307
errors: vec![],

src/lib.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::num::NonZeroUsize;
2323
use std::path::{Component, Path, PathBuf, Prefix};
2424
use std::process::{Command, ExitStatus, Output};
2525
use std::thread;
26+
use test_result::{Errored, TestOk, TestResult, TestRun};
2627

2728
use crate::parser::{Comments, Condition};
2829

@@ -38,6 +39,7 @@ mod parser;
3839
pub mod per_test_config;
3940
mod rustc_stderr;
4041
pub mod status_emitter;
42+
pub mod test_result;
4143

4244
#[cfg(test)]
4345
mod tests;
@@ -161,35 +163,6 @@ pub fn test_command(mut config: Config, path: &Path) -> Result<Command> {
161163
Ok(result)
162164
}
163165

164-
/// The possible non-failure results a single test can have.
165-
pub enum TestOk {
166-
/// The test passed
167-
Ok,
168-
/// The test was ignored due to a rule (`//@only-*` or `//@ignore-*`)
169-
Ignored,
170-
}
171-
172-
/// The possible results a single test can have.
173-
pub type TestResult = Result<TestOk, Errored>;
174-
175-
/// Information about a test failure.
176-
#[derive(Debug)]
177-
pub struct Errored {
178-
/// Command that failed
179-
command: Command,
180-
/// The errors that were encountered.
181-
errors: Vec<Error>,
182-
/// The full stderr of the test run.
183-
stderr: Vec<u8>,
184-
/// The full stdout of the test run.
185-
stdout: Vec<u8>,
186-
}
187-
188-
struct TestRun {
189-
result: TestResult,
190-
status: Box<dyn status_emitter::TestStatus>,
191-
}
192-
193166
/// A version of `run_tests` that allows more fine-grained control over running tests.
194167
///
195168
/// All `configs` are being run in parallel.

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use bstr::{ByteSlice, Utf8Error};
99
use regex::bytes::Regex;
1010

11-
use crate::{filter::Match, rustc_stderr::Level, Error, Errored, Mode};
11+
use crate::{filter::Match, rustc_stderr::Level, test_result::Errored, Error, Mode};
1212

1313
use color_eyre::eyre::{Context, Result};
1414

src/status_emitter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
88
use spanned::Span;
99

1010
use crate::{
11-
github_actions, parser::Pattern, rustc_stderr::Level, Error, Errored, Errors, Format, Message,
12-
TestOk, TestResult,
11+
github_actions, parser::Pattern, rustc_stderr::Level, test_result::Errored,
12+
test_result::TestOk, test_result::TestResult, Error, Errors, Format, Message,
1313
};
1414
use std::{
1515
collections::HashMap,

src/test_result.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Various data structures used for carrying information about test success or failure
2+
3+
use crate::{status_emitter::TestStatus, Error};
4+
use color_eyre::eyre::Result;
5+
use std::process::Command;
6+
7+
/// The possible non-failure results a single test can have.
8+
pub enum TestOk {
9+
/// The test passed
10+
Ok,
11+
/// The test was ignored due to a rule (`//@only-*` or `//@ignore-*`)
12+
Ignored,
13+
}
14+
15+
/// The possible results a single test can have.
16+
pub type TestResult = Result<TestOk, Errored>;
17+
18+
/// Information about a test failure.
19+
#[derive(Debug)]
20+
pub struct Errored {
21+
/// Command that failed
22+
pub(crate) command: Command,
23+
/// The errors that were encountered.
24+
pub(crate) errors: Vec<Error>,
25+
/// The full stderr of the test run.
26+
pub(crate) stderr: Vec<u8>,
27+
/// The full stdout of the test run.
28+
pub(crate) stdout: Vec<u8>,
29+
}
30+
31+
pub(crate) struct TestRun {
32+
pub(crate) result: TestResult,
33+
pub(crate) status: Box<dyn TestStatus>,
34+
}

0 commit comments

Comments
 (0)