deepmodebot 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +2 -2
- package/.omp-plugin/marketplace.json +2 -2
- package/README.md +15 -6
- package/bin/deepmodebot.mjs +104 -10
- package/native/dmb-gate/Cargo.toml +1 -1
- package/native/dmb-gate/src/agents.rs +58 -25
- package/native/dmb-gate/src/ci.rs +530 -14
- package/native/dmb-gate/src/main.rs +215 -7
- package/native/dmb-gate/src/reward.rs +1895 -242
- package/native/dmb-gate/src/sim.rs +969 -0
- package/native/dmb-gate/src/slop.rs +1061 -295
- package/package.json +1 -1
- package/plugins/deepmodebot/.antigravity-plugin/plugin.json +1 -1
- package/plugins/deepmodebot/.antigravity-plugin/skills/deep/SKILL.md +1 -1
- package/plugins/deepmodebot/.claude-plugin/plugin.json +1 -1
- package/plugins/deepmodebot/.codex-plugin/plugin.json +2 -2
- package/plugins/deepmodebot/agents/comment-sicko.md +29 -0
- package/plugins/deepmodebot/agents/researcher.md +29 -0
- package/plugins/deepmodebot/agents/reviewer.md +29 -0
- package/plugins/deepmodebot/agents/scout.md +28 -0
- package/plugins/deepmodebot/agents/security-reviewer.md +27 -0
- package/plugins/deepmodebot/commands/deep.md +3 -2
- package/plugins/deepmodebot/commands/tournament.md +1 -1
- package/plugins/deepmodebot/hooks/hooks.json +12 -2
- package/plugins/deepmodebot/hooks.json +1 -1
- package/plugins/deepmodebot/scripts/antigravity-guard.mjs +740 -37
- package/plugins/deepmodebot/skills/agent-harnesses/references/antigravity.md +2 -2
- package/plugins/deepmodebot/skills/deepmodebot/SKILL.md +19 -11
- package/plugins/deepmodebot/skills/deepmodebot/assets/agents-md/agents_md.py +51 -20
- package/plugins/deepmodebot/skills/deepmodebot/assets/autoroute/autoroute.py +54 -49
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude-guard.sh +4 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/claude_guard.py +658 -21
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/holdout_guard_cases.json +272 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/contain/omp-contain.ts +774 -23
- package/plugins/deepmodebot/skills/deepmodebot/assets/f2p-gate/f2p_gate.py +547 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/gap-audit/gap_audit.py +5 -11
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard-patterns.txt +4 -4
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.sh +53 -6
- package/plugins/deepmodebot/skills/deepmodebot/assets/git-guardrails/git-guard.ts +48 -2
- package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/local_ci.py +262 -6
- package/plugins/deepmodebot/skills/deepmodebot/assets/local-ci/slop_gate.py +529 -122
- package/plugins/deepmodebot/skills/deepmodebot/assets/loop/loop.py +747 -46
- package/plugins/deepmodebot/skills/deepmodebot/assets/memory/project_memory.py +404 -5
- package/plugins/deepmodebot/skills/deepmodebot/assets/mutation/mutation_gate.py +798 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/reward-guard/reward_guard.py +2050 -200
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule-paths.json +44 -1
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rule_ledger.py +278 -252
- package/plugins/deepmodebot/skills/deepmodebot/assets/rules/rules_watch.py +436 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/self-grill/self_grill.py +594 -18
- package/plugins/deepmodebot/skills/deepmodebot/assets/setup/project_setup.py +41 -5
- package/plugins/deepmodebot/skills/deepmodebot/assets/sim/sim.py +856 -0
- package/plugins/deepmodebot/skills/deepmodebot/assets/worker-gate/worker_gate.py +237 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/catalog.md +3 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/delegation.md +6 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/authoring-a-skill.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/hillclimb.md +1 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/playbooks/self-authoring.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/principles/no-reward-hacking.md +6 -6
- package/plugins/deepmodebot/skills/deepmodebot/references/rule-approval.md +36 -16
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/autoroute.md +9 -8
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/correct.md +1 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/inner-loop.md +6 -2
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/mutation-testing.md +31 -9
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/no-comments.md +1 -1
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/panel.md +4 -4
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/sim.md +41 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tdd.md +12 -0
- package/plugins/deepmodebot/skills/deepmodebot/references/techniques/tournament.md +24 -13
- package/plugins/deepmodebot/skills/deepmodebot/worker.md +28 -16
- package/plugins/deepmodebot/agents/comment-sicko/agent.md +0 -35
- package/plugins/deepmodebot/agents/researcher/agent.md +0 -33
- package/plugins/deepmodebot/agents/reviewer/agent.md +0 -35
- package/plugins/deepmodebot/agents/scout/agent.md +0 -33
- package/plugins/deepmodebot/agents/security-reviewer/agent.md +0 -31
|
@@ -10,6 +10,8 @@ use std::time::Instant;
|
|
|
10
10
|
pub struct Step {
|
|
11
11
|
pub name: String,
|
|
12
12
|
pub run: String,
|
|
13
|
+
continue_on_error: bool,
|
|
14
|
+
allow_zero_tests: bool,
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
#[derive(Clone, Debug)]
|
|
@@ -17,12 +19,14 @@ pub struct Job {
|
|
|
17
19
|
pub needs: Vec<String>,
|
|
18
20
|
pub inputs: Vec<String>,
|
|
19
21
|
pub steps: Vec<Step>,
|
|
22
|
+
allow_soft_fail: bool,
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
#[derive(Clone, Debug)]
|
|
23
26
|
pub struct Workflow {
|
|
24
27
|
pub name: String,
|
|
25
28
|
pub jobs: BTreeMap<String, Job>,
|
|
29
|
+
allow_soft_fail: bool,
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
fn unquote(s: &str) -> String {
|
|
@@ -37,8 +41,17 @@ fn unquote(s: &str) -> String {
|
|
|
37
41
|
t.to_string()
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
fn bool_field(line: &str, key: &str) -> Option<bool> {
|
|
45
|
+
let (name, value) = line.split_once(':')?;
|
|
46
|
+
(unquote(name) == key).then(|| {
|
|
47
|
+
let value = value.split_once(" #").map_or(value, |(value, _)| value);
|
|
48
|
+
value.trim().eq_ignore_ascii_case("true")
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
41
53
|
let mut wf_name = "local-ci".to_string();
|
|
54
|
+
let mut allow_soft_fail = false;
|
|
42
55
|
let mut jobs: BTreeMap<String, Job> = BTreeMap::new();
|
|
43
56
|
let mut in_jobs = false;
|
|
44
57
|
let mut cur_job: Option<String> = None;
|
|
@@ -47,10 +60,8 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
47
60
|
|
|
48
61
|
let flush_step = |jobs: &mut BTreeMap<String, Job>, cur_job: &Option<String>, cur_step: &mut Option<Step>| {
|
|
49
62
|
if let (Some(jid), Some(st)) = (cur_job.as_ref(), cur_step.take()) {
|
|
50
|
-
if
|
|
51
|
-
|
|
52
|
-
j.steps.push(st);
|
|
53
|
-
}
|
|
63
|
+
if let Some(j) = jobs.get_mut(jid) {
|
|
64
|
+
j.steps.push(st);
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
67
|
};
|
|
@@ -69,6 +80,9 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
69
80
|
in_jobs = true;
|
|
70
81
|
} else {
|
|
71
82
|
in_jobs = false;
|
|
83
|
+
if let Some(value) = bool_field(trimmed, "allow-soft-fail") {
|
|
84
|
+
allow_soft_fail = value;
|
|
85
|
+
}
|
|
72
86
|
}
|
|
73
87
|
continue;
|
|
74
88
|
}
|
|
@@ -84,6 +98,7 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
84
98
|
needs: Vec::new(),
|
|
85
99
|
inputs: Vec::new(),
|
|
86
100
|
steps: Vec::new(),
|
|
101
|
+
allow_soft_fail: false,
|
|
87
102
|
},
|
|
88
103
|
);
|
|
89
104
|
cur_job = Some(jid);
|
|
@@ -119,6 +134,9 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
119
134
|
section = "steps";
|
|
120
135
|
} else {
|
|
121
136
|
section = "";
|
|
137
|
+
if let Some(value) = bool_field(trimmed, "allow-soft-fail") {
|
|
138
|
+
jobs.get_mut(&jid).expect("current job").allow_soft_fail = value;
|
|
139
|
+
}
|
|
122
140
|
}
|
|
123
141
|
continue;
|
|
124
142
|
}
|
|
@@ -136,11 +154,17 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
136
154
|
let mut st = Step {
|
|
137
155
|
name: String::new(),
|
|
138
156
|
run: String::new(),
|
|
157
|
+
continue_on_error: false,
|
|
158
|
+
allow_zero_tests: false,
|
|
139
159
|
};
|
|
140
160
|
if let Some(v) = rest.strip_prefix("name:") {
|
|
141
161
|
st.name = unquote(v);
|
|
142
162
|
} else if let Some(v) = rest.strip_prefix("run:") {
|
|
143
163
|
st.run = unquote(v);
|
|
164
|
+
} else if let Some(value) = bool_field(rest, "continue-on-error") {
|
|
165
|
+
st.continue_on_error = value;
|
|
166
|
+
} else if let Some(value) = bool_field(rest, "allow_zero_tests") {
|
|
167
|
+
st.allow_zero_tests = value;
|
|
144
168
|
}
|
|
145
169
|
cur_step = Some(st);
|
|
146
170
|
} else if let Some(st) = cur_step.as_mut() {
|
|
@@ -148,6 +172,10 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
148
172
|
st.name = unquote(v);
|
|
149
173
|
} else if let Some(v) = trimmed.strip_prefix("run:") {
|
|
150
174
|
st.run = unquote(v);
|
|
175
|
+
} else if let Some(value) = bool_field(trimmed, "continue-on-error") {
|
|
176
|
+
st.continue_on_error = value;
|
|
177
|
+
} else if let Some(value) = bool_field(trimmed, "allow_zero_tests") {
|
|
178
|
+
st.allow_zero_tests = value;
|
|
151
179
|
}
|
|
152
180
|
}
|
|
153
181
|
}
|
|
@@ -156,7 +184,27 @@ pub fn parse_ci_yaml(text: &str) -> Workflow {
|
|
|
156
184
|
Workflow {
|
|
157
185
|
name: wf_name,
|
|
158
186
|
jobs,
|
|
187
|
+
allow_soft_fail,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pub fn validate_workflow(wf: &Workflow) -> Result<(), String> {
|
|
192
|
+
if wf.jobs.is_empty() {
|
|
193
|
+
return Err("missing non-empty `jobs` mapping".into());
|
|
194
|
+
}
|
|
195
|
+
for (id, job) in &wf.jobs {
|
|
196
|
+
if job.steps.is_empty() || job.steps.iter().any(|step| step.run.is_empty()) {
|
|
197
|
+
return Err(format!("job `{id}` has no steps or is missing a `run` command"));
|
|
198
|
+
}
|
|
199
|
+
if !wf.allow_soft_fail && !job.allow_soft_fail {
|
|
200
|
+
if let Some(index) = job.steps.iter().position(|step| step.continue_on_error) {
|
|
201
|
+
return Err(format!(
|
|
202
|
+
"job `{id}` step[{index}] uses `continue-on-error: true` without `allow-soft-fail: true`"
|
|
203
|
+
));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
159
206
|
}
|
|
207
|
+
Ok(())
|
|
160
208
|
}
|
|
161
209
|
|
|
162
210
|
pub fn topo_waves(jobs: &BTreeMap<String, Job>) -> Result<Vec<Vec<String>>, String> {
|
|
@@ -212,14 +260,14 @@ pub fn merkle_job_hash(root: &Path, job: &Job, all_files: &[(String, PathBuf)])
|
|
|
212
260
|
let step_sig: String = job
|
|
213
261
|
.steps
|
|
214
262
|
.iter()
|
|
215
|
-
.map(|s| format!("{}\0{}", s.name, s.run))
|
|
263
|
+
.map(|s| format!("{}\0{}\0{}\0{}", s.name, s.run, s.continue_on_error, s.allow_zero_tests))
|
|
216
264
|
.collect::<Vec<_>>()
|
|
217
265
|
.join("\n");
|
|
218
266
|
let file_hashes: Vec<String> = parallel_map(&matched, |(rel, path)| {
|
|
219
267
|
let bytes = fs::read(path).unwrap_or_default();
|
|
220
268
|
format!("{}:{}", rel, sha256_hex(&bytes))
|
|
221
269
|
});
|
|
222
|
-
let mut payload = String::
|
|
270
|
+
let mut payload = String::from("executed-test-count-v1\0");
|
|
223
271
|
payload.push_str(&root.to_string_lossy());
|
|
224
272
|
payload.push('\n');
|
|
225
273
|
payload.push_str(&step_sig);
|
|
@@ -258,6 +306,350 @@ fn save_cache(path: &Path, cache: &BTreeMap<String, String>) {
|
|
|
258
306
|
let _ = fs::write(path, out);
|
|
259
307
|
}
|
|
260
308
|
|
|
309
|
+
const REPORTERS: [&str; 9] = ["pytest", "unittest", "node", "jest/vitest", "cargo", "go", "dotnet", "maven", "gradle"];
|
|
310
|
+
const RAN: u8 = 1;
|
|
311
|
+
const ZERO: u8 = 2;
|
|
312
|
+
const ERROR: u8 = 4;
|
|
313
|
+
|
|
314
|
+
fn test_runner(mut words: &[&str]) -> Option<&'static str> {
|
|
315
|
+
let exe = loop {
|
|
316
|
+
let word = words.first()?;
|
|
317
|
+
let mut exe = word.rsplit(['/', '\\']).next()?.to_ascii_lowercase();
|
|
318
|
+
for extension in [".exe", ".cmd", ".bat"] {
|
|
319
|
+
if exe.ends_with(extension) {
|
|
320
|
+
exe.truncate(exe.len() - extension.len());
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if word.contains('=') || matches!(exe.as_str(), "env" | "call" | "npx") {
|
|
324
|
+
words = &words[1..];
|
|
325
|
+
} else if (matches!(exe.as_str(), "uv" | "poetry" | "npm" | "pnpm" | "yarn")
|
|
326
|
+
&& words.get(1) == Some(&"exec")) || (matches!(exe.as_str(), "uv" | "poetry") && words.get(1) == Some(&"run"))
|
|
327
|
+
{
|
|
328
|
+
words = &words[2..];
|
|
329
|
+
} else {
|
|
330
|
+
break exe;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
let mut args = &words[1..];
|
|
334
|
+
if exe == "py" || exe.strip_prefix("python").is_some_and(|suffix| suffix.is_empty() ||
|
|
335
|
+
suffix.split('.').all(|s| !s.is_empty() && s.bytes().all(|b| b.is_ascii_digit())))
|
|
336
|
+
{
|
|
337
|
+
while let Some((&word, rest)) = args.split_first() {
|
|
338
|
+
match word {
|
|
339
|
+
"-m" => return match rest.first().copied() {
|
|
340
|
+
Some("pytest") => Some("pytest"),
|
|
341
|
+
Some("unittest") => Some("unittest"),
|
|
342
|
+
_ => None,
|
|
343
|
+
},
|
|
344
|
+
"-" | "--" | "-c" => break,
|
|
345
|
+
"-W" | "-X" => args = rest.get(1..)?,
|
|
346
|
+
_ if word.starts_with('-') => args = rest,
|
|
347
|
+
_ => break,
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return None;
|
|
351
|
+
}
|
|
352
|
+
match exe.as_str() {
|
|
353
|
+
"pytest" => Some("pytest"),
|
|
354
|
+
"jest" | "vitest" => Some("jest/vitest"),
|
|
355
|
+
"node" => {
|
|
356
|
+
while let Some((&word, rest)) = args.split_first() {
|
|
357
|
+
match word {
|
|
358
|
+
"--test" => return Some("node"),
|
|
359
|
+
"--" | "-" | "-e" | "--eval" | "-p" | "--print" => break,
|
|
360
|
+
"-r" | "--require" | "--import" | "--loader" | "--experimental-loader" | "-C"
|
|
361
|
+
| "--conditions" | "--test-reporter" | "--test-reporter-destination" | "--test-name-pattern" => {
|
|
362
|
+
args = rest.get(1..)?;
|
|
363
|
+
}
|
|
364
|
+
_ if word.starts_with('-') => args = rest,
|
|
365
|
+
_ => break,
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
None
|
|
369
|
+
}
|
|
370
|
+
"npm" | "pnpm" | "yarn" => {
|
|
371
|
+
while let Some((&word, rest)) = args.split_first() {
|
|
372
|
+
if !word.starts_with('-') {
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
args = if matches!(word, "--prefix" | "--filter" | "--dir" | "--cwd" | "-C" | "-w" | "--workspace") {
|
|
376
|
+
rest.get(1..)?
|
|
377
|
+
} else {
|
|
378
|
+
rest
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
args = args.strip_prefix(&["run"]).unwrap_or(args);
|
|
382
|
+
matches!(args.first().copied(), Some("test" | "t")).then_some("package-manager")
|
|
383
|
+
}
|
|
384
|
+
"cargo" => {
|
|
385
|
+
if args.first().is_some_and(|word| word.starts_with('+')) {
|
|
386
|
+
args = &args[1..];
|
|
387
|
+
}
|
|
388
|
+
(args.first() == Some(&"test")).then_some("cargo")
|
|
389
|
+
}
|
|
390
|
+
"go" if args.first() == Some(&"test")
|
|
391
|
+
|| args.first() == Some(&"-C") && args.get(2) == Some(&"test") => Some("go"),
|
|
392
|
+
"dotnet" if args.first() == Some(&"test") => Some("dotnet"),
|
|
393
|
+
"mvn" | "mvnw" if args.contains(&"test") => Some("maven"),
|
|
394
|
+
"gradle" | "gradlew" if args.iter().any(|word| word.rsplit(':').next() == Some("test")) => Some("gradle"),
|
|
395
|
+
_ => None,
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
fn test_runners(command: &str) -> HashSet<&'static str> {
|
|
400
|
+
let mut runners = HashSet::new();
|
|
401
|
+
let mut words = Vec::new();
|
|
402
|
+
let (mut start, mut quote, mut at_redirect, mut escaped, mut comment) = (0, None, false, false, false);
|
|
403
|
+
let mut chars = command.char_indices().chain(std::iter::once((command.len(), '\n'))).peekable();
|
|
404
|
+
while let Some((i, c)) = chars.next() {
|
|
405
|
+
if comment && c != '\n' {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if escaped {
|
|
409
|
+
escaped = false;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if c == '\\' && quote != Some('\'') && chars.peek().is_some_and(|(at, next)| *at < command.len()
|
|
413
|
+
&& matches!(next, '\\' | '\'' | '"' | ';' | '&' | '|' | '\n' | ' '))
|
|
414
|
+
{
|
|
415
|
+
escaped = true;
|
|
416
|
+
} else if let Some(q) = quote {
|
|
417
|
+
if c == q {
|
|
418
|
+
quote = None;
|
|
419
|
+
}
|
|
420
|
+
} else if matches!(c, '\'' | '"') {
|
|
421
|
+
quote = Some(c);
|
|
422
|
+
} else if c == '#' && start == i {
|
|
423
|
+
comment = true;
|
|
424
|
+
} else if c.is_whitespace() || matches!(c, ';' | '&' | '|' | '<' | '>') {
|
|
425
|
+
if start != i && !at_redirect && !comment {
|
|
426
|
+
words.push(command[start..i].trim_matches(['\'', '"']));
|
|
427
|
+
}
|
|
428
|
+
start = i + c.len_utf8();
|
|
429
|
+
if matches!(c, ';' | '&' | '|' | '\n') {
|
|
430
|
+
runners.extend(test_runner(&words));
|
|
431
|
+
words.clear();
|
|
432
|
+
at_redirect = false;
|
|
433
|
+
comment = false;
|
|
434
|
+
} else if matches!(c, '<' | '>') {
|
|
435
|
+
at_redirect = true;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
runners
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
fn count_after(line: &str, label: &str) -> Option<u64> {
|
|
443
|
+
let digits = line.split_once(label)?.1.trim_start();
|
|
444
|
+
let n = digits.bytes().take_while(u8::is_ascii_digit).count();
|
|
445
|
+
(n < 20).then(|| digits[..n].parse().ok()).flatten()
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
fn count_before(line: &str, label: &str) -> Option<u64> {
|
|
449
|
+
let digits = line.split_once(label)?.0.split_whitespace().next_back()?;
|
|
450
|
+
(digits.len() < 20 && digits.bytes().all(|b| b.is_ascii_digit())).then(|| digits.parse().ok()).flatten()
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
fn count_report(count: Option<u64>) -> u8 {
|
|
454
|
+
match count {
|
|
455
|
+
Some(0) => ZERO,
|
|
456
|
+
Some(_) => RAN,
|
|
457
|
+
None => 0,
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
fn starts_any(line: &str, prefixes: &[&str]) -> bool {
|
|
462
|
+
prefixes.iter().any(|prefix| line.starts_with(prefix))
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
fn positive_before(line: &str, labels: &[&str]) -> bool {
|
|
466
|
+
labels.iter().any(|label| count_before(line, label).unwrap_or(0) > 0)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
fn test_report(runner: &str, line: &str) -> u8 {
|
|
470
|
+
match runner {
|
|
471
|
+
"pytest" => {
|
|
472
|
+
if starts_any(line, &["error collecting ", "error: "])
|
|
473
|
+
|| line.contains(" during collection") && (line.contains(" error") || line.starts_with("error"))
|
|
474
|
+
{
|
|
475
|
+
return ERROR;
|
|
476
|
+
}
|
|
477
|
+
if starts_any(line, &["collected 0 items", "no tests ran"]) || line.contains(" / 0 selected") {
|
|
478
|
+
return ZERO;
|
|
479
|
+
}
|
|
480
|
+
let summary = line.split_once(" in ").map_or(line, |(s, _)| s);
|
|
481
|
+
let mut words = summary.split_whitespace();
|
|
482
|
+
if words.next().is_some_and(|word| word.bytes().all(|b| b.is_ascii_digit())) &&
|
|
483
|
+
words.next().is_some_and(|status| matches!(status.trim_end_matches(','), "passed" | "failed" | "skipped" | "deselected" | "xfailed" | "xpassed" | "error" | "errors"))
|
|
484
|
+
{
|
|
485
|
+
return if positive_before(summary, &[" passed", " failed", " xfailed", " xpassed"]) { RAN } else { ZERO };
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
"unittest" => {
|
|
489
|
+
if starts_any(line, &["error: ", "failed (errors="]) {
|
|
490
|
+
return ERROR;
|
|
491
|
+
}
|
|
492
|
+
if line.starts_with("ran ") && line.contains(" test") {
|
|
493
|
+
return count_report(count_after(line, "ran "));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
"node" => {
|
|
497
|
+
for prefix in ["# ", "ℹ "] {
|
|
498
|
+
let Some(summary) = line.strip_prefix(prefix) else { continue };
|
|
499
|
+
if summary.starts_with("tests ") {
|
|
500
|
+
return count_report(count_after(summary, "tests "));
|
|
501
|
+
}
|
|
502
|
+
if summary.starts_with("pass ") && count_after(summary, "pass ") == Some(0) {
|
|
503
|
+
return ZERO;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
"jest/vitest" => {
|
|
508
|
+
if starts_any(line, &["test suite failed to run", "error: failed to load config", "unhandled errors"]) {
|
|
509
|
+
return ERROR;
|
|
510
|
+
}
|
|
511
|
+
if starts_any(line, &["no tests found", "no test files found"]) {
|
|
512
|
+
return ZERO;
|
|
513
|
+
}
|
|
514
|
+
if starts_any(line, &["tests:", "tests "]) {
|
|
515
|
+
return if positive_before(line, &[" passed", " failed"]) { RAN } else { ZERO };
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
"cargo" => {
|
|
519
|
+
if starts_any(line, &["error: could not compile", "error[", "error: aborting"]) {
|
|
520
|
+
return ERROR;
|
|
521
|
+
}
|
|
522
|
+
if line.starts_with("test result:") {
|
|
523
|
+
return if positive_before(line, &[" passed;", " failed;"]) { RAN } else { ZERO };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
"go" => {
|
|
527
|
+
if starts_any(line, &["fail ", "fail\t"]) && (line.contains("[build failed]") || line.contains("[setup failed]")) {
|
|
528
|
+
return ERROR;
|
|
529
|
+
}
|
|
530
|
+
if starts_any(line, &["ok ", "ok\t"]) &&
|
|
531
|
+
line.split_whitespace().nth(2).is_some_and(|field| field == "(cached)" ||
|
|
532
|
+
field.strip_suffix('s').and_then(|s| s.split_once('.')).is_some_and(|(seconds, fraction)|
|
|
533
|
+
[seconds, fraction].iter().all(|s| !s.is_empty() && s.bytes().all(|b| b.is_ascii_digit()))))
|
|
534
|
+
&& !line.contains("[no tests to run]")
|
|
535
|
+
{
|
|
536
|
+
return RAN;
|
|
537
|
+
}
|
|
538
|
+
if line.starts_with("--- pass:") {
|
|
539
|
+
return RAN;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
"dotnet" => {
|
|
543
|
+
if starts_any(line, &["error ", "error:", "build failed"]) || line.contains(": error ") {
|
|
544
|
+
return ERROR;
|
|
545
|
+
}
|
|
546
|
+
if starts_any(line, &["passed!", "failed!", "skipped!", "test summary:"]) {
|
|
547
|
+
return if ["failed:", "passed:", "succeeded:"].iter()
|
|
548
|
+
.any(|label| count_after(line, label).unwrap_or(0) > 0) { RAN } else { ZERO };
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
"maven" => {
|
|
552
|
+
let line = line.strip_prefix("[info]").map_or(line, str::trim_start);
|
|
553
|
+
if starts_any(line, &["[error]", "build failure"]) {
|
|
554
|
+
return ERROR;
|
|
555
|
+
}
|
|
556
|
+
if line.starts_with("tests run:") {
|
|
557
|
+
return if count_after(line, "tests run:").unwrap_or(0) > count_after(line, "skipped:").unwrap_or(0) { RAN } else { ZERO };
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
"gradle" => {
|
|
561
|
+
if starts_any(line, &["build failed", "compilation failed", "failure: build failed"]) {
|
|
562
|
+
return ERROR;
|
|
563
|
+
}
|
|
564
|
+
if line.contains(" > ") && (line.ends_with(" passed") || line.ends_with(" failed")) {
|
|
565
|
+
return RAN;
|
|
566
|
+
}
|
|
567
|
+
if line.contains(" tests completed") {
|
|
568
|
+
return count_report(count_before(line, " tests completed"));
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
_ => {}
|
|
572
|
+
}
|
|
573
|
+
0
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
fn normalize_report_line(mut line: &str) -> String {
|
|
577
|
+
let mut cleaned = String::new();
|
|
578
|
+
while let Some((before, after)) = line.split_once("\x1b[") {
|
|
579
|
+
cleaned.push_str(before);
|
|
580
|
+
let control = after.trim_start_matches(|c: char| c.is_ascii_digit() || c == ';');
|
|
581
|
+
if let Some(rest) = control.strip_prefix('m') {
|
|
582
|
+
line = rest;
|
|
583
|
+
} else {
|
|
584
|
+
cleaned.push_str("\x1b[");
|
|
585
|
+
line = after;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
cleaned.push_str(line);
|
|
589
|
+
cleaned
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
fn executed_tests(runner: &str, report: u8) -> bool {
|
|
593
|
+
let aggregate = matches!(runner, "cargo" | "go" | "dotnet" | "maven" | "gradle");
|
|
594
|
+
report & RAN != 0 && (aggregate || report & ZERO == 0)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
fn go_json_report(line: &str) -> u8 {
|
|
598
|
+
use crate::sim::{parse_json, Json};
|
|
599
|
+
if let Ok(Json::Obj(event)) = parse_json(line) {
|
|
600
|
+
if let Some(Json::Str(action)) = event.get("Action") {
|
|
601
|
+
if action == "build-fail" {
|
|
602
|
+
return ERROR;
|
|
603
|
+
}
|
|
604
|
+
if action == "pass" && matches!(event.get("Test"), Some(Json::Str(test)) if !test.is_empty()) {
|
|
605
|
+
return RAN;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
0
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
fn test_count_failure(command: &str, output: &str) -> Option<String> {
|
|
613
|
+
let runners = test_runners(command);
|
|
614
|
+
if runners.is_empty() {
|
|
615
|
+
return None;
|
|
616
|
+
}
|
|
617
|
+
let wrapped = runners.contains("package-manager");
|
|
618
|
+
let mut reports: Vec<_> = REPORTERS.into_iter().filter(|name| wrapped || runners.contains(name))
|
|
619
|
+
.map(|name| (name, 0)).collect();
|
|
620
|
+
for raw in output.lines() {
|
|
621
|
+
let normalized = normalize_report_line(raw);
|
|
622
|
+
let line = normalized.trim().trim_matches('=').trim();
|
|
623
|
+
for (name, report) in &mut reports {
|
|
624
|
+
if *name == "go" && line.starts_with('{') {
|
|
625
|
+
*report |= go_json_report(line);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
let line = line.to_ascii_lowercase();
|
|
629
|
+
for (name, report) in &mut reports {
|
|
630
|
+
*report |= test_report(name, &line);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
for &(runner, report) in &reports {
|
|
634
|
+
if report & ERROR != 0 {
|
|
635
|
+
return Some(format!("Test runner reported a collection or build failure: {runner}."));
|
|
636
|
+
}
|
|
637
|
+
if runners.contains(runner) && !executed_tests(runner, report) {
|
|
638
|
+
return Some(format!("Test runner did not report any executed tests: {runner}."));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if wrapped && !reports.into_iter().any(|(name, report)| executed_tests(name, report)) {
|
|
642
|
+
return Some("Test runner did not report any executed tests: package-manager.".into());
|
|
643
|
+
}
|
|
644
|
+
None
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
fn output_tail(output: &str) -> &str {
|
|
648
|
+
let output = output.trim();
|
|
649
|
+
let start = output.char_indices().rev().nth(599).map_or(0, |(i, _)| i);
|
|
650
|
+
&output[start..]
|
|
651
|
+
}
|
|
652
|
+
|
|
261
653
|
fn run_shell(root: &Path, cmd_str: &str) -> (bool, String) {
|
|
262
654
|
let mut cmd = if cfg!(windows) {
|
|
263
655
|
let mut c = Command::new("cmd");
|
|
@@ -298,13 +690,17 @@ struct JobResult {
|
|
|
298
690
|
pub fn run(args: &[String]) -> ExitCode {
|
|
299
691
|
let mut root = PathBuf::from(".");
|
|
300
692
|
let mut cached = false;
|
|
693
|
+
let mut action = "run";
|
|
301
694
|
let mut as_json = false;
|
|
302
695
|
let mut filter_jobs: HashSet<String> = HashSet::new();
|
|
303
696
|
|
|
304
697
|
let mut i = 0;
|
|
305
698
|
while i < args.len() {
|
|
306
699
|
match args[i].as_str() {
|
|
307
|
-
"run"
|
|
700
|
+
"run" | "validate" | "plan" => {
|
|
701
|
+
action = &args[i];
|
|
702
|
+
i += 1;
|
|
703
|
+
}
|
|
308
704
|
"--root" if i + 1 < args.len() => {
|
|
309
705
|
root = PathBuf::from(&args[i + 1]);
|
|
310
706
|
i += 2;
|
|
@@ -336,6 +732,10 @@ pub fn run(args: &[String]) -> ExitCode {
|
|
|
336
732
|
return ExitCode::from(1);
|
|
337
733
|
};
|
|
338
734
|
let mut wf = parse_ci_yaml(&txt);
|
|
735
|
+
if let Err(error) = validate_workflow(&wf) {
|
|
736
|
+
eprintln!("dmb-gate ci: {error}");
|
|
737
|
+
return ExitCode::from(1);
|
|
738
|
+
}
|
|
339
739
|
if !filter_jobs.is_empty() {
|
|
340
740
|
wf.jobs.retain(|k, _| filter_jobs.contains(k));
|
|
341
741
|
for j in wf.jobs.values_mut() {
|
|
@@ -349,6 +749,30 @@ pub fn run(args: &[String]) -> ExitCode {
|
|
|
349
749
|
return ExitCode::from(1);
|
|
350
750
|
}
|
|
351
751
|
};
|
|
752
|
+
match action {
|
|
753
|
+
"validate" => {
|
|
754
|
+
if as_json {
|
|
755
|
+
println!("{{\"ok\":true}}");
|
|
756
|
+
} else {
|
|
757
|
+
println!("ok");
|
|
758
|
+
}
|
|
759
|
+
return ExitCode::SUCCESS;
|
|
760
|
+
}
|
|
761
|
+
"plan" => {
|
|
762
|
+
if as_json {
|
|
763
|
+
let waves = waves.iter().map(|wave| {
|
|
764
|
+
format!("[{}]", wave.iter().map(|job| json_escape(job)).collect::<Vec<_>>().join(","))
|
|
765
|
+
}).collect::<Vec<_>>().join(",");
|
|
766
|
+
println!("{{\"ok\":true,\"waves\":[{waves}]}}");
|
|
767
|
+
} else {
|
|
768
|
+
for (index, wave) in waves.iter().enumerate() {
|
|
769
|
+
println!("wave {}: {}", index + 1, wave.join(", "));
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return ExitCode::SUCCESS;
|
|
773
|
+
}
|
|
774
|
+
_ => {}
|
|
775
|
+
}
|
|
352
776
|
let t0 = Instant::now();
|
|
353
777
|
let cache_path = root.join(".scratch/dmb-ci-cache.kv");
|
|
354
778
|
let mut cache = if cached {
|
|
@@ -419,11 +843,17 @@ pub fn run(args: &[String]) -> ExitCode {
|
|
|
419
843
|
}
|
|
420
844
|
for step in &job.steps {
|
|
421
845
|
let (ok, output) = run_shell(root_ref, &step.run);
|
|
422
|
-
if
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
846
|
+
let failure = if ok && !step.allow_zero_tests {
|
|
847
|
+
test_count_failure(&step.run, &output)
|
|
848
|
+
} else {
|
|
849
|
+
None
|
|
850
|
+
};
|
|
851
|
+
if failure.is_some() || !ok && !step.continue_on_error {
|
|
852
|
+
let tail = output_tail(&output);
|
|
853
|
+
let tail = match failure {
|
|
854
|
+
Some(reason) if !tail.is_empty() => format!("{reason}\n{tail}"),
|
|
855
|
+
Some(reason) => reason,
|
|
856
|
+
None => tail.to_owned(),
|
|
427
857
|
};
|
|
428
858
|
return JobResult {
|
|
429
859
|
id: jid,
|
|
@@ -477,10 +907,11 @@ pub fn run(args: &[String]) -> ExitCode {
|
|
|
477
907
|
.iter()
|
|
478
908
|
.map(|r| {
|
|
479
909
|
format!(
|
|
480
|
-
"{{\"id\":{},\"status\":{},\"seconds\":{:.3}}}",
|
|
910
|
+
"{{\"id\":{},\"status\":{},\"seconds\":{:.3},\"tail\":{}}}",
|
|
481
911
|
json_escape(&r.id),
|
|
482
912
|
json_escape(r.status),
|
|
483
|
-
r.seconds
|
|
913
|
+
r.seconds,
|
|
914
|
+
json_escape(&r.tail)
|
|
484
915
|
)
|
|
485
916
|
})
|
|
486
917
|
.collect();
|
|
@@ -514,3 +945,88 @@ pub fn run(args: &[String]) -> ExitCode {
|
|
|
514
945
|
ExitCode::SUCCESS
|
|
515
946
|
}
|
|
516
947
|
}
|
|
948
|
+
|
|
949
|
+
#[cfg(test)]
|
|
950
|
+
mod tests {
|
|
951
|
+
use super::*;
|
|
952
|
+
|
|
953
|
+
#[test]
|
|
954
|
+
fn test_count_rejects_zero_and_masks_neither_collection_nor_build_errors() {
|
|
955
|
+
for (command, output, diagnostic) in [
|
|
956
|
+
("pytest -q", "collected 0 items", "executed tests: pytest."),
|
|
957
|
+
("python3.12 -B -m pytest -q", "=== no tests ran in 0.01s ===", "executed tests: pytest."),
|
|
958
|
+
("pytest || echo done", "ERROR collecting tests/test_app.py\n1 error during collection\n1 passed", "failure: pytest."),
|
|
959
|
+
("pytest -k absent", "collected 8 items / 8 deselected / 0 selected", "executed tests: pytest."),
|
|
960
|
+
("python -B -m unittest discover", "Ran 0 tests in 0.000s\n\nOK", "executed tests: unittest."),
|
|
961
|
+
("py -3 -m unittest || echo done", "ERROR: a (unittest.loader._FailedTest.a)\nRan 1 test", "failure: unittest."),
|
|
962
|
+
("node --test", "# tests 0\n# pass 0", "executed tests: node."),
|
|
963
|
+
("node --test --test-reporter=spec", "ℹ tests 2\nℹ pass 0\nℹ skipped 2", "executed tests: node."),
|
|
964
|
+
("npm test", "# tests 0\n# pass 0", "executed tests: package-manager."),
|
|
965
|
+
("pnpm --filter app run test", "No test files found, exiting with code 0", "executed tests: package-manager."),
|
|
966
|
+
("yarn test", "No tests found, exiting with code 0", "executed tests: package-manager."),
|
|
967
|
+
("npx jest --passWithNoTests", "No tests found, exiting with code 0", "executed tests: jest/vitest."),
|
|
968
|
+
("vitest run --passWithNoTests", "No test files found, exiting with code 0", "executed tests: jest/vitest."),
|
|
969
|
+
("vitest run", "Tests 1 passed (1)\nUnhandled Errors", "failure: jest/vitest."),
|
|
970
|
+
("cargo +stable test", "running 0 tests\ntest result: ok. 0 passed; 0 failed;", "executed tests: cargo."),
|
|
971
|
+
("cargo test", "running 2 tests\ntest result: ok. 0 passed; 0 failed; 2 ignored", "executed tests: cargo."),
|
|
972
|
+
("cargo test || echo done", "test result: ok. 1 passed; 0 failed;\nerror: could not compile `app`", "failure: cargo."),
|
|
973
|
+
("go test ./...", "?\ta\t[no test files]\n?\tb\t[no test files]", "executed tests: go."),
|
|
974
|
+
("go -C src test ./...", "ok\ta\t0.018s [no tests to run]", "executed tests: go."),
|
|
975
|
+
("go test ./... || echo done", "ok\ta\t0.018s\nFAIL\tb [build failed]", "failure: go."),
|
|
976
|
+
("go test -json", r#"{"Action":"pass","Package":"a","Elapsed":0.001}"#, "executed tests: go."),
|
|
977
|
+
("dotnet test", "Passed! - Failed: 0, Passed: 0, Skipped: 0, Total: 0", "executed tests: dotnet."),
|
|
978
|
+
("dotnet test", "Test summary: total: 4, failed: 0, succeeded: 0, skipped: 4", "executed tests: dotnet."),
|
|
979
|
+
("mvn clean test", "[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0", "executed tests: maven."),
|
|
980
|
+
("./mvnw test", "[ERROR] COMPILATION ERROR", "failure: maven."),
|
|
981
|
+
("gradle test", "> Task :test NO-SOURCE\nBUILD SUCCESSFUL", "executed tests: gradle."),
|
|
982
|
+
("./gradlew :app:test", "> Task :app:test\n0 tests completed", "executed tests: gradle."),
|
|
983
|
+
] {
|
|
984
|
+
assert!(test_count_failure(command, output).is_some_and(|reason| reason.ends_with(diagnostic)), "{command:?}: {output:?}");
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
#[test]
|
|
989
|
+
fn test_count_accepts_mixed_packages_and_ignores_unknown_commands() {
|
|
990
|
+
for (command, output) in [
|
|
991
|
+
(r#""C:\repo name\venv\Scripts\pytest.exe" -q"#, "\x1b[32m=== 1 passed in 0.1s ===\x1b[0m"),
|
|
992
|
+
("npm test", "# tests 3\n# pass 3"),
|
|
993
|
+
("pnpm run test", "Tests: 1 passed, 1 total"),
|
|
994
|
+
("vitest run", "Tests 1 passed (1)"),
|
|
995
|
+
("cargo test", "running 0 tests\ntest result: ok. 0 passed; 0 failed;\nrunning 1 test\ntest result: ok. 1 passed; 0 failed;"),
|
|
996
|
+
("go test ./...", "?\tempty\t[no test files]\nok\tactual\t0.017s\n?\tlast\t[no test files]"),
|
|
997
|
+
("go test -json", r#"{"Action":"pass","Test":"TestContract","Package":"a","Elapsed":0.001}"#),
|
|
998
|
+
("dotnet test", "Passed! - Failed: 0, Passed: 2, Skipped: 1, Total: 3"),
|
|
999
|
+
("mvn test", "[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 1"),
|
|
1000
|
+
("gradle test", "> Task :old:test NO-SOURCE\nContract > roundTrip PASSED"),
|
|
1001
|
+
(r#"python -c "print('quoted ; pytest')" && echo done"#, "collected 0 items"),
|
|
1002
|
+
("node fixture.js --test", "# tests 0"),
|
|
1003
|
+
("custom-runner test", "no tests ran"),
|
|
1004
|
+
] {
|
|
1005
|
+
assert_eq!(test_count_failure(command, output), None, "{command:?}: {output:?}");
|
|
1006
|
+
}
|
|
1007
|
+
assert!(test_count_failure("echo ready && pytest -q", "collected 0 items").is_some());
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
#[test]
|
|
1011
|
+
fn test_count_opt_out_is_step_local_and_cannot_reuse_a_cached_pass() {
|
|
1012
|
+
let repo = crate::tests::TestRepo::new("test-count");
|
|
1013
|
+
let root = &repo.0;
|
|
1014
|
+
fs::create_dir(root.join(".deepmodebot")).unwrap();
|
|
1015
|
+
fs::create_dir(root.join("suite")).unwrap();
|
|
1016
|
+
fs::write(root.join("suite/helper.py"), "").unwrap();
|
|
1017
|
+
let file = root.join(".deepmodebot/ci.yml");
|
|
1018
|
+
let args = ["run".into(), "--root".into(), root.to_string_lossy().into_owned(), "--cached".into()];
|
|
1019
|
+
let workflow = "name: count\njobs:\n unit:\n inputs:\n - suite/*.py\n steps:\n - run: python -B -m unittest discover -s suite || echo done\n";
|
|
1020
|
+
fs::write(&file, format!("{workflow} allow_zero_tests: true\n")).unwrap();
|
|
1021
|
+
assert_eq!(run(&args), ExitCode::SUCCESS);
|
|
1022
|
+
fs::write(&file, format!("{workflow} allow_zero_tests: \"true\"\n")).unwrap();
|
|
1023
|
+
assert_eq!(run(&args), ExitCode::from(1));
|
|
1024
|
+
fs::write(&file, format!("{workflow} allow_zero_tests: true\n - run: python -B -m unittest discover -s suite || echo done\n")).unwrap();
|
|
1025
|
+
assert_eq!(run(&args), ExitCode::from(1));
|
|
1026
|
+
fs::write(&file, workflow).unwrap();
|
|
1027
|
+
fs::write(root.join("suite/test_contract.py"),
|
|
1028
|
+
"import unittest\nfrom pathlib import Path\nclass Contract(unittest.TestCase):\n def test_input_exists(self):\n self.assertTrue(Path('suite/helper.py').is_file())\n",
|
|
1029
|
+
).unwrap();
|
|
1030
|
+
assert_eq!(run(&args), ExitCode::SUCCESS);
|
|
1031
|
+
}
|
|
1032
|
+
}
|