/
RunDetails.ts
196 lines (190 loc) · 4.96 KB
/
RunDetails.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import type { VerbosityLevel } from '../configuration/VerbosityLevel';
import type { ExecutionTree } from './ExecutionTree';
import type { Parameters } from '../configuration/Parameters';
/**
* Post-run details produced by {@link check}
*
* A failing property can easily detected by checking the `failed` flag of this structure
*
* @remarks Since 0.0.7
* @public
*/
export type RunDetails<Ts> =
| RunDetailsFailureProperty<Ts>
| RunDetailsFailureTooManySkips<Ts>
| RunDetailsFailureInterrupted<Ts>
| RunDetailsSuccess<Ts>;
/**
* Run reported as failed because
* the property failed
*
* Refer to {@link RunDetailsCommon} for more details
*
* @remarks Since 1.25.0
* @public
*/
export interface RunDetailsFailureProperty<Ts> extends RunDetailsCommon<Ts> {
failed: true;
interrupted: boolean;
counterexample: Ts;
counterexamplePath: string;
error: string;
errorInstance: unknown;
}
/**
* Run reported as failed because
* too many retries have been attempted to generate valid values
*
* Refer to {@link RunDetailsCommon} for more details
*
* @remarks Since 1.25.0
* @public
*/
export interface RunDetailsFailureTooManySkips<Ts> extends RunDetailsCommon<Ts> {
failed: true;
interrupted: false;
counterexample: null;
counterexamplePath: null;
error: null;
errorInstance: null;
}
/**
* Run reported as failed because
* it took too long and thus has been interrupted
*
* Refer to {@link RunDetailsCommon} for more details
*
* @remarks Since 1.25.0
* @public
*/
export interface RunDetailsFailureInterrupted<Ts> extends RunDetailsCommon<Ts> {
failed: true;
interrupted: true;
counterexample: null;
counterexamplePath: null;
error: null;
errorInstance: null;
}
/**
* Run reported as success
*
* Refer to {@link RunDetailsCommon} for more details
*
* @remarks Since 1.25.0
* @public
*/
export interface RunDetailsSuccess<Ts> extends RunDetailsCommon<Ts> {
failed: false;
interrupted: boolean;
counterexample: null;
counterexamplePath: null;
error: null;
errorInstance: null;
}
/**
* Shared part between variants of RunDetails
* @remarks Since 2.2.0
* @public
*/
export interface RunDetailsCommon<Ts> {
/**
* Does the property failed during the execution of {@link check}?
* @remarks Since 0.0.7
*/
failed: boolean;
/**
* Was the execution interrupted?
* @remarks Since 1.19.0
*/
interrupted: boolean;
/**
* Number of runs
*
* - In case of failed property: Number of runs up to the first failure (including the failure run)
* - Otherwise: Number of successful executions
*
* @remarks Since 1.0.0
*/
numRuns: number;
/**
* Number of skipped entries due to failed pre-condition
*
* As `numRuns` it only takes into account the skipped values that occured before the first failure.
* Refer to {@link pre} to add such pre-conditions.
*
* @remarks Since 1.3.0
*/
numSkips: number;
/**
* Number of shrinks required to get to the minimal failing case (aka counterexample)
* @remarks Since 1.0.0
*/
numShrinks: number;
/**
* Seed that have been used by the run
*
* It can be forced in {@link assert}, {@link check}, {@link sample} and {@link statistics} using `Parameters`
* @remarks Since 0.0.7
*/
seed: number;
/**
* In case of failure: the counterexample contains the minimal failing case (first failure after shrinking)
* @remarks Since 0.0.7
*/
counterexample: Ts | null;
/**
* In case of failure: it contains the reason of the failure
* @remarks Since 0.0.7
*/
error: string | null;
/**
* In case of failure: it contains the error that has been thrown if any
* @remarks Since 3.0.0
*/
errorInstance: unknown | null;
/**
* In case of failure: path to the counterexample
*
* For replay purposes, it can be forced in {@link assert}, {@link check}, {@link sample} and {@link statistics} using `Parameters`
*
* @remarks Since 1.0.0
*/
counterexamplePath: string | null;
/**
* List all failures that have occurred during the run
*
* You must enable verbose with at least `Verbosity.Verbose` in `Parameters`
* in order to have values in it
*
* @remarks Since 1.1.0
*/
failures: Ts[];
/**
* Execution summary of the run
*
* Traces the origin of each value encountered during the test and its execution status.
* Can help to diagnose shrinking issues.
*
* You must enable verbose with at least `Verbosity.Verbose` in `Parameters`
* in order to have values in it:
* - Verbose: Only failures
* - VeryVerbose: Failures, Successes and Skipped
*
* @remarks Since 1.9.0
*/
executionSummary: ExecutionTree<Ts>[];
/**
* Verbosity level required by the user
* @remarks Since 1.9.0
*/
verbose: VerbosityLevel;
/**
* Configuration of the run
*
* It includes both local parameters set on {@link check} or {@link assert}
* and global ones specified using {@link configureGlobal}
*
* @remarks Since 1.25.0
*/
runConfiguration: Parameters<Ts>;
}