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
3 changes: 3 additions & 0 deletions .github/workflows/coverage-generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
sudo apt install -y build-essential doxygen graphviz
npm install -g jsonld-cli
npm --prefix scripts ci
- name: Install Rust static analysis tools
run: |
rustup component add clippy
- name: Install package
run: |
pip install -e .[dev]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
run: |
brew update
brew install doxygen gcc go graphviz
- name: Install Rust static analysis tools
run: |
rustup component add clippy
- name: Build package
run: |
python -m build
Expand Down
54 changes: 40 additions & 14 deletions tests/test_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,33 +407,59 @@ def f(path, name, tag, **kwargs):
yield f


@pytest.mark.parametrize(
RUST_MODEL_TESTS = (
"args",
[
["--input", TEST_MODEL],
["--input", TEST_MODEL, "--context-url", TEST_CONTEXT, SPDX3_CONTEXT_URL],
],
)


def _build_rust_module(tmp_path, model_server, args):
subprocess.run(
[
"shacl2code",
"generate",
"--context",
model_server + "/test-context.json",
]
+ args
+ [
"rust",
"--output",
tmp_path / "shacl_model",
],
check=True,
)


@pytest.mark.parametrize(*RUST_MODEL_TESTS)
class TestOutput:
def test_output_compile(self, tmp_path, model_server, args):
_build_rust_module(tmp_path, model_server, args)

subprocess.run(
[
"shacl2code",
"generate",
"--context",
model_server + "/test-context.json",
]
+ args
+ [
"rust",
"--output",
tmp_path / "shacl_model",
],
["cargo", "build"],
cwd=tmp_path / "shacl_model",
check=True,
)


@pytest.mark.parametrize(*RUST_MODEL_TESTS)
class TestStaticAnalysis:
"""
Static analysis checks for the generated Rust code
"""

def test_clippy(self, tmp_path, model_server, args):
"""
cargo clippy static analysis
"""
_build_rust_module(tmp_path, model_server, args)

subprocess.run(
["cargo", "build"],
["cargo", "clippy", "--all-targets", "--", "-D", "warnings"],
cwd=tmp_path / "shacl_model",
check=True,
)
Expand Down
Loading