Skip to content

Commit

Permalink
Improved cmake tests configuration (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-ni authored Feb 16, 2024
1 parent 15fcdc9 commit 3bb18b0
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tests/CMakeTests/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import datetime

# Setting global variables
if os.name == 'nt': # windows
venv_command = "python -m venv venv"
activate_script = "venv\\Scripts\\activate"
venv_folder_path = Path(__file__).parent / "venv"
venv_command = f"python -m venv {venv_folder_path}"
if os.name == 'nt': # windows
activate_script = f"{venv_folder_path}\\Scripts\\activate"
activate_command = f"call {activate_script}"
else:
venv_command = "python -m venv venv"
activate_script = "venv/bin/activate"
else:
activate_script = f"{venv_folder_path}/bin/activate"
activate_command = f". {activate_script}"

def create_virtual_environment():
venv_folder_path = Path(__file__).parent / "venv"
if not venv_folder_path.exists():
subprocess.run(venv_command, shell=True)

Expand Down Expand Up @@ -45,8 +44,6 @@ def run_tests():
result_message_structure_output = result_message_structure_output.replace("\r", "")
log_file.write(result_message_structure_output)
print(result_message_structure_output)
if result_message_structure.returncode != 0:
result_message_structure = subprocess.run(["python", "-m", "pytest", str(message_structures_test_path), "-vv"])
if result_message_structure.returncode != 0:
print(f"Message structural tests failed with exit code {result_message_structure.returncode}. Exiting.")
sys.exit(result_message_structure.returncode)
Expand All @@ -61,8 +58,6 @@ def run_tests():
result_exported_functions_output = result_exported_functions_output.replace("\r", "")
log_file.write(result_exported_functions_output)
print(result_exported_functions_output)
if result_exported_functions.returncode != 0:
result_exported_functions = subprocess.run(["python", "-m", "pytest", str(exported_functions_test_path), "-vv"])
if result_exported_functions.returncode != 0:
print(f"Function structural tests failed with exit code {result_exported_functions.returncode}. Exiting.")
sys.exit(result_exported_functions.returncode)
Expand All @@ -83,8 +78,6 @@ def run_tests():
log_file.write("You have not added these function in the 'Exported Functions Cmake Test': " + "\n\n" + result_exported_functions_addition_output + "Please add these function(s) in tests/CMakeTests/testcases/ExportedFunctionList.json")
warning_output = "::warning::" + "You have not added these function in the 'Exported Functions Cmake Test': " + " ".join(result_exported_functions_addition_output.split('\n')) + ". Please add these function(s) in tests/CMakeTests/testcases/ExportedFunctionList.json"
print(warning_output)
if result_exported_functions_addition.returncode != 0:
result_exported_functions_addition = subprocess.run(["python", str(exported_functions_addition_test_path)])
if result_exported_functions_addition.returncode != 0:
print(f"Function structural tests failed with exit code {result_exported_functions_addition.returncode}. Exiting.")
sys.exit(result_exported_functions_addition.returncode)
Expand Down

0 comments on commit 3bb18b0

Please sign in to comment.