diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9bf87ada..1c6f250f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,7 +103,7 @@ jobs: strategy: matrix: python3-version: ['11', '12', '13'] - python3-platform: ['macos-latest'] + python3-platform: ['windows-latest', 'macos-latest'] runs-on: ${{ matrix.python3-platform }} needs: test steps: diff --git a/.vscode/settings.json b/.vscode/settings.json index bbf67685..f28c096c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "python.testing.cwd": "${workspaceFolder}", "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, - "python.testing.pytestArgs": ["-v"], + "python.testing.pytestArgs": ["-vv"], "pylint.args": [ "--rcfile=${workspaceFolder}/tox.ini" ], diff --git a/conftest.py b/conftest.py index a1d765c5..b0c057e1 100644 --- a/conftest.py +++ b/conftest.py @@ -135,8 +135,8 @@ def _run_nnvg_main( class GenTestPaths: """Helper to generate common paths used in our unit tests.""" - def __init__(self, test_file: str, keep_temporaries: bool, node_name: str): - test_file_path = Path(test_file) + def __init__(self, test_file: Path, keep_temporaries: bool, node_name: str): + test_file_path = test_file.resolve() self.test_name = f"{test_file_path.parent.stem}_{node_name}" self.test_dir = test_file_path.parent search_dir = self.test_dir.resolve() @@ -237,7 +237,7 @@ def gen_paths(request: pytest.FixtureRequest) -> GenTestPaths: Used by the "gentest" unit tests in Nunavut to standardize output paths for generated code created as part of the tests. Use the --keep-generated argument to disable the auto-clean behaviour this fixture provides by default. """ - g = GenTestPaths(str(request.fspath), request.config.option.keep_generated, request.node.name) + g = GenTestPaths(request.path, request.config.option.keep_generated, request.node.name) request.addfinalizer(g.test_path_finalizer) return g @@ -251,7 +251,7 @@ def gen_paths_for_module(request: pytest.FixtureRequest) -> GenTestPaths: # pyl Note: this fixture is different than gen_paths because it is scoped to the module level. This is useful for Sybil tests that share temporary files across different test blocks within the same document. """ - g = GenTestPaths(str(request.fspath), request.config.option.keep_generated, request.node.name) + g = GenTestPaths(request.path, request.config.option.keep_generated, request.node.name) request.addfinalizer(g.test_path_finalizer) return g diff --git a/src/nunavut/cli/parsers.py b/src/nunavut/cli/parsers.py index 395e45db..7ce23ce2 100644 --- a/src/nunavut/cli/parsers.py +++ b/src/nunavut/cli/parsers.py @@ -213,17 +213,20 @@ def _parse_target_paths( from nunavut.cli.parsers import NunavutArgumentParser from pytest import raises + from pathlib import Path + + real_root = Path().cwd().as_posix() parser = NunavutArgumentParser() # Happy path root_paths, target_files = parser._parse_target_paths( [ - "/one/to/root", - "/two/to/file.dsdl", + f"{real_root}one/to/root", + f"{real_root}two/to/file.dsdl", "three/path/four:to/file.dsdl", - "/five/path/six:to/file.dsdl", + f"{real_root}five/path/six:to/file.dsdl", "seven/path/eight\\\\:to/file.dsdl", - "/nine/path/ten/:to/file.dsdl", + f"{real_root}nine/path/ten/:to/file.dsdl", ], False, ) @@ -231,12 +234,12 @@ def _parse_target_paths( assert len(root_paths) == 4 assert len(target_files) == 5 - assert Path("/one/to/root") in root_paths + assert Path(f"{real_root}one/to/root") in root_paths assert Path("three/path/four") in root_paths - assert Path("/five/path/six") in root_paths - assert Path("/nine/path/ten") in root_paths + assert Path(f"{real_root}five/path/six") in root_paths + assert Path(f"{real_root}nine/path/ten") in root_paths - assert Path("/two/to/file.dsdl") in target_files + assert Path(f"{real_root}two/to/file.dsdl") in target_files assert Path("four/to/file.dsdl") in target_files assert Path("six/to/file.dsdl") in target_files assert Path("seven/path/eight\\\\:to/file.dsdl") in target_files @@ -250,11 +253,11 @@ def _parse_target_paths( # Happy path: single target file single_target_file_root_paths, single_target_file_target_files = parser._parse_target_paths( - ["/one/to/file.dsdl"], True + [f"{real_root}one/to/file.dsdl"], True ) assert len(single_target_file_root_paths) == 0 assert len(single_target_file_target_files) == 1 - assert single_target_file_target_files.pop() == Path("/one/to/file.dsdl") + assert single_target_file_target_files.pop() == Path(f"{real_root}one/to/file.dsdl") # errors: multiple colons with raises(SystemExit): @@ -262,21 +265,30 @@ def _parse_target_paths( # errors: leading slash with raises(SystemExit): - parser._parse_target_paths(["path/to:/root/to/file.dsdl"], False) + parser._parse_target_paths([f"path/to:{Path.cwd().anchor}root/to/file.dsdl"], False) """ def _parse_lookup_dir(lookup_dir: str) -> Tuple[Optional[Path], Optional[Path]]: - split_path = re.split(r"(? 2: self.error(f"Invalid lookup path (too many colons) > {lookup_dir}") - if len(split_path) == 2: + if lookup_path.is_absolute(): + root_path = Path(lookup_path.anchor, split_path[0]) + else: root_path = Path(split_path[0]) + if len(split_path) == 2: return root_path, Path(root_path.stem, split_path[1]) - elif (first_path := Path(split_path[0])).suffix in self.DSDL_FILE_SUFFIXES: - return None, first_path + elif root_path.suffix in self.DSDL_FILE_SUFFIXES: + return None, root_path else: - return first_path, None + return root_path, None if target_files_or_root_namespace is None: return set(), set() diff --git a/src/nunavut/lang/cpp/templates/_composite_type.j2 b/src/nunavut/lang/cpp/templates/_composite_type.j2 index 5f1f3523..8259a527 100644 --- a/src/nunavut/lang/cpp/templates/_composite_type.j2 +++ b/src/nunavut/lang/cpp/templates/_composite_type.j2 @@ -135,7 +135,7 @@ struct {% if composite_type.deprecated -%} {%- endfor %} {%- endif %} { - (void)allocator; // avoid unused param warning + static_cast(allocator); // avoid unused param warning } {%- if composite_type.inner_type is not UnionType %} @@ -152,7 +152,7 @@ struct {% if composite_type.deprecated -%} {{ field | id }}{{ field | value_initializer(SpecialMethod.INITIALIZING_CONSTRUCTOR_WITH_ALLOCATOR) }} {%- endfor %} { - (void)allocator; // avoid unused param warning + static_cast(allocator); // avoid unused param warning } {%- endif %} {%- endif %} @@ -174,8 +174,8 @@ struct {% if composite_type.deprecated -%} {%- endfor %} {%- endif %} { - (void)rhs; // avoid unused param warning - (void)allocator; // avoid unused param warning + static_cast(rhs); // avoid unused param warning + static_cast(allocator); // avoid unused param warning } // Move constructor @@ -195,8 +195,8 @@ struct {% if composite_type.deprecated -%} {%- endfor %} {%- endif %} { - (void)rhs; // avoid unused param warning - (void)allocator; // avoid unused param warning + static_cast(rhs); // avoid unused param warning + static_cast(allocator); // avoid unused param warning } {% if composite_type.inner_type is UnionType and not composite_type.bit_length_set.fixed_length %}