Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove additional curly bracket #48

Merged
merged 1 commit into from
Jan 19, 2024
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ output/
velocitas_model/
out/

# VSS Submodule
vehicle_signal_specification/
# test data repos
tests/data/vspec

# test reports
results/
Expand Down
2 changes: 1 addition & 1 deletion src/velocitas/model_generator/python/vss_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __gen_getter(self, name, instances, base_ctx):
f'raise IndexError(f"Index {{index}} is out of range [1, {count}]")\n'
)
body_ctx.dedent()
body_ctx.write("_options = {{\n")
body_ctx.write("_options = {\n")
body_ctx.indent()

for index in range(len(instances)):
Expand Down
13 changes: 13 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
41 changes: 41 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
import subprocess
from pathlib import Path


def prepare_vss_repo_data(tag: str) -> None:
test_data_path = Path(__file__).parent.joinpath("data", "vspec").__str__()
if os.path.exists(os.path.join(test_data_path, tag)):
return

os.makedirs(test_data_path, exist_ok=True)

subprocess.call(
[
"git",
"clone",
"-b",
tag,
"https://github.com/COVESA/vehicle_signal_specification.git",
tag,
],
cwd=test_data_path,
)


def pytest_configure(config) -> None:
prepare_vss_repo_data("v3.0")
7,798 changes: 7,798 additions & 0 deletions tests/data/json/vss_rel_3.0.json

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions tests/test_model_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@
# SPDX-License-Identifier: Apache-2.0

import compileall
import subprocess
import sys
from pathlib import Path
from velocitas.model_generator import generate_model

import pytest
import subprocess
import sys
from velocitas.model_generator import generate_model

test_data_base_path = Path(__file__).parent.joinpath("data")


@pytest.mark.parametrize("language", ["python", "cpp"])
@pytest.mark.parametrize(
"language,vss_file", [("python", "vss_rel_3.0.json"), ("cpp", "vss_rel_3.0.json")]
"input_file_path,include_dir",
[
("json/vss_rel_3.0.json", "."),
("vspec/v3.0/spec/VehicleSignalSpecification.vspec", "vspec/v3.0/spec"),
],
)
def test_generate(language: str, vss_file: str):
input_file_path = Path(__file__).parent.joinpath(vss_file).__str__()
generate_model(input_file_path, language, "out", "vehicle")
def test_generate(language: str, input_file_path: str, include_dir: str):
input_file_path = Path(__file__).parent.joinpath("data", input_file_path).__str__()
generate_model(input_file_path, language, "output", "vehicle")

if language == "python":
subprocess.check_call([sys.executable, "-m", "pip", "install", "./out"])
compileall.compile_dir("./out", force=True)
subprocess.check_call([sys.executable, "-m", "pip", "install", "./output"])
assert compileall.compile_dir("./output", force=True)
elif language == "cpp":
# TODO: add a check if the package can be installed after generated model is a conan package
pass
1 change: 0 additions & 1 deletion tests/vss_rel_3.0.json

This file was deleted.