Skip to content
Snippets Groups Projects
Commit 0fd7778a authored by Jammer, Tim's avatar Jammer, Tim
Browse files

Added ability to format generated testcases on the fly

parent 2ea7a43c
No related branches found
No related tags found
1 merge request!5more work on infrastructure III
...@@ -65,7 +65,7 @@ class GeneratorManager: ...@@ -65,7 +65,7 @@ class GeneratorManager:
return case_name + "-" + str(num).zfill(digits_to_use) + suffix return case_name + "-" + str(num).zfill(digits_to_use) + suffix
def generate(self, outpath, filterlist_=None, print_progress_bar=True, overwrite=True, generate_full_set=False, def generate(self, outpath, filterlist_=None, print_progress_bar=True, overwrite=True, generate_full_set=False,
try_compile=False, max_mpi_version=4.0): try_compile=False, max_mpi_version=4.0, use_clang_format=True):
""" """
Generates test cases based on the specified parameters. Generates test cases based on the specified parameters.
Parameters: Parameters:
...@@ -75,6 +75,7 @@ class GeneratorManager: ...@@ -75,6 +75,7 @@ class GeneratorManager:
- `overwrite` (bool, optional): Whether to overwrite existing files. Defaults to True. - `overwrite` (bool, optional): Whether to overwrite existing files. Defaults to True.
- `generate_full_set` (bool, optional): Whether to generate the full (extended) set of errors. Defaults to False. - `generate_full_set` (bool, optional): Whether to generate the full (extended) set of errors. Defaults to False.
- `try_compile` (bool, optional): Whether to try compiling the generated test cases. Defaults to False. - `try_compile` (bool, optional): Whether to try compiling the generated test cases. Defaults to False.
- `use_clang_format` (bool, optional): Whether to format the generated test cases. Defaults to True.
- `max_mpi_version` (float, optional): The maximum MPI version allowed for generated test cases. Defaults to 4.0. - `max_mpi_version` (float, optional): The maximum MPI version allowed for generated test cases. Defaults to 4.0.
Returns: Returns:
...@@ -82,11 +83,11 @@ class GeneratorManager: ...@@ -82,11 +83,11 @@ class GeneratorManager:
Raises: Raises:
AssertionError: If the environment variable 'MPICC' is not set when `try_compile` is True. AssertionError: If the environment variable 'MPICC' is not set when `try_compile` is True.
CalledProcessError: If compilation fails during the try_compile process. CalledProcessError: If compilation fails during the try_compile process or clang-formart fails.
Note: Note:
- The progress bar is printed using the tqdm module. - The progress bar is printed using the tqdm module.
- If `try_compile` is True, it uses the compiler specified via 'MPICC' environment variable to attempt compilation.# - If `try_compile` is True, it uses the compiler specified via 'MPICC' environment variable to attempt compilation.
- the Features and if a test belongs to the base of frull test set is defined by the respective generators - the Features and if a test belongs to the base of frull test set is defined by the respective generators
- Generators can Raise CorrectTestcase, therefore the number of discovered testcases may not match the number of generated cases - Generators can Raise CorrectTestcase, therefore the number of discovered testcases may not match the number of generated cases
""" """
...@@ -136,8 +137,13 @@ class GeneratorManager: ...@@ -136,8 +137,13 @@ class GeneratorManager:
if not overwrite and os.path.isfile(full_name): if not overwrite and os.path.isfile(full_name):
assert False and "File Already exists" assert False and "File Already exists"
result_str = str(result_error)
if use_clang_format:
result_str = subprocess.check_output(["clang-format"], text=True,
input=result_str)
with open(full_name, "w") as text_file: with open(full_name, "w") as text_file:
text_file.write(str(result_error)) text_file.write(result_str)
cases_generated += 1 cases_generated += 1
if try_compile: if try_compile:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment