diff --git a/.github/workflows/converter-tests.yml b/.github/workflows/converter-tests.yml new file mode 100644 index 0000000..af09990 --- /dev/null +++ b/.github/workflows/converter-tests.yml @@ -0,0 +1,39 @@ +name: converter contracts +on: + push: + branches: [master] + pull_request: +permissions: + contents: read +concurrency: + group: converter-contracts-${{ github.ref }} + cancel-in-progress: true +jobs: + converter: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Match desktop dependency versions + run: python3 scripts/check-converter-lock.py + - name: Rust and LLVM instrumentation + run: rustup toolchain install stable --profile minimal --component llvm-tools-preview + - name: Install pinned coverage runner + run: cargo +stable install cargo-llvm-cov --version 0.9.2 --locked + - name: Production converter tests with locked dependencies + run: cargo +stable llvm-cov --manifest-path converter-tests/Cargo.toml --locked --lcov --output-path converter-coverage.lcov + - name: Export matching LLVM summary + run: cargo +stable llvm-cov report --manifest-path converter-tests/Cargo.toml --json --output-path converter-coverage.json + - name: Coverage gate regression tests + run: python3 scripts/test-converter-coverage.py + - name: Enforce 80 percent on every converter source + run: python3 scripts/check-converter-coverage.py converter-coverage.lcov converter-coverage.json + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 + if: always() + with: + name: converter-line-coverage + path: | + converter-coverage.lcov + converter-coverage.json + if-no-files-found: error + retention-days: 7 diff --git a/.gitignore b/.gitignore index fa0dbbf..acc36e4 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ dist-ssr # agent runtime state .gjc/ + +# Standalone source-including converter tests +/converter-tests/target/ diff --git a/converter-tests/Cargo.lock b/converter-tests/Cargo.lock new file mode 100644 index 0000000..5a58d1e --- /dev/null +++ b/converter-tests/Cargo.lock @@ -0,0 +1,115 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "converter-contract-tests" +version = "0.0.0" +dependencies = [ + "quick-xml", + "serde_json", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/converter-tests/Cargo.toml b/converter-tests/Cargo.toml new file mode 100644 index 0000000..c952329 --- /dev/null +++ b/converter-tests/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "converter-contract-tests" +version = "0.0.0" +edition = "2024" +publish = false + +[dependencies] +quick-xml = "0.42" + +serde_json = "1" + +[workspace] diff --git a/converter-tests/README.md b/converter-tests/README.md new file mode 100644 index 0000000..155decb --- /dev/null +++ b/converter-tests/README.md @@ -0,0 +1,28 @@ +# Converter contract tests (DEV-85) + +This standalone crate compiles the production converter directly with Rust `#[path]` modules. It does not copy or mock the converter and does not need a desktop window, Tauri build, credentials, or network access at test runtime. Existing inline converter unit tests run alongside the new contracts. + +```sh +cargo test --manifest-path converter-tests/Cargo.toml --locked +cargo install cargo-llvm-cov --version 0.9.2 --locked +rustup component add llvm-tools-preview +cargo llvm-cov --manifest-path converter-tests/Cargo.toml --locked --lcov --output-path converter-coverage.lcov +cargo llvm-cov report --manifest-path converter-tests/Cargo.toml --json --output-path converter-coverage.json +python3 scripts/check-converter-coverage.py converter-coverage.lcov converter-coverage.json +``` + +## Fixtures and review + +`fixtures/cases.json` contains 32 synthetic, Confluence-shaped storage/Markdown pairs. These are not exports from a real customer account. They cover headings, inline markup and escaping, nested lists, tables and spans, code fences/CDATA, panels, expand, tasks, links/attachments/images, properties, malformed macros and inert self/reciprocal references. URLs use the reserved `.invalid` domain; no real account data is stored. + +Each expected string was inspected against the storage and the current converter's behavior. Tests compare exact Markdown bytes, including trailing newlines, and repeat conversions to detect instability. Golden changes require a human-readable input/output diff and an explanation. There is intentionally no automatic snapshot-accept command. + +These are **characterization tests, not a declaration that every existing output is ideal**. The two products have different contracts. Studio currently flattens tasks, drops some inline styles, and shows unsupported macros as callouts; export-desktop emits task checkboxes and unsupported-macro comments. Missing targets and malformed input may lose content. The fixtures keep these limitations visible rather than silently changing production behavior in this test-only ticket. + +Neither converter resolves includes recursively or fetches page content. Self/reciprocal reference tests verify bounded, deterministic conversion, not cycle detection in a recursive resolver. The XML entity-like case is a local safety regression; it makes no external request. + +## Coverage gate + +The CI workflow runs on every pull request and default-branch push. LLVM LCOV must name every production converter `.rs` source, and **each file** must have at least 80% line coverage. Missing, duplicate, empty, truncated, inconsistent LCOV/JSON totals, or below-threshold reports fail. Imported error/model support modules are outside the converter scope. The gate excludes lines in trailing `#[cfg(test)]` modules, so test assertions cannot inflate production coverage. The current converter sources put those modules last; preserve that layout or update the gate when refactoring. This is a production line gate, not a branch-coverage claim. CI uploads the raw LCOV and matching LLVM JSON for 7 days. + +The harness dependencies have their own committed `Cargo.lock`, because it is an independent workspace. CI checks every harness registry dependency against the desktop lock version/source/checksum. To refresh, copy `src-tauri/Cargo.lock` to `converter-tests/Cargo.lock` and run `cargo check --manifest-path converter-tests/Cargo.toml` to prune unrelated desktop packages. A production dependency or source-layout change must update this harness as needed; compiling the actual sources makes API drift fail at compile time. Desktop/end-to-end behavior remains the responsibility of the main application's tests. diff --git a/converter-tests/fixtures/cases.json b/converter-tests/fixtures/cases.json new file mode 100644 index 0000000..fc4efef --- /dev/null +++ b/converter-tests/fixtures/cases.json @@ -0,0 +1,162 @@ +[ + { + "markdown": "# Title\n\n## Section\n\n###### Small\n", + "name": "headings", + "storage": "

Title

Section

Small
" + }, + { + "markdown": "Hello **bold** *em* gone `` a`b `` & 한글.\n", + "name": "inline", + "storage": "

Hello bold em gone a`b & 한글.

" + }, + { + "markdown": "- One\n - Nested\n- Two\n\n1. Third\n2. Fourth\n", + "name": "lists", + "storage": "
  1. Third
  2. Fourth
" + }, + { + "markdown": "| A | B |\n| --- | --- |\n| x\\|y | line \nnext |\n", + "name": "table", + "storage": "
AB
x|yline
next
" + }, + { + "markdown": "| A & B | |\n| --- | --- |\n| X | Y |\n", + "name": "spans", + "storage": "
A & B
XY
" + }, + { + "markdown": "````js\nconst x = ``;\n```\n````\n", + "name": "code", + "storage": "js`;\n```]]>" + }, + { + "markdown": "```noformat\nraw \ntext\n```\n", + "name": "noformat", + "storage": "\ntext]]>" + }, + { + "markdown": "> [!INFO]\n> Body info\n\n> [!NOTE]\n> Body note\n\n> [!WARNING]\n> Body warning\n\n> [!TIP]\n> Body tip\n\n> [!PANEL]\n> Body panel\n", + "name": "panels", + "storage": "Heading

Body info

Heading

Body note

Heading

Body warning

Heading

Body tip

Heading

Body panel

" + }, + { + "markdown": "> [!EXPAND]\n> Details\n", + "name": "expand", + "storage": "More <now>

Details

" + }, + { + "markdown": "completeDoneincompleteTodo\n", + "name": "tasks", + "storage": "completeDoneincompleteTodo" + }, + { + "markdown": "> Quote\n>\n> Second\n\n```\nraw \n```\n\n---\n", + "name": "quote-pre", + "storage": "

Quote

Second

raw <x>

" + }, + { + "markdown": "[Link](https://example.invalid/a(b)) [Wiki](/spaces/S/pages/2) No target\n", + "name": "links", + "storage": "

Link Wiki No target

" + }, + { + "markdown": "Other page\n", + "name": "page-links", + "storage": "

" + }, + { + "markdown": "Missing Jump\n", + "name": "missing-links", + "storage": "

Jump

" + }, + { + "markdown": "![](diagram.png)![External](https://example.invalid/image.png)\n", + "name": "images", + "storage": "

\"External\"/

" + }, + { + "markdown": "Download\n", + "name": "attachment-link", + "storage": "

Download

" + }, + { + "markdown": "> [!PAGE-PROPERTIES]\n> | Owner | Team A |\n> | --- | --- |\n> | Status | Ready |\n", + "name": "properties", + "storage": "
OwnerTeam A
StatusReady
" + }, + { + "markdown": "> [!CUSTOM]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n> key: value\n", + "name": "unknown-macro", + "storage": "value" + }, + { + "markdown": "> [!CUSTOM]\n> Preserved body\n", + "name": "rich-unknown", + "storage": "

Preserved body

" + }, + { + "markdown": "Before\n", + "name": "malformed", + "storage": "

Before

[!INCLUDE]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n", + "name": "cyclic-reference", + "storage": "

Self

Self" + }, + { + "markdown": " \"quote\" & A &unknown;\n", + "name": "entities", + "storage": "

<tag> "quote" & A &unknown;

" + }, + { + "markdown": "\n\n```\n\n```\n", + "name": "empty", + "storage": "

" + }, + { + "markdown": "Inside\n\nSpan under 2n \nend\n", + "name": "transparent", + "storage": "

Inside

Span under 2n
end

" + }, + { + "markdown": "TermMeaningOnlyNextLoose\n", + "name": "definitions", + "storage": "
Term
Meaning
Only
Next
Loose
" + }, + { + "markdown": "![A](https://example.invalid/a.png)Caption\n", + "name": "figure", + "storage": "
\"A\"/
Caption
" + }, + { + "markdown": "> [!STATUS]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n> title: Ready\n> colour: green\n\n> [!DATE]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n> value: 2026-01-02\n\n> [!JIRA]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n> key: DEV-1\n> server: https://example.invalid\n", + "name": "status-date-jira", + "storage": "Readygreen2026-01-02DEV-1https://example.invalid" + }, + { + "markdown": "Attention\n\nWarn\n", + "name": "panel-div", + "storage": "

Attention

Warn

" + }, + { + "markdown": "Todayxhidden[spaced](a b)\n", + "name": "inline-extras", + "storage": "

x hiddenspaced

" + }, + { + "markdown": "| A | |\n| --- | --- |\n| B | C |\n", + "name": "ragged-table", + "storage": "
Caption
A
BC
" + }, + { + "markdown": "- ParentcompleteNestedTail\n", + "name": "nested-tasks", + "storage": "
  • Parent

    completeNested

    Tail

" + }, + { + "markdown": "> [!CODE]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!EXPAND]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!PAGE-PROPERTIES]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!TOC]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!JIRA]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!DATE]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n\n> [!STATUS]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n", + "name": "macro-empty", + "storage": "" + } +] diff --git a/converter-tests/src/lib.rs b/converter-tests/src/lib.rs new file mode 100644 index 0000000..197f184 --- /dev/null +++ b/converter-tests/src/lib.rs @@ -0,0 +1,6 @@ +#[path = "../../src-tauri/src/confluence/convert.rs"] +pub mod converter; + +pub fn golden_convert(s: &str) -> String { + crate::converter::storage_to_markdown(s) +} diff --git a/converter-tests/tests/golden.rs b/converter-tests/tests/golden.rs new file mode 100644 index 0000000..4aec991 --- /dev/null +++ b/converter-tests/tests/golden.rs @@ -0,0 +1,52 @@ +use converter_contract_tests::golden_convert; + +#[test] +fn reviewed_storage_goldens() { + let cases: serde_json::Value = + serde_json::from_str(include_str!("../fixtures/cases.json")).unwrap(); + let cases = cases.as_array().unwrap(); + assert!(cases.len() >= 20, "keep broad storage-format coverage"); + let mut names = std::collections::HashSet::new(); + for case in cases { + let name = case["name"].as_str().unwrap(); + assert!(names.insert(name), "duplicate fixture: {name}"); + let storage = case["storage"].as_str().unwrap(); + let expected = case["markdown"].as_str().unwrap(); + assert_eq!(golden_convert(storage), expected, "fixture: {name}"); + assert_eq!( + golden_convert(storage), + expected, + "repeat must be deterministic: {name}" + ); + } +} + +#[test] +fn hostile_and_truncated_storage_is_bounded() { + // No network resolver exists in these converters. Includes are inert, not expanded. + for input in [ + "A", + "", + "]>

&x;

", + "

\0

", + ] { + let first = golden_convert(input); + assert!(first.len() < 10_000); + assert_eq!(first, golden_convert(input)); + } +} + +#[test] +fn reference_edges_and_includes_stay_inert() { + // Studio has no page context/resolver. Test each edge of A -> B -> A. + for target in ["B", "A"] { + let input = format!( + "{target}" + ); + let expected = format!( + "{target}\n\n> [!INCLUDE]\n> *변환되지 않는 Confluence 매크로입니다. 원본 페이지에서 확인하세요.*\n" + ); + assert_eq!(golden_convert(&input), expected); + } +} diff --git a/scripts/check-converter-coverage.py b/scripts/check-converter-coverage.py new file mode 100644 index 0000000..77d7262 --- /dev/null +++ b/scripts/check-converter-coverage.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +"""Enforce >=80% measured production lines per converter source, excluding inline tests.""" +from pathlib import Path +import sys +import json + +root = Path(__file__).resolve().parents[1] +if (root / 'src-tauri/src/confluence/convert.rs').is_file(): + expected = {(root / 'src-tauri/src/confluence/convert.rs').resolve()} +else: + expected = {p.resolve() for p in (root / 'src-tauri/src/converter').rglob('*.rs')} +if not expected: + raise SystemExit('No production converter sources found') +summary = {} +for run in json.loads(Path(sys.argv[2]).read_text())['data']: + for item in run['files']: + path = Path(item['filename']).resolve() + if path in expected: + if path in summary: + raise SystemExit('Duplicate JSON coverage summary') + summary[path] = item +if set(summary) != expected: + raise SystemExit('Missing JSON converter summary') +measured = {} +report = Path(sys.argv[1]).read_text() +if not report.strip().endswith('end_of_record'): + raise SystemExit('Incomplete LCOV report') +for record in report.split('end_of_record'): + fields = record.strip().splitlines() + paths = [line[3:] for line in fields if line.startswith('SF:')] + if not paths: + continue + source = Path(paths[0]).resolve() + if source not in expected: + continue + if source in measured: + raise SystemExit(f'Duplicate coverage: {source}') + totals = {} + for field in fields: + if field.startswith(('LF:', 'LH:')): + key, value = field.split(':', 1) + if key in totals: + raise SystemExit('Duplicate LCOV totals') + totals[key] = int(value) + source_lines = source.read_text().splitlines() + # Rust source files in these converters keep the inline test module last. + cutoff = next((i for i, line in enumerate(source_lines, 1) if line.strip() == '#[cfg(test)]'), len(source_lines) + 1) + hits = {} + for field in fields: + if field.startswith('DA:'): + parts = field[3:].split(',') + number, count = int(parts[0]), int(parts[1]) + if number < 1 or number > len(source_lines) or count < 0 or number in hits: + raise SystemExit(f'Invalid/duplicate line coverage: {source}') + hits[number] = count + # LLVM LF/LH include multi-region lines not listed as separate DA records. + if totals.get('LF') != summary[source]['summary']['lines']['count'] or totals.get('LH') != summary[source]['summary']['lines']['covered'] or totals['LF'] < len(hits) or totals['LH'] < sum(count > 0 for count in hits.values()): + raise SystemExit('Missing or inconsistent LCOV line totals') + json_hits = {} + segments = summary[source]['segments'] + for start, end in zip(segments, segments[1:]): + if start[3] and not start[5]: + for number in range(start[0], end[0] + (end[1] > 1)): + json_hits[number] = max(json_hits.get(number, 0), start[2]) + if hits != json_hits: + raise SystemExit('LCOV line records disagree with LLVM regions') + production = [count for number, count in hits.items() if number < cutoff] + if not production: + raise SystemExit(f'Empty production coverage: {source}') + measured[source] = (sum(count > 0 for count in production), len(production)) +if set(measured) != expected: + raise SystemExit(f'Missing converter coverage: {sorted(map(str, expected - set(measured)))}') +failed = False +for source, (covered, total) in sorted(measured.items()): + print(f'{source.relative_to(root)}: {covered}/{total} ({100 * covered / total:.2f}%) production lines') + failed |= covered * 100 < total * 80 +if failed: + raise SystemExit('Every converter source must have at least 80% production line coverage') diff --git a/scripts/check-converter-lock.py b/scripts/check-converter-lock.py new file mode 100644 index 0000000..0db07eb --- /dev/null +++ b/scripts/check-converter-lock.py @@ -0,0 +1,20 @@ +"""Keep every registry dependency in the harness aligned with the desktop lock.""" +from pathlib import Path +import re + +root = Path(__file__).resolve().parents[1] + +def packages(path): + result = set() + for block in path.read_text().split('[[package]]')[1:]: + fields = dict(re.findall(r'^(name|version|source|checksum) = "([^"]*)"$', block, re.M)) + if 'source' in fields: + result.add(tuple(fields.get(k, '') for k in ('name', 'version', 'source', 'checksum'))) + if not result: + raise SystemExit(f'No dependency packages in {path}') + return result + +extra = packages(root / 'converter-tests/Cargo.lock') - packages(root / 'src-tauri/Cargo.lock') +if extra: + raise SystemExit(f'Harness dependencies differ from desktop lock: {sorted(extra)}') +print('Every harness registry dependency matches the desktop lock version/source/checksum') diff --git a/scripts/test-converter-coverage.py b/scripts/test-converter-coverage.py new file mode 100644 index 0000000..f20333d --- /dev/null +++ b/scripts/test-converter-coverage.py @@ -0,0 +1,59 @@ +"""Fail-closed coverage gate regression tests, standard library only.""" +from pathlib import Path +import json +import subprocess +import tempfile +import unittest + +SCRIPT = Path(__file__).with_name('check-converter-coverage.py').read_text() + + +class CoverageGateTests(unittest.TestCase): + def run_gate(self, counts, *, expected=False, truncate=False, missing=False, + duplicate=False, totals_delta=0, remove_line=False): + with tempfile.TemporaryDirectory() as folder: + root = Path(folder) + (root / 'scripts').mkdir() + script = root / 'scripts/check-converter-coverage.py' + script.write_text(SCRIPT) + source = root / 'src-tauri/src/converter/mod.rs' + source.parent.mkdir(parents=True) + source.write_text('fn a() {}\nfn b() {}\n#[cfg(test)]\n' + 'test line\n' * 9) + segments = [] + for number, count in enumerate(counts, 1): + segments.extend([[number, 1, count, True, True, False], + [number + 1, 1, 0, False, False, False]]) + summary = {'count': len(counts), 'covered': sum(c > 0 for c in counts)} + report = {'data':[{'files':[] if missing else [{'filename':str(source), 'segments':segments, 'summary':{'lines':summary}}]}]} + rows = [f'DA:{i},{c}' for i,c in enumerate(counts, 1)] + if remove_line: + rows.pop() + record = f'SF:{source}\n' + '\n'.join(rows) + f'\nLF:{len(counts)+totals_delta}\nLH:{summary["covered"]}\nend_of_record\n' + if truncate: + record = record.replace('end_of_record', '') + if duplicate: + record *= 2 + path = root / 'coverage.lcov' + path.write_text('' if missing else record) + data = root / 'coverage.json' + data.write_text(json.dumps(report)) + result = subprocess.run(['python3',str(script),str(path),str(data)],capture_output=True,text=True) + self.assertEqual(result.returncode == 0, expected, result.stdout + result.stderr) + + def test_complete(self): self.run_gate([1,1], expected=True) + def test_low(self): self.run_gate([1,0]) + def test_tests_do_not_inflate_production(self): + # Including tests would pass 10/12=83.3%; excluding them must fail 0/2. + self.run_gate([0,0]+[1]*10) + def test_uncovered_tests_do_not_reduce_production(self): + self.run_gate([1,1]+[0]*10, expected=True) + def test_missing(self): self.run_gate([1,1],missing=True) + def test_empty(self): self.run_gate([]) + def test_truncated(self): self.run_gate([1,1],truncate=True) + def test_duplicate(self): self.run_gate([1,1],duplicate=True) + def test_inconsistent_totals(self): self.run_gate([1,1],totals_delta=1) + def test_missing_da(self): self.run_gate([1,1],remove_line=True) + def test_negative_hit(self): self.run_gate([1,-1]) + + +if __name__ == '__main__': unittest.main()