diff --git a/resources/tester/helper_test_all.py b/resources/tester/helper_test_all.py new file mode 100644 index 000000000..35ddc3ac7 --- /dev/null +++ b/resources/tester/helper_test_all.py @@ -0,0 +1,20 @@ +"""시험 표본 · 전수 한 벌 — 기본 = 표본(파일마다 60 초 안쪽) · 전수 = 환경 `AISLO_TEST_ALL=1`. + +옛 이름 `S855_ALL=1` · `S8121_ALL=1` 도 같은 뜻. 전수 한 번에 = `tools/full_sweep_tests.txt` 머리 명령. +표본은 전수의 부분 — 표본에서 실패하는 것은 전수에서도 실패. +""" + +from __future__ import annotations + +import os + +ALL = any(os.environ.get(k) == "1" for k in ("AISLO_TEST_ALL", "S855_ALL", "S8121_ALL")) + + +def spread(items, n: int) -> list: + """전수면 그대로 · 아니면 차례 고르게 n 개(처음 · 끝 포함 · 차례 유지).""" + items = list(items) + if ALL or len(items) <= n: + return items + step = (len(items) - 1) / (n - 1) + return [items[round(i * step)] for i in range(n)] diff --git a/resources/tester/test_800_1_var_symbols.py b/resources/tester/test_800_1_var_symbols.py index 04646b351..02c7239a1 100644 --- a/resources/tester/test_800_1_var_symbols.py +++ b/resources/tester/test_800_1_var_symbols.py @@ -2,6 +2,7 @@ ① 규칙(`master_symbol.rule`) 표본 — 끝말 → 머리글자 · 아래첨자 · 갈래별(찾기 위 「표」 · 요소 · 합 · 결과). ② 입력 · 중간 변수 — 기호에 한글 0 · 한 로직 안 겹침 0 · 같은 이름 같은 기호(원문 796-3 제외). + (한글 0 · 겹침 0 = 기본 로직 차례 고르게 600 · 전수 = `AISLO_TEST_ALL=1`) ③ 빌더 — 채운 정본에 쓸 것 없음 · 채운 것을 걷으면 같은 수만큼 다시 채움. ④ 수식 내보내기 — 표본 로직 전 변수 기호에 한글 0(찾기 · 요소 · 합 · 결과 포함) · 한 로직 안 겹침 없음. ⑤ 보이기만 — 변수표를 걷어도 엔진 셈 · 끝수 지문 같음(금액 전후 같음). @@ -17,6 +18,7 @@ import re from functools import lru_cache import pytest +from helper_test_all import spread from M01_MasterData import M01_MasterData_Store as store @@ -63,7 +65,7 @@ def test_규칙_표본(): def test_기호에_한글_0_한_로직_겹침_0(): - for r in logic_rows(): + for r in spread(logic_rows(), 600): seen: dict[str, str] = {} for v in meq.table(r): assert not HAN.search(v["기호"]), (r["키"], v["열쇠"], v["기호"]) diff --git a/resources/tester/test_801_3_groups.py b/resources/tester/test_801_3_groups.py index 6d9c3f8ac..8d92722d4 100644 --- a/resources/tester/test_801_3_groups.py +++ b/resources/tester/test_801_3_groups.py @@ -2,6 +2,7 @@ ① 묶음 = 부른 단가산출(갈래 블록) 하나씩 + 직접 줄 한 묶음(갈래 직접) · 돈 없는 줄 = 묶음 아님 · 안쪽 말 0 ② M01 전수 — 묶음 합 + 끝수 = 합계(엔진 비목 합 그대로) · 직접 묶음 하나뿐 + (기본 = 호표 로직 키 차례 고르게 600 · 전수 = `AISLO_TEST_ALL=1`) ③ 부품 — 묶음 하나 = 머리 없음 · 계 / 둘 이상 = 머리 · 소계 / 단가산출 둘 이상 = 합계 · 안쪽 말 글 0 """ @@ -11,6 +12,8 @@ import importlib from decimal import Decimal as D from pathlib import Path +from helper_test_all import spread + from M01_MasterData import M01_MasterData_Store as store mf = importlib.import_module("master_formula") @@ -78,29 +81,31 @@ def test_거푸집_한_묶음_굴착기_한_묶음(): def test_M01_전수_묶음_합_끝수_합계_안쪽_말_0(): w = _w() many = seen = 0 - for tid, rows in sorted(w.index.items()): - if mf.mk.GROUP_OF.get(tid) != "로직": + keys = [ + logic["키"] + for tid, rows in sorted(w.index.items()) + if mf.mk.GROUP_OF.get(tid) == "로직" + for logic in rows.values() + if logic.get("호표") + ] + for key in spread(keys, 600): + try: + eq = _export(key) + except mf.FormulaError: continue - for logic in rows.values(): - if not logic.get("호표"): - continue - try: - eq = _export(logic["키"]) - except mf.FormulaError: - continue - sub = eq.get("소계") - if not sub: - continue - seen += 1 - lines = sub["줄"] - assert sum(r["갈래"] == "직접" for r in lines) <= 1, logic["키"] - assert all(r["계"] != 0 for r in lines), logic["키"] - for r in lines: - assert not any(b in r["이름"] for b in BAD), (logic["키"], r["이름"]) - for k in COSTS: - got = sum((r[k] for r in lines), D(0)) + sub["끝수"][k] - assert got == eq["합계"][k], (logic["키"], k) - many += sum(r["갈래"] == "블록" for r in lines) >= 2 + sub = eq.get("소계") + if not sub: + continue + seen += 1 + lines = sub["줄"] + assert sum(r["갈래"] == "직접" for r in lines) <= 1, key + assert all(r["계"] != 0 for r in lines), key + for r in lines: + assert not any(b in r["이름"] for b in BAD), (key, r["이름"]) + for k in COSTS: + got = sum((r[k] for r in lines), D(0)) + sub["끝수"][k] + assert got == eq["합계"][k], (key, k) + many += sum(r["갈래"] == "블록" for r in lines) >= 2 assert seen > 400 and many >= 10, (seen, many) diff --git a/resources/tester/test_810_2_native_doc.py b/resources/tester/test_810_2_native_doc.py index 9c7ce5473..71bf0d72e 100644 --- a/resources/tester/test_810_2_native_doc.py +++ b/resources/tester/test_810_2_native_doc.py @@ -9,6 +9,7 @@ (d) 올림 길(814-1 파일 하나) — 원파일 = 새 HP(단가산출표 판 · 일위대가 없음 · 엑셀 HP 에 안 붙음) · 가져온 식 = 원파일 · 엑셀 HP = 엑셀 길 그대로 원파일 · 실무 엑셀 없으면 그 시험만 skip(다른 PC). +표본(기본) = 원파일마다 블록 차례 고르게 8 개 이상(큰 파일 = 1/50 · main 1,569 → 31) · 전수 = `AISLO_TEST_ALL=1`. """ from __future__ import annotations @@ -28,6 +29,7 @@ for p in (ROOT, HERE): sys.path.insert(0, str(p)) import helper_m02_hopyo_golden as golden # noqa: E402 +from helper_test_all import spread # noqa: E402 from test_810_1_estx import FILES as EST # noqa: E402 from test_810_1_stc import FILES as STC # noqa: E402 @@ -62,6 +64,12 @@ def whole(): return imp._whole() +def picked(saved: dict, few: int = 8) -> dict: + """산근 블록 표본(번 → 블록) — 원파일마다 차례 고르게 · 전수 = AISLO_TEST_ALL=1.""" + nums = fn.numbers(saved) + return {no: nums[no] for no in spread(nums, max(few, len(nums) // 50))} + + def sk_of(out: dict) -> dict: """{로직, 원본} → 저장 없는 가져온 식 SK(만들기 몸과 같은 꼴 · 키 = 시험용).""" row = out["로직"] @@ -80,7 +88,7 @@ def doc_and_money(out: dict) -> tuple[dict, dict, dict]: # ── (a) 전수 ───────────────────────────────────────────────────────────── def _sweep(saved: dict) -> dict: stat = {"블록": 0, "같음": 0, "표지없는틀린줄": 0, "다름": []} - for no, blk in fn.numbers(saved).items(): + for no, blk in picked(saved).items(): out = fn.emit(saved, no) sk, _, got = doc_and_money(out) mine = {c: got.get(k) for c, k in COST} diff --git a/resources/tester/test_810_3_native_screen.py b/resources/tester/test_810_3_native_screen.py index c33014b78..b864653fc 100644 --- a/resources/tester/test_810_3_native_screen.py +++ b/resources/tester/test_810_3_native_screen.py @@ -9,6 +9,7 @@ (d) 소계 줄 — 합 밖 · 비목 없음(화면 비목 칸 빈칸 · 종류 「소계」 — `line_stack_edit` · `line_stack_out` 글 대조) 원파일 없으면 그 시험만 skip(다른 PC). 추정 표지 수 표 = tmp/s8103/guess.json(일회 기록). +표본(기본) = 원파일마다 블록 차례 고르게 8 개 이상(`test_810_2.picked` · main 1,569 → 31) · 전수 = `AISLO_TEST_ALL=1`. """ from __future__ import annotations @@ -68,7 +69,7 @@ def _file(kind: str, tag: str) -> list[tuple[int, dict, dict, dict]]: """블록마다 (번, 원본, 문서, 서버 답 · 기록) — 서버 길 그대로.""" saved = t2.native(kind, tag) out = [] - for no in t2.fn.numbers(saved): + for no in t2.picked(saved): # 표본(기본) · 전수 = AISLO_TEST_ALL=1 emitted = t2.fn.emit(saved, no) sk = t2.sk_of(emitted) doc = dim.derive(sk, None, t2.whole()) diff --git a/resources/tester/test_812_1_xlsx_golden.py b/resources/tester/test_812_1_xlsx_golden.py index 0f62d6cb4..6ef3924af 100644 --- a/resources/tester/test_812_1_xlsx_golden.py +++ b/resources/tester/test_812_1_xlsx_golden.py @@ -7,13 +7,12 @@ 읽기기 → 원파일 구조 줄과 같음(EST 1,849 · STC 371 블록) · 원파일 자체 엇갈림(같은 글 · 다른 표지)은 `ODD` 로 고정 ③ 금액 — 실무 엑셀 11 = 읽기기 → `M02_Doc_FromNative` → 수식 문서 셈 = 엑셀 블록 금액 100 % -빠른 견본 기본 · 전수 = 환경 S8121_ALL=1 · 파일 없으면 skip(다른 PC). +빠른 견본 기본 · 전수 = 환경 AISLO_TEST_ALL=1(옛 S8121_ALL=1) · 파일 없으면 skip(다른 PC). """ from __future__ import annotations import math -import os import re import sys import unicodedata @@ -33,12 +32,12 @@ import helper_m02_hopyo_golden as golden # noqa: E402 import test_797_1a_import_flags as practice # noqa: E402 import test_810_1_estx as estx # noqa: E402 import test_810_1_stc as stc # noqa: E402 +from helper_test_all import ALL # noqa: E402 from M02_MasterTemplete import M02_Doc_FromNative as fn # noqa: E402 from M02_MasterTemplete import M02_San_Book as book # noqa: E402 from M02_MasterTemplete import M02_San_Xlsx as sx # noqa: E402 -ALL = os.environ.get("S8121_ALL") == "1" F = sx.flat FIELDS = ("연결뜻", "비목", "변수", "줄참조", "결과", "합계") #: 원파일 자체 엇갈림 — 같은 보인 글 · 금액 칸인데 원파일 표지가 다른 줄(엑셀이 못 가름 · 고정) diff --git a/resources/tester/test_812_3_native_layout.py b/resources/tester/test_812_3_native_layout.py index d83e8a071..2220ff3bd 100644 --- a/resources/tester/test_812_3_native_layout.py +++ b/resources/tester/test_812_3_native_layout.py @@ -11,6 +11,7 @@ 수 표 = tmp/s8123/sweep.json(일회 기록) (c) M01 문서 1,518 — 차림 안 바뀜(쌓기 없음 · 왕복 같음 · 거울 같음) 원파일 없으면 그 시험만 skip(다른 PC). +(b) 표본(기본) = 원파일마다 블록 차례 고르게 4 개 이상(main 1,569 → 31) · 전수 = `AISLO_TEST_ALL=1`. """ from __future__ import annotations @@ -177,7 +178,7 @@ def _sweep() -> dict: for tag, path in files.items(): if not path.exists(): continue - for no in t2.fn.numbers(t2.native(kind, tag)): + for no in t2.picked(t2.native(kind, tag), few=4): sk, doc = _doc(kind, tag, no) _, plain = _doc(kind, tag, no, laid=False) stat["블록"] += 1 diff --git a/resources/tester/test_826_2_machine_files.py b/resources/tester/test_826_2_machine_files.py index fecb9708e..6ba1edb8c 100644 --- a/resources/tester/test_826_2_machine_files.py +++ b/resources/tester/test_826_2_machine_files.py @@ -4,6 +4,7 @@ ② 한 대 고침 = 파일 하나만 · 새 기계 = 파일 하나 더함(끝) · 지움 = 파일 하나 지움 · 판 충돌 409 ③ 내 기계 — 옛 `내기계.json` 은 읽을 때 폴더로 한 번 옮김(내용 · 다음 번호 같음 · 옛 파일 지움) ④ 저장 검사 좁히기 — 옛 길(폴더 두 번 읽고 전체 검사 두 번)과 같은 오류 목록(견본 고침 스물) + 기본 = 갈래(기계 · 자재 · 인력 · 유가 · 표 · 로직 · 조합)마다 하나 이상 아홉(`SAMPLE`) · 전수 = `AISLO_TEST_ALL=1` """ from __future__ import annotations @@ -23,6 +24,20 @@ from M02_MasterTemplete import M02_MyMachine as mym ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "resources" / "master_data" / "scripts")) import master_machine_files as mmf # noqa: E402 +from helper_test_all import ALL # noqa: E402 + +#: ④ 기본 표본 — 갈래마다 하나 이상 · 오류 남 · 안 남 둘 다 +SAMPLE = { + "기계 값", + "기계 지움(로직이 씀)", + "자재 지움(로직이 씀)", + "인력 준용 끊김", + "유가 값", + "표 조건 틀림", + "로직 요소 끊김", + "로직 지움(일위대가 문서가 씀)", + "조합 지움", +} REAL = store.FOLDER cm, mk = store.cm, store.mk @@ -229,7 +244,10 @@ def test_narrow_check_same_as_before(master: Path, tmp_path: Path, monkeypatch) ("조합 지움", lambda: _delete(cm.mcb.FILE, combo[-1]), False), ("새 자재", lambda: _add(MT, "MT000008", 이름="sub1임시새자재"), False), ] # fmt: skip + assert SAMPLE <= {name for name, _, _ in cases} for name, make, bad in cases: + if not ALL and name not in SAMPLE: + continue batch = make() want = _old(batch) got = _new(batch) diff --git a/resources/tester/test_855_engine_parity.py b/resources/tester/test_855_engine_parity.py index 3c9088393..4801179bb 100644 --- a/resources/tester/test_855_engine_parity.py +++ b/resources/tester/test_855_engine_parity.py @@ -1,6 +1,6 @@ """855-A 지킴 ① — 로직 전수 옛 엔진 대 새 계산기(저장된 수식 문서) · 걸음 2 동안 「다름 0」 자. -- 기본 입력 전수(관문 · 십여 초) · 옵션 표본 전수 = 환경 `S855_ALL=1`(3 분 남짓). +- 기본 입력 전수(관문 · 십여 초) · 옵션 표본 전수 = 환경 `AISLO_TEST_ALL=1`(옛 `S855_ALL=1` · 3 분 남짓). - 층 L0 합계 · L1 줄 비목 · L2 줄 꼴 · L3 수량 · 단가(`helper_855_engine.level`). - 다름 = 채택된 차이와 같아야 함(합계 = 빌더 `ADOPTED` 그대로 · 줄 비목 = 같은 까닭의 문서만) · 「보임」(보이는 단가만 · 금액 같음)은 허용 갈래로 셈. @@ -9,11 +9,8 @@ from __future__ import annotations -import os - import helper_855_engine as h - -ALL = os.environ.get("S855_ALL") == "1" +from helper_test_all import ALL # noqa: E402 def _diffs(options: bool) -> dict[str, list]: diff --git a/resources/tester/test_855_golden.py b/resources/tester/test_855_golden.py index 03a8c9e85..0a9ae4cce 100644 --- a/resources/tester/test_855_golden.py +++ b/resources/tester/test_855_golden.py @@ -4,6 +4,7 @@ - 다르면 실패 — 계산기 · 수식 문서 · M01 자료가 금액을 바꿨다는 뜻. 자료 · 규칙을 **뜻대로 바꾼 걸음만** 다시 뜸: `./venv/Scripts/python.exe resources/tester/test_855_golden.py --write`(바뀐 키를 커밋 글에). - 옛 엔진을 지운 뒤(2-E4) 옛 → 새 대조(`test_855_engine_parity` · `test_802_2`)를 이것이 대신함. +- 기본 = 로직 키 차례 고르게 300(지문 대조만) · 전수 = `AISLO_TEST_ALL=1`(빠짐 · 새 키까지). """ from __future__ import annotations @@ -17,18 +18,24 @@ FILE = HERE / "golden_855_engine.json" REDO = "./venv/Scripts/python.exe resources/tester/test_855_golden.py --write" -def current() -> dict[str, str]: +def current(n: int | None = None) -> dict[str, str]: import helper_855_engine as h + from helper_test_all import spread rows, _, docs, _ = h.world() - return {str(r["키"]): h.fingerprint(str(r["키"]), r) for r in rows if str(r["키"]) in docs} + rows = [r for r in rows if str(r["키"]) in docs] + rows = spread(rows, n) if n else rows + return {str(r["키"]): h.fingerprint(str(r["키"]), r) for r in rows} def test_새_계산기_답_지문_같음(): + from helper_test_all import ALL + want = json.loads(FILE.read_text("utf-8"))["지문"] - got = current() + got = current(None if ALL else 300) changed = sorted(k for k in want.keys() & got.keys() if want[k] != got[k]) - gone, new = sorted(want.keys() - got.keys()), sorted(got.keys() - want.keys()) + gone = sorted(want.keys() - got.keys()) if ALL else [] + new = sorted(got.keys() - want.keys()) assert not (changed or gone or new), ( f"지문 다름 — 바뀜 {len(changed)} {changed[:20]} · 빠짐 {gone[:20]} · 새 키 {new[:20]}\n" f"뜻대로 금액을 바꾼 걸음이면 다시 뜸: {REDO} (아니면 고친 코드 · 자료를 되짚음)" diff --git a/resources/tester/test_m01_text.py b/resources/tester/test_m01_text.py index d761507ed..ad5832f56 100644 --- a/resources/tester/test_m01_text.py +++ b/resources/tester/test_m01_text.py @@ -1,6 +1,7 @@ """M01 읽는 식 줄(`POST /text`) — 계약 `resources/master_data/_화면_계약.md` 3장. 견본 셋: 산림 13-4-1 메쌓기 · 12-4 합판거푸집 · 12-17-1 펌프카 타설. +「모든 로직을 돌려도 멈추지 않는다」 둘 = 기본 로직 키 차례 고르게 400 · 전수 = `AISLO_TEST_ALL=1`. """ from __future__ import annotations @@ -21,6 +22,7 @@ from M01_MasterData import M01_MasterData_Store as store sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "master_data/scripts")) import master_text as mt # noqa: E402 +from helper_test_all import spread # noqa: E402 REAL = store.FOLDER STACK = "GF000219" # 13-4-1 메쌓기(인력) — 증가율이 걸린 줄 @@ -387,13 +389,12 @@ def test_모든_로직을_값_없이_돌려도_멈추지_않는다() -> None: files = store.cm.load(folder=REAL) master = store.cm.master(REAL) stops = [] - for rows in master.index.values(): - for key in rows: - if key[:2] in mt.mf.mk.GROUP_OF and mt.mf.mk.GROUP_OF[key[:2]] == "로직": - try: - mt.lines(files, key, {}) - except mt._CALC_ERRORS as e: - stops.append((key, str(e))) + keys = [k for rows in master.index.values() for k in rows] + for key in spread([k for k in keys if mt.mf.mk.GROUP_OF.get(k[:2]) == "로직"], 400): + try: + mt.lines(files, key, {}) + except mt._CALC_ERRORS as e: + stops.append((key, str(e))) assert not stops, stops[:3] @@ -413,18 +414,16 @@ def test_자동값으로_모든_로직을_돌려도_멈추지_않는다() -> Non files = store.cm.load(folder=REAL) master = store.cm.master(REAL) stops = [] - for rows in master.index.values(): - for key in rows: - if mt.mf.mk.GROUP_OF.get(key[:2]) != "로직": - continue - given = {n: store._dec(v) for n, v in store.auto(key)["값"].items()} - # 고르기가 빈 입력 = 내 기계 · 불러오기 전용 식(M01 정본 기계가 안 씀) — 자동값 고를 것이 없음 - if any(i.get("고르기") == [] for i in master.logic(key).get("입력", [])): - continue - try: - mt.lines(files, key, given) - except mt._CALC_ERRORS as e: - stops.append((key, str(e))) + keys = [k for rows in master.index.values() for k in rows] + for key in spread([k for k in keys if mt.mf.mk.GROUP_OF.get(k[:2]) == "로직"], 400): + given = {n: store._dec(v) for n, v in store.auto(key)["값"].items()} + # 고르기가 빈 입력 = 내 기계 · 불러오기 전용 식(M01 정본 기계가 안 씀) — 자동값 고를 것이 없음 + if any(i.get("고르기") == [] for i in master.logic(key).get("입력", [])): + continue + try: + mt.lines(files, key, given) + except mt._CALC_ERRORS as e: + stops.append((key, str(e))) assert not stops, stops[:3] diff --git a/tools/full_sweep_tests.txt b/tools/full_sweep_tests.txt new file mode 100644 index 000000000..2c64678a3 --- /dev/null +++ b/tools/full_sweep_tests.txt @@ -0,0 +1,13 @@ +# 전수 한 번에 — 기본 = 표본인 시험(`helper_test_all.py`) + 늘 전수인 느린 시험 · 걸음 끝 · 싱크 앞에 브레인이 돌림 +# AISLO_TEST_ALL=1 ./venv/Scripts/python.exe -m pytest $(grep -v '^#' tools/full_sweep_tests.txt) -q -p no:cacheprovider -rs +resources/tester/test_812_3_native_layout.py +resources/tester/test_810_2_native_doc.py +resources/tester/test_810_3_native_screen.py +resources/tester/test_812_1_xlsx_golden.py +resources/tester/test_m01_text.py +resources/tester/test_801_3_groups.py +resources/tester/test_800_1_var_symbols.py +resources/tester/test_826_2_machine_files.py +resources/tester/test_855_golden.py +resources/tester/test_855_engine_parity.py +resources/tester/test_802_2_convert.py