行数の制限
This commit is contained in:
parent
1d865583b2
commit
6828fe684d
@ -1,7 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
|
sys.path.append(
|
||||||
|
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
from utils.custom_logger import get_logger
|
from utils.custom_logger import get_logger
|
||||||
|
|||||||
@ -5,7 +5,9 @@ class GenerateCoverage:
|
|||||||
"""カバレッジ結果を解析して Markdown テーブルを生成"""
|
"""カバレッジ結果を解析して Markdown テーブルを生成"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coverage_file="pytest-coverage.txt", output_file="coverage_table.md"
|
self,
|
||||||
|
coverage_file="pytest-coverage.txt",
|
||||||
|
output_file="coverage_table.md",
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
初期化
|
初期化
|
||||||
@ -38,18 +40,23 @@ class GenerateCoverage:
|
|||||||
continue
|
continue
|
||||||
# Coverage セクションの終わりを検出(TOTAL行の次の空行)
|
# Coverage セクションの終わりを検出(TOTAL行の次の空行)
|
||||||
if in_coverage_section and (
|
if in_coverage_section and (
|
||||||
line.strip().startswith("TOTAL") or line.strip().startswith("=")
|
line.strip().startswith("TOTAL")
|
||||||
|
or line.strip().startswith("=")
|
||||||
):
|
):
|
||||||
break
|
break
|
||||||
# Coverage データを抽出
|
# Coverage データを抽出
|
||||||
if in_coverage_section:
|
if in_coverage_section:
|
||||||
match = re.match(r"(.+?)\s+(\d+)\s+(\d+)\s+(\d+%)\s*(.*)", line)
|
match = re.match(
|
||||||
|
r"(.+?)\s+(\d+)\s+(\d+)\s+(\d+%)\s*(.*)", line
|
||||||
|
)
|
||||||
if match:
|
if match:
|
||||||
filename = match.group(1).strip()
|
filename = match.group(1).strip()
|
||||||
statements = match.group(2).strip()
|
statements = match.group(2).strip()
|
||||||
missed = match.group(3).strip()
|
missed = match.group(3).strip()
|
||||||
coverage = match.group(4).strip()
|
coverage = match.group(4).strip()
|
||||||
missing_lines = match.group(5).strip() if match.group(5) else "-"
|
missing_lines = (
|
||||||
|
match.group(5).strip() if match.group(5) else "-"
|
||||||
|
)
|
||||||
coverage_info.append(
|
coverage_info.append(
|
||||||
{
|
{
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
@ -71,8 +78,12 @@ class GenerateCoverage:
|
|||||||
print("Parsed coverage data.")
|
print("Parsed coverage data.")
|
||||||
|
|
||||||
# Markdown テーブルヘッダー
|
# Markdown テーブルヘッダー
|
||||||
table_header = "| File | Statements | Missed | Coverage | Missing Lines |\n"
|
table_header = (
|
||||||
table_header += "|------|------------|--------|----------|---------------|\n"
|
"| File | Statements | Missed | Coverage | Missing Lines |\n"
|
||||||
|
)
|
||||||
|
table_header += (
|
||||||
|
"|------|------------|--------|----------|---------------|\n"
|
||||||
|
)
|
||||||
|
|
||||||
# テーブル行を生成
|
# テーブル行を生成
|
||||||
table_rows = [
|
table_rows = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user