Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
Expand Down
7 changes: 5 additions & 2 deletions src/dvsim/templates/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from collections.abc import Mapping
from importlib import resources
from pathlib import Path

from jinja2 import Environment, PackageLoader, select_autoescape

Expand All @@ -28,9 +29,11 @@ def render_static(path: str) -> str:
string containing the static file content

"""
full_path = Path("dvsim/templates/static") / path

return resources.read_text(
"dvsim",
f"templates/static/{path}",
".".join(full_path.parts[:-1]), # Module path
full_path.name,
)


Expand Down
5 changes: 5 additions & 0 deletions tests/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""DVSim templates tests."""
26 changes: 26 additions & 0 deletions tests/templates/test_render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""Test template renderer."""

import pytest
from hamcrest import assert_that, empty, is_not

from dvsim.templates.render import render_static


@pytest.mark.parametrize(
"static_content_path",
[
"css/style.css",
"css/bootstrap.min.css",
"js/bootstrap.bundle.min.js",
"js/htmx.min.js",
],
)
def test_render_static(static_content_path: str) -> None:
"""Test that static files are able to be rendered."""
text = render_static(path=static_content_path)

assert_that(text, is_not(empty()))
Loading