| 1 | use crate::{ | 
| 2 | diagnostics::Message, | 
|---|
| 3 | parser::{Pattern, Span, Spanned}, | 
|---|
| 4 | }; | 
|---|
| 5 | use std::{num::NonZeroUsize, path::PathBuf, process::ExitStatus}; | 
|---|
| 6 |  | 
|---|
| 7 | /// All the ways in which a test can fail. | 
|---|
| 8 | #[ derive(Debug)] | 
|---|
| 9 | #[ must_use] | 
|---|
| 10 | pub enum Error { | 
|---|
| 11 | /// Got an invalid exit status. | 
|---|
| 12 | ExitStatus { | 
|---|
| 13 | /// The exit status of the command. | 
|---|
| 14 | status: ExitStatus, | 
|---|
| 15 | /// The expected exit status as set in the file or derived from the mode. | 
|---|
| 16 | expected: i32, | 
|---|
| 17 | /// A reason for why the expected exit status was expected | 
|---|
| 18 | reason: Spanned<String>, | 
|---|
| 19 | }, | 
|---|
| 20 | /// A pattern was declared but had no matching error. | 
|---|
| 21 | PatternNotFound { | 
|---|
| 22 | /// The pattern that was not found, and the span of where that pattern was declared. | 
|---|
| 23 | pattern: Spanned<Pattern>, | 
|---|
| 24 | /// Can be `None` when it is expected outside the current file | 
|---|
| 25 | expected_line: Option<NonZeroUsize>, | 
|---|
| 26 | }, | 
|---|
| 27 | /// A diagnostic code matcher was declared but had no matching error. | 
|---|
| 28 | CodeNotFound { | 
|---|
| 29 | /// The code that was not found, and the span of where that code was declared. | 
|---|
| 30 | code: Spanned<String>, | 
|---|
| 31 | /// Can be `None` when it is expected outside the current file | 
|---|
| 32 | expected_line: Option<NonZeroUsize>, | 
|---|
| 33 | }, | 
|---|
| 34 | /// A ui test checking for failure does not have any failure patterns | 
|---|
| 35 | NoPatternsFound, | 
|---|
| 36 | /// A ui test checking for success has failure patterns | 
|---|
| 37 | PatternFoundInPassTest { | 
|---|
| 38 | /// Span of a flag changing the mode (if changed from default). | 
|---|
| 39 | mode: Span, | 
|---|
| 40 | /// Span of the pattern | 
|---|
| 41 | span: Span, | 
|---|
| 42 | }, | 
|---|
| 43 | /// Stderr/Stdout differed from the `.stderr`/`.stdout` file present. | 
|---|
| 44 | OutputDiffers { | 
|---|
| 45 | /// The file containing the expected output that differs from the actual output. | 
|---|
| 46 | path: PathBuf, | 
|---|
| 47 | /// The normalized output from the command. | 
|---|
| 48 | actual: Vec<u8>, | 
|---|
| 49 | /// The unnormalized output from the command. | 
|---|
| 50 | output: Vec<u8>, | 
|---|
| 51 | /// The contents of the file. | 
|---|
| 52 | expected: Vec<u8>, | 
|---|
| 53 | /// A command, that when run, causes the output to get blessed instead of erroring. | 
|---|
| 54 | bless_command: Option<String>, | 
|---|
| 55 | }, | 
|---|
| 56 | /// There were errors that don't have a pattern. | 
|---|
| 57 | ErrorsWithoutPattern { | 
|---|
| 58 | /// The main message of the error. | 
|---|
| 59 | msgs: Vec<Message>, | 
|---|
| 60 | /// File and line information of the error. | 
|---|
| 61 | path: Option<(PathBuf, NonZeroUsize)>, | 
|---|
| 62 | }, | 
|---|
| 63 | /// A comment failed to parse. | 
|---|
| 64 | InvalidComment { | 
|---|
| 65 | /// The comment | 
|---|
| 66 | msg: String, | 
|---|
| 67 | /// The character range in which it was defined. | 
|---|
| 68 | span: Span, | 
|---|
| 69 | }, | 
|---|
| 70 | /// An invalid setting was used. | 
|---|
| 71 | ConfigError(String), | 
|---|
| 72 | /// Conflicting comments | 
|---|
| 73 | MultipleRevisionsWithResults { | 
|---|
| 74 | /// The comment being looked for | 
|---|
| 75 | kind: String, | 
|---|
| 76 | /// The lines where conflicts happened | 
|---|
| 77 | lines: Vec<Span>, | 
|---|
| 78 | }, | 
|---|
| 79 | /// A subcommand (e.g. rustfix) of a test failed. | 
|---|
| 80 | Command { | 
|---|
| 81 | /// The name of the subcommand (e.g. "rustfix"). | 
|---|
| 82 | kind: String, | 
|---|
| 83 | /// The exit status of the command. | 
|---|
| 84 | status: ExitStatus, | 
|---|
| 85 | }, | 
|---|
| 86 | /// This catches crashes of ui tests and reports them along the failed test. | 
|---|
| 87 | Bug(String), | 
|---|
| 88 | /// An auxiliary build failed with its own set of errors. | 
|---|
| 89 | Aux { | 
|---|
| 90 | /// Path to the aux file. | 
|---|
| 91 | path: Spanned<PathBuf>, | 
|---|
| 92 | /// The errors that occurred during the build of the aux file. | 
|---|
| 93 | errors: Vec<Error>, | 
|---|
| 94 | }, | 
|---|
| 95 | /// An error occured applying [`rustfix`] suggestions | 
|---|
| 96 | Rustfix(anyhow::Error), | 
|---|
| 97 | } | 
|---|
| 98 |  | 
|---|
| 99 | pub(crate) type Errors = Vec<Error>; | 
|---|
| 100 |  | 
|---|