diff --git a/.gitignore b/.gitignore index cd40c16..b43aa62 100644 --- a/.gitignore +++ b/.gitignore @@ -164,7 +164,6 @@ vendor *.lcov dist* -*.html *.log logs/* *.db \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 8474874..6025376 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include src/mutahunter/core/queries/*.scm -include src/mutahunter/core/html/*.html \ No newline at end of file +include src/mutahunter/core/templates/*.html \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8d9fd08..7eb94fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ authors = [{ name = "Steven Jung" }] maintainers = [{ name = "Steven Jung" }] [project.urls] -Homepage = "https://www.mutahunter.ai" +Homepage = "https://mutahunter.ai" Repository = "https://github.com/codeintegrity-ai/mutahunter" [project.optional-dependencies] @@ -39,5 +39,5 @@ mutahunter = "mutahunter.main:run" [tool.setuptools.package-data] mutahunter = [ 'src/mutahunter/core/queries/*.scm', - 'src/mutahunter/core/html/*.html', + 'src/mutahunter/core/templates/*.html', ] diff --git a/src/mutahunter/core/report.py b/src/mutahunter/core/report.py index bab2b0a..889d6f5 100644 --- a/src/mutahunter/core/report.py +++ b/src/mutahunter/core/report.py @@ -5,9 +5,13 @@ import os from typing import Any, Dict, List -from jinja2 import Environment, FileSystemLoader +from jinja2 import ( + Environment, + PackageLoader, + FileSystemLoader, + select_autoescape, +) from importlib import resources - from mutahunter.core.db import MutationDatabase from mutahunter.core.logger import logger @@ -24,10 +28,12 @@ class MutantReport: def __init__(self, db: MutationDatabase) -> None: self.log_file = "logs/_latest/coverage.txt" self.db = db - module_dir = os.path.dirname(__file__) - templates_dir = os.path.join(module_dir, "html") - self.template_env = Environment(loader=FileSystemLoader(templates_dir)) os.makedirs("logs/_latest/html", exist_ok=True) + self.template_env = Environment( + loader=FileSystemLoader(resources.files(__package__).joinpath("templates")) + ) + assert self.template_env.get_template("report_template.html") + assert self.template_env.get_template("file_detail_template.html") def generate_report(self, total_cost: float, line_rate: float) -> None: """ diff --git a/src/mutahunter/core/templates/__init__.py b/src/mutahunter/core/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/mutahunter/core/templates/file_detail_template.html b/src/mutahunter/core/templates/file_detail_template.html new file mode 100644 index 0000000..599679b --- /dev/null +++ b/src/mutahunter/core/templates/file_detail_template.html @@ -0,0 +1,134 @@ + + +
+ + +{{ mutation.original_code }}
to {{ mutation.mutated_code }}
Line Coverage: {{ line_coverage }}%
+ +Mutation Coverage: {{ mutation_coverage }}%
+ +File Name | +Mutants | +Mutation Coverage | +Survived Mutants | +
---|---|---|---|
{{ file.name }} | +{{ file.totalMutants }} | +{{ file.mutationCoverage }}% | +{{ file.survivedMutants }} | +