-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuiltins.rs
More file actions
137 lines (135 loc) · 5.39 KB
/
builtins.rs
File metadata and controls
137 lines (135 loc) · 5.39 KB
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
use regex::Regex;
use super::{FailurePattern, FailureStrategy, Pattern, SuccessPattern};
/// Built-in pattern definitions for common commands.
pub fn builtin_patterns() -> Vec<Pattern> {
vec![
// pytest
Pattern {
command_match: Regex::new(r"(?:^|\b)pytest\b")
.expect("valid regex: pytest command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?P<passed>\d+) passed.*in (?P<time>[\d.]+)s")
.expect("valid regex: pytest success pattern"),
summary: "{passed} passed, {time}s".into(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Tail { lines: 30 },
}),
},
// cargo test
Pattern {
command_match: Regex::new(r"\bcargo\s+test\b")
.expect("valid regex: cargo test command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(
r"test result: ok\. (?P<passed>\d+) passed; (?P<failed>\d+) failed.*finished in (?P<time>[\d.]+)s",
)
.expect("valid regex: cargo test success pattern"),
summary: "{passed} passed, {time}s".into(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Tail { lines: 40 },
}),
},
// go test
Pattern {
command_match: Regex::new(r"\bgo\s+test\b")
.expect("valid regex: go test command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"ok\s+\S+\s+(?P<time>[\d.]+)s")
.expect("valid regex: go test success pattern"),
summary: "ok ({time}s)".into(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Tail { lines: 30 },
}),
},
// jest / vitest
Pattern {
command_match: Regex::new(r"\b(?:jest|vitest|npx\s+(?:jest|vitest))\b")
.expect("valid regex: jest/vitest command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(
r"Tests:\s+(?P<passed>\d+) passed.*Time:\s+(?P<time>[\d.]+)\s*s",
)
.expect("valid regex: jest/vitest success pattern"),
summary: "{passed} passed, {time}s".into(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Tail { lines: 30 },
}),
},
// ruff
Pattern {
command_match: Regex::new(r"\bruff\s+check\b")
.expect("valid regex: ruff check command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"All checks passed")
.expect("valid regex: ruff check success pattern"),
summary: String::new(), // empty = quiet success
}),
failure: None, // show all violations
},
// eslint
Pattern {
command_match: Regex::new(r"\beslint\b")
.expect("valid regex: eslint command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?s).*")
.expect("valid regex: eslint success pattern (always matches)"),
summary: String::new(),
}),
failure: None,
},
// cargo build
Pattern {
command_match: Regex::new(r"\bcargo\s+build\b")
.expect("valid regex: cargo build command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?s).*")
.expect("valid regex: cargo build success pattern (always matches)"),
summary: String::new(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Head { lines: 20 },
}),
},
// go build
Pattern {
command_match: Regex::new(r"\bgo\s+build\b")
.expect("valid regex: go build command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?s).*")
.expect("valid regex: go build success pattern (always matches)"),
summary: String::new(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Head { lines: 20 },
}),
},
// tsc
Pattern {
command_match: Regex::new(r"\btsc\b")
.expect("valid regex: tsc command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?s).*")
.expect("valid regex: tsc success pattern (always matches)"),
summary: String::new(),
}),
failure: Some(FailurePattern {
strategy: FailureStrategy::Head { lines: 20 },
}),
},
// cargo clippy
Pattern {
command_match: Regex::new(r"\bcargo\s+clippy\b")
.expect("valid regex: cargo clippy command_match"),
success: Some(SuccessPattern {
pattern: Regex::new(r"(?s).*")
.expect("valid regex: cargo clippy success pattern (always matches)"),
summary: String::new(),
}),
failure: None,
},
]
}