ruda_test_utils/test_mode/
base.rs1use crate::config::{TestPolicy, config};
9use crate::{TestDecision, TestOutcome, ValidationResult};
10
11pub fn decide(outcome: TestOutcome) -> TestDecision {
13 use TestDecision::*;
14 use TestOutcome::*;
15 use ValidationResult::*;
16
17 let cfg = config();
18 let print_force_fail = cfg.print.enabled && cfg.print.force_fail;
19
20 match cfg.test.policy {
21 TestPolicy::Correct => match outcome {
22 Validated(result) => match result {
23 Pass => {
24 if print_force_fail {
25 Reject("print mode: tensors dumped".into())
26 } else {
27 Accept
28 }
29 }
30 Fail(reason) => Reject(reason),
31 Error(reason) => Reject(reason),
32 Skipped(_) => Accept,
33 },
34 CompileError(reason) => {
35 if print_force_fail {
36 Reject(reason)
37 } else {
38 Accept
39 }
40 }
41 },
42 TestPolicy::Strict => match outcome {
43 Validated(result) => match result {
44 Pass => {
45 if print_force_fail {
46 Reject("print mode: tensors dumped".into())
47 } else {
48 Accept
49 }
50 }
51 Fail(reason) => Reject(reason),
52 Error(reason) => Reject(reason),
53 Skipped(reason) => Reject(reason),
54 },
55 CompileError(reason) => Reject(reason),
56 },
57 TestPolicy::FailIfRun => match outcome {
58 Validated(result) => match result {
59 Pass => Reject("Actually passed, but fail-if-run policy active".into()),
60 Fail(_) => Accept,
61 Error(_) => Accept,
62 Skipped(_) => Accept,
63 },
64 CompileError(_) => Accept,
65 },
66 }
67}