forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_agent_governance_check.py
More file actions
624 lines (498 loc) · 26.4 KB
/
Copy pathtest_agent_governance_check.py
File metadata and controls
624 lines (498 loc) · 26.4 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
import json
import os
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[2]
CHECKER = REPO_ROOT / "tools" / "03_code_analysis" / "agent_governance_check.py"
class AgentGovernanceCheckTest(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.repo = Path(self.tmp.name)
self.git("init")
self.git("config", "user.email", "agent-governance@example.com")
self.git("config", "user.name", "Agent Governance Test")
self.write("README.md", "baseline\n")
self.write(
"source/source_io/module_parameter/read_input_item_model.cpp",
'Input_Item item("old_switch");\n',
)
self.git("add", ".")
self.git("commit", "-m", "baseline")
self.base = self.git("rev-parse", "HEAD").stdout.strip()
def tearDown(self):
self.tmp.cleanup()
def git(self, *args):
return subprocess.run(
["git", *args],
cwd=self.repo,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
def write(self, path, content, mode="w"):
target = self.repo / path
target.parent.mkdir(parents=True, exist_ok=True)
with open(target, mode) as handle:
handle.write(content)
def commit_change(self):
self.git("add", ".")
self.git("commit", "-m", "change")
return self.git("rev-parse", "HEAD").stdout.strip()
def run_checker(self, *args):
return subprocess.run(
[sys.executable, str(CHECKER), *args],
cwd=self.repo,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
def assert_blocked_by(self, result, rule):
self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn(rule, result.stdout)
def assert_warns_with_success(self, result, rule):
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn(rule, result.stdout)
def test_detects_crlf_in_changed_text_file(self):
self.write("source/source_base/crlf.cpp", b"int x = 1;\r\n", mode="wb")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "LF line endings")
def test_allows_escaped_crlf_text_in_changed_text_file(self):
self.write("source/source_base/escaped.cpp", 'const char* eol = "\\r\\n";\n')
self.write("source/source_base/CMakeLists.txt", "add_library(escaped escaped.cpp)\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_allows_crlf_in_windows_scripts(self):
self.write("tools/install.bat", b"echo ok\r\n", mode="wb")
self.write("tools/install.cmd", b"echo ok\r\n", mode="wb")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_blocks_when_global_dependency_budget_increases(self):
self.write("source/source_base/global.cpp", "int n = GlobalV::NPROC + PARAM.inp.nbands;\n")
self.write("source/source_base/CMakeLists.txt", "add_library(global global.cpp)\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "Global dependency budget")
self.assertIn("net_delta=2", result.stdout)
def test_warns_when_global_dependency_usage_is_rebalanced(self):
self.write("source/source_base/global.cpp", "int old_n = PARAM.inp.nbands;\n")
self.write("source/source_base/CMakeLists.txt", "add_library(global global.cpp)\n")
self.git("add", ".")
self.git("commit", "-m", "add baseline global usage")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write("source/source_base/global.cpp", "int moved_n = GlobalV::NPROC;\n")
head = self.commit_change()
result = self.run_checker("--base", base, "--head", head)
self.assert_warns_with_success(result, "Global dependency budget")
self.assertIn("net_delta=0", result.stdout)
def test_allows_global_dependency_budget_reduction(self):
self.write("source/source_base/global.cpp", "int old_n = PARAM.inp.nbands;\n")
self.write("source/source_base/CMakeLists.txt", "add_library(global global.cpp)\n")
self.git("add", ".")
self.git("commit", "-m", "add baseline global usage")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write("source/source_base/global.cpp", "int old_n = 0;\n")
head = self.commit_change()
result = self.run_checker("--base", base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertNotIn("Global dependency budget", result.stdout)
def test_allows_global_names_in_documentation(self):
self.write("docs/governance-notes.md", "Mention GlobalV::NPROC and PARAM.inp in documentation.\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_allows_global_names_in_governance_checker_tests(self):
self.write("tools/03_code_analysis/checker_fixture.py", 'pattern = "GlobalV::NPROC and PARAM.inp"\n')
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_blocks_default_parameters_added_to_headers(self):
self.write("source/source_base/defaults.h", "void update_solver(int step = 0);\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "No new default parameters")
def test_ignores_crlf_to_lf_only_changes_for_semantic_added_lines(self):
self.write("source/source_base/defaults.h", b"void update_solver(int step = 0);\r\n", mode="wb")
self.git("add", ".")
self.git("commit", "-m", "add crlf header")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write("source/source_base/defaults.h", "void update_solver(int step = 0);\n")
head = self.commit_change()
result = self.run_checker("--base", base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertNotIn("No new default parameters", result.stdout)
def test_staged_mode_ignores_crlf_to_lf_only_semantic_added_lines(self):
self.write("source/source_base/defaults.h", b"void update_solver(int step = 0);\r\n", mode="wb")
self.git("add", ".")
self.git("commit", "-m", "add crlf header")
self.write("source/source_base/defaults.h", "void update_solver(int step = 0);\n")
self.git("add", ".")
result = self.run_checker("--staged")
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertNotIn("No new default parameters", result.stdout)
def test_allows_for_loop_initializer_in_header(self):
self.write(
"source/source_base/loop_header.h",
"inline int sum(int n) {\n"
" int total = 0;\n"
" for (int i = 0; i < n; ++i) {\n"
" total += i;\n"
" }\n"
" return total;\n"
"}\n",
)
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertNotIn("No new default parameters", result.stdout)
def test_warns_but_does_not_block_for_new_hpp_files(self):
self.write("source/source_base/detail.hpp", "inline int value() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "# listed elsewhere\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("Avoid new .hpp propagation", result.stdout)
def test_blocks_new_source_file_without_cmake_linkage(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "CMake linkage for new sources")
def test_blocks_input_parameter_changes_without_docs_linkage(self):
self.write(
"source/source_io/module_parameter/read_input_item_model.cpp",
'Input_Item item("new_switch");\nitem.default_value = "0";\n',
)
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "INPUT parameter documentation linkage")
def test_allows_parameter_file_comment_only_change_without_docs(self):
self.write(
"source/source_io/module_parameter/read_input_item_model.cpp",
'Input_Item item("old_switch");\n// Keep legacy input switch documented nearby.\n',
)
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_allows_input_item_test_fixture_without_docs(self):
self.write("tools/03_code_analysis/input_fixture.py", 'fixture = "Input_Item item(\\"old_switch\\");"\n')
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_allows_input_parameter_changes_with_required_docs(self):
self.write(
"source/source_io/module_parameter/read_input_item_model.cpp",
'Input_Item item("new_switch");\nitem.default_value = "0";\n',
)
self.write("docs/parameters.yaml", "parameters: []\n")
self.write("docs/advanced/input_files/input-main.md", "# INPUT\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_blocks_input_parameter_change_when_required_docs_are_deleted(self):
self.write("docs/parameters.yaml", "parameters: []\n")
self.write("docs/advanced/input_files/input-main.md", "# INPUT\n")
self.git("add", ".")
self.git("commit", "-m", "add input docs")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write(
"source/source_io/module_parameter/read_input_item_model.cpp",
'Input_Item item("new_switch");\nitem.default_value = "0";\n',
)
(self.repo / "docs" / "parameters.yaml").unlink()
(self.repo / "docs" / "advanced" / "input_files" / "input-main.md").unlink()
head = self.commit_change()
result = self.run_checker("--base", base, "--head", head)
self.assert_blocked_by(result, "INPUT parameter documentation linkage")
def test_blocks_unfilled_pr_template_fields_from_event_payload(self):
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nFix #...\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"- A unit test is added for each new feature or bug fix.\n"
}
}
)
)
result = self.run_checker("--event-path", str(event))
self.assert_blocked_by(result, "PR metadata completeness")
def test_blocks_empty_pr_template_from_event_payload(self):
for body in ("", None):
with self.subTest(body=body):
event = self.repo / "event.json"
event.write_text(json.dumps({"pull_request": {"body": body}}))
result = self.run_checker("--event-path", str(event))
self.assert_blocked_by(result, "PR metadata completeness")
def test_blocks_missing_pr_body_from_event_payload(self):
event = self.repo / "event.json"
event.write_text(json.dumps({"pull_request": {}}))
result = self.run_checker("--event-path", str(event))
self.assert_blocked_by(result, "PR metadata completeness")
def test_skips_pr_metadata_when_event_payload_is_not_a_pull_request(self):
event = self.repo / "event.json"
event.write_text(json.dumps({"workflow_run": {"name": "Agent Governance"}}))
result = self.run_checker("--event-path", str(event))
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertNotIn("PR metadata completeness", result.stdout)
def test_accepts_filled_pr_template_fields_from_event_payload(self):
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue; governance bootstrap.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"Ran python3 -m unittest tools/03_code_analysis/test_agent_governance_check.py.\n\n"
"### What's changed?\n"
"Adds governance checks only; no runtime behavior change.\n\n"
"### Governance Checklist\n"
"Line endings, CMake linkage, and docs rules reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"No core module impact.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--event-path", str(event))
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
def test_warns_for_source_change_without_test_evidence(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "add_library(new_feature new_feature.cpp)\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"Not filled yet.\n\n"
"### What's changed?\n"
"Adds a source file.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base helper only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", self.base, "--head", head, "--event-path", str(event))
self.assert_warns_with_success(result, "Test evidence review")
def test_warns_when_pr_says_no_tests_were_run(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "add_library(new_feature new_feature.cpp)\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"No tests were run.\n\n"
"### What's changed?\n"
"Adds a source file.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base helper only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", self.base, "--head", head, "--event-path", str(event))
self.assert_warns_with_success(result, "Test evidence review")
def test_warns_when_pr_says_no_tests_added_yet(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "add_library(new_feature new_feature.cpp)\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"No tests added yet.\n\n"
"### What's changed?\n"
"Adds a source file.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base helper only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", self.base, "--head", head, "--event-path", str(event))
self.assert_warns_with_success(result, "Test evidence review")
def test_accepts_explicit_no_test_rationale(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "add_library(new_feature new_feature.cpp)\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"Tests not required because documentation only.\n\n"
"### What's changed?\n"
"Adds a source file.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base helper only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", self.base, "--head", head, "--event-path", str(event))
self.assertNotIn("Test evidence review", result.stdout)
def test_warns_for_source_change_without_docs_or_no_docs_reason(self):
self.write("source/source_base/new_feature.cpp", "int new_feature() { return 1; }\n")
self.write("source/source_base/CMakeLists.txt", "add_library(new_feature new_feature.cpp)\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"Ran focused unit tests.\n\n"
"### What's changed?\n"
"Adds a source file.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base helper only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", self.base, "--head", head, "--event-path", str(event))
self.assert_warns_with_success(result, "Documentation sync review")
def test_warns_for_source_header_change_without_test_evidence(self):
self.write("source/source_base/api.h", "void api();\n")
self.git("add", ".")
self.git("commit", "-m", "add header")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write("source/source_base/api.h", "#include <vector>\nvoid api();\n")
head = self.commit_change()
result = self.run_checker("--base", base, "--head", head)
self.assert_warns_with_success(result, "Test evidence review")
def test_warns_for_source_header_change_without_docs_or_no_docs_reason(self):
self.write("source/source_base/api.h", "void api();\n")
self.git("add", ".")
self.git("commit", "-m", "add header")
base = self.git("rev-parse", "HEAD").stdout.strip()
self.write("source/source_base/api.h", "#include <vector>\nvoid api();\n")
head = self.commit_change()
event = self.repo / "event.json"
event.write_text(
json.dumps(
{
"pull_request": {
"body": "### Linked Issue\nNo issue.\n\n"
"### Unit Tests and/or Case Tests for my changes\n"
"Ran focused unit tests.\n\n"
"### What's changed?\n"
"Updates a source header.\n\n"
"### Governance Checklist\n"
"Reviewed.\n\n"
"### INPUT Parameter Changes\n"
"No INPUT parameter changes.\n\n"
"### Core Module Impact\n"
"source/source_base API only.\n\n"
"### Governance Exception\n"
"No exceptions requested.\n"
}
}
)
)
result = self.run_checker("--base", base, "--head", head, "--event-path", str(event))
self.assert_warns_with_success(result, "Documentation sync review")
def test_warns_for_new_header_include(self):
self.write("source/source_base/include_growth.h", "#include <vector>\nclass IncludeGrowth {};\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_warns_with_success(result, "Header dependency review")
def test_merge_base_scoped_comparison_excludes_base_branch_only_changes(self):
self.write("source/source_base/api.h", "void update_solver(int step = 0);\n")
self.git("add", ".")
self.git("commit", "-m", "add legacy default")
base_branch = self.git("branch", "--show-current").stdout.strip()
merge_base = self.git("rev-parse", "HEAD").stdout.strip()
self.git("checkout", "-b", "feature")
self.write("docs/feature.md", "feature docs\n")
head = self.commit_change()
self.git("checkout", base_branch)
self.write("source/source_base/api.h", "void update_solver(int step);\n")
base_tip = self.commit_change()
base_tip_result = self.run_checker("--base", base_tip, "--head", head)
merge_base_result = self.run_checker("--base", merge_base, "--head", head)
self.assertIn("No new default parameters", base_tip_result.stdout)
self.assertNotIn("No new default parameters", merge_base_result.stdout)
self.assertEqual(merge_base_result.returncode, 0, merge_base_result.stdout + merge_base_result.stderr)
def test_blocks_new_heterogeneous_file_without_cmake_linkage(self):
self.write("source/module_hamilt/kernels/new_kernel.cu", "__global__ void k() {}\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "CMake linkage for heterogeneous sources")
def test_blocks_new_cuh_file_without_cmake_linkage(self):
self.write("source/module_hamilt/kernels/new_kernel.cuh", "__device__ int k();\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_blocked_by(result, "CMake linkage for heterogeneous sources")
def test_warns_for_heterogeneous_file_without_test_evidence(self):
self.write("source/module_hamilt/kernels/new_kernel.cu", "__global__ void k() {}\n")
self.write("source/module_hamilt/CMakeLists.txt", "add_library(new_kernel kernels/new_kernel.cu)\n")
head = self.commit_change()
result = self.run_checker("--base", self.base, "--head", head)
self.assert_warns_with_success(result, "Heterogeneous test evidence review")
def test_staged_mode_blocks_global_dependency_budget_increase(self):
self.write("source/source_base/staged.cpp", "int n = GlobalC::ucell.nat;\n")
self.write("source/source_base/CMakeLists.txt", "add_library(staged staged.cpp)\n")
self.git("add", ".")
result = self.run_checker("--staged")
self.assert_blocked_by(result, "Global dependency budget")
def test_rejects_staged_with_base_head(self):
result = self.run_checker("--staged", "--base", self.base, "--head", self.base)
self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("--staged cannot be combined with --base/--head", result.stderr)
if __name__ == "__main__":
unittest.main()