Skip to content
Open
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
2 changes: 1 addition & 1 deletion plain2code.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def main(): # noqa: C901
# Parse the plain file (and its required modules) once; reused by dry-run and rendering.
try:
plain_module = plain_modules.PlainModule(
args.filename,
os.path.basename(args.filename),
args.build_folder,
args.conformance_tests_folder,
template_dirs,
Expand Down
12 changes: 12 additions & 0 deletions tests/data/requires_subdir/main_in_subdir.plain
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
requires:
- nested/leaf
---

***implementation reqs***

- Main implementation requirement.

***functional specs***

- Display "hello, world"
7 changes: 7 additions & 0 deletions tests/data/requires_subdir/nested/leaf.plain
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
***implementation reqs***

- Base implementation requirement for the leaf.

***functional specs***

- A base functionality from the leaf.
26 changes: 26 additions & 0 deletions tests/test_plainfileparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ def test_regular_plain_source(get_test_data_path):
}


def test_parser_keeps_subdirectory_in_module_name(get_test_data_path):
# A template-relative filename with a subdirectory (as passed for required/imported modules)
# must keep its subdirectory prefix in the module name so it resolves under template_dirs.
data_dir = get_test_data_path("data/requires_subdir")

module_name, _, required = plain_file.plain_file_parser("nested/leaf.plain", [data_dir])

assert module_name == "nested/leaf"
assert required == []


def test_requires_module_in_subdirectory_resolves(get_test_data_path):
# Regression: rendering a top module (referenced by basename, its dir supplied via
# template_dirs) that `requires` a module in a subdirectory must build the full PlainModule
# tree without a "Module does not exist" error, preserving the subdirectory in build paths.
import plain_modules

data_dir = get_test_data_path("data/requires_subdir")

module = plain_modules.PlainModule("main_in_subdir.plain", "build", "conformance", [data_dir])

assert module.module_name == "main_in_subdir"
assert [m.module_name for m in module.required_modules] == ["nested/leaf"]
assert [m.module_build_folder for m in module.required_modules] == [os.path.join("build", "nested/leaf")]


def test_unknown_section():
plain_source = """
***definitions***
Expand Down
Loading