Skip to content

Commit e7c65ea

Browse files
committed
Fix for missing conformance_test_json
Moving fix to render context
1 parent d15f14e commit e7c65ea

3 files changed

Lines changed: 33 additions & 23 deletions

File tree

render_machine/conformance_tests.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def get_module_conformance_tests_folder(self, module_name: str) -> str:
2626

2727
def _get_full_conformance_tests_definition_file_name(self, module_name: str) -> str:
2828
return os.path.join(
29-
self.get_module_conformance_tests_folder(module_name), self.conformance_tests_definition_file_name
29+
self.get_module_conformance_tests_folder(module_name),
30+
self.conformance_tests_definition_file_name,
3031
)
3132

3233
def get_conformance_tests_json(self, module_name: str) -> dict:
@@ -112,19 +113,23 @@ def store_conformance_tests_files(
112113

113114
[source_conformance_test_folder_name, new_conformance_test_folder_name] = (
114115
self.get_source_conformance_test_folder_name(
115-
module_name, required_modules, current_testing_module_name, current_conformance_test_folder_name
116+
module_name,
117+
required_modules,
118+
current_testing_module_name,
119+
current_conformance_test_folder_name,
116120
)
117121
)
118122

119123
if source_conformance_test_folder_name != module_name:
120124
console.info(
121125
f"Creating folder {new_conformance_test_folder_name} for a copy of conformance tests {source_conformance_test_folder_name}"
122126
)
123-
124-
if source_conformance_test_folder_name != new_conformance_test_folder_name:
125-
file_utils.copy_folder_content(source_conformance_test_folder_name, new_conformance_test_folder_name)
126-
else:
127-
console.info(f"Source conformance test folder name {source_conformance_test_folder_name} is the same as the new conformance test folder name {new_conformance_test_folder_name}! Skipping copy!")
127+
128+
if not os.path.exists(new_conformance_test_folder_name):
129+
file_utils.copy_folder_content(
130+
source_conformance_test_folder_name,
131+
new_conformance_test_folder_name,
132+
)
128133

129134
current_conformance_test_folder_name = new_conformance_test_folder_name
130135

@@ -151,7 +156,10 @@ def fetch_existing_conformance_test_files(
151156
) -> tuple[list[str], dict[str, str]]:
152157
if module_name != current_testing_module_name:
153158
[current_conformance_test_folder_name, _] = self.get_source_conformance_test_folder_name(
154-
module_name, required_modules, current_testing_module_name, current_conformance_test_folder_name
159+
module_name,
160+
required_modules,
161+
current_testing_module_name,
162+
current_conformance_test_folder_name,
155163
)
156164

157165
existing_conformance_test_files = file_utils.list_all_text_files(current_conformance_test_folder_name)

render_machine/render_context.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,21 @@ def _get_first_frid_conformance_test_running_context(self, module: PlainModule |
209209

210210
if module is None:
211211
conformance_tests_running_context.current_testing_module_name = self.module_name
212+
if not conformance_tests_running_context.conformance_tests_json_has_module_populated(
213+
conformance_tests_running_context.current_testing_module_name
214+
):
215+
conformance_tests_running_context.set_conformance_tests_json(
216+
conformance_tests_running_context.current_testing_module_name,
217+
{},
218+
)
212219
else:
213220
conformance_tests_running_context.current_testing_module_name = module.name
214-
215-
conformance_tests_json = conformance_tests_running_context.get_conformance_tests_json(self.module_name)
216-
conformance_tests_json_from_file = self.conformance_tests.get_conformance_tests_json(self.module_name)
217-
218-
# Merge conformance tests from file into the existing conformance tests
219-
if conformance_tests_json_from_file:
220-
for frid, test_data in conformance_tests_json_from_file.items():
221-
if frid not in conformance_tests_json:
222-
conformance_tests_json[frid] = test_data
223-
224-
conformance_tests_running_context.set_conformance_tests_json(
225-
conformance_tests_running_context.current_testing_module_name,
226-
conformance_tests_json,
227-
)
221+
conformance_tests_running_context.set_conformance_tests_json(
222+
conformance_tests_running_context.current_testing_module_name,
223+
self.conformance_tests.get_conformance_tests_json(
224+
conformance_tests_running_context.current_testing_module_name
225+
),
226+
)
228227

229228
if module is None:
230229
conformance_tests_running_context.current_testing_frid = plain_spec.get_first_frid(self.plain_source_tree)

render_machine/render_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def __init__(
5454
def get_conformance_tests_json(self, module_name: str) -> dict:
5555
return self._conformance_tests_json[module_name]
5656

57+
def conformance_tests_json_has_module_populated(self, module_name: str) -> bool:
58+
return module_name in self._conformance_tests_json and len(self._conformance_tests_json[module_name]) > 0
59+
5760
def set_conformance_tests_json(self, module_name: str, conformance_tests_json: dict):
5861
self._conformance_tests_json[module_name] = conformance_tests_json
5962

@@ -76,7 +79,7 @@ def get_current_acceptance_tests(self) -> Optional[list[str]]:
7679
plain_spec.ACCEPTANCE_TESTS
7780
]
7881

79-
return None
82+
return []
8083

8184
def get_current_acceptance_test(self) -> Optional[str]:
8285
"""Get the current acceptance test text (raw, unformatted)."""

0 commit comments

Comments
 (0)