File size: 1,973 Bytes
0e239c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
from pathlib import Path
import tempfile
import unittest
import sys
sys.path.insert(0,str(Path(__file__).resolve().parent/"reusable_support"))
from batch03_case_reports import parse_report


class ReportTests(unittest.TestCase):
    def test_missing_git_chain_case_is_rejected(self):
        raw = [{'name': str(n), 'pass': True} for n in range(18)]
        text = '\n'.join('CROSSREPO_GIT_CHAIN_CASE ' + json.dumps(r) for r in raw)
        text += '\nCROSSREPO_GIT_CHAIN_SUMMARY ' + json.dumps({'mode': 'p2p', 'executed': 18, 'passed': 18, 'failed': 0, 'real_cli': True, 'provider': '/testbed/npm/pacote/lib/index.js'})
        _, issues, _ = parse_report('buildpkg-npm-cli-8703', 'npm-cli', 'pass_to_pass', text, '', 0, Path('.'))
        self.assertTrue(issues)

    def test_missing_mcp_execution_cannot_be_behavior_failure(self):
        rows, issues, _ = parse_report('mcp-specification-2508', 'spec', 'fail_to_pass', '', 'MODULE_NOT_FOUND', 1, Path('.'))
        self.assertTrue(issues)

    def test_tap_failure_requires_failed_assertion(self):
        with tempfile.TemporaryDirectory() as temp:
            path = Path(temp)
            report = {'assertions': [{'id': 'case', 'ok': True}], 'summaries': [{'plan': {'start': 1, 'end': 1}, 'count': 1}], 'parser_errors': [], 'bailouts': []}
            (path / 'npm-cli-fail_to_pass-tap-report.json').write_text(json.dumps(report))
            _, issues, _ = parse_report('buildpkg-npm-cli-9026', 'npm-cli', 'fail_to_pass', 'TAP version 13', '', 1, path)
            self.assertTrue(issues)

    def test_mcp_summary_cannot_hide_omitted_scenario(self):
        text = 'CONTRACT_PASS core-request-removal\nCONTRACT_SUMMARY ' + json.dumps({'group': 'spec:f2p', 'total': 1, 'passed': 1, 'failed': 0, 'skipped': 0})
        _, issues, _ = parse_report('mcp-specification-2663', 'spec', 'fail_to_pass', text, '', 0, Path('.'))
        self.assertTrue(issues)


if __name__ == '__main__':
    unittest.main()