diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10e0c58ba8a699a08e7505ba2f24df491661af09..08733742e4ada45480e6fe6e8bc9f15270a84c77 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,3 +25,10 @@ include: - '.gitlab/ci/windows_python.gitlab-ci.yml' - '.gitlab/ci/release/cibuildwheel_windows.gitlab-ci.yml' + +# Required bc of test_export that cannot run in parallel in test and in coverage +coverage:ubuntu_python: + needs: + - build:ubuntu_python + - test:ubuntu_python + diff --git a/aidge_core/unit_tests/test_export.py b/aidge_core/unit_tests/test_export.py index b60304365d512d5d08abd8572cf3fae6fcce887f..dd9eda7a26b0e226357fe66792410f10aead6a91 100644 --- a/aidge_core/unit_tests/test_export.py +++ b/aidge_core/unit_tests/test_export.py @@ -16,6 +16,7 @@ import sys import subprocess import shutil + def initFiller(model): # Initialize parameters (weights and biases) for node in model.get_nodes(): @@ -40,11 +41,11 @@ def initFiller(model): else: pass -def clean_dir(dir : pathlib.Path) -> None: - if not os.path.isdir(dir): - print(f"Error : directory {dir} doesn't exist.") - return +def clean_dir(dir: pathlib.Path) -> None: + if not dir.is_dir(): + print(f"Error : directory {dir} doesn't exist. Exiting clean_dir().") + return for filename in os.listdir(dir): file_path = os.path.join(dir, filename) try: @@ -53,14 +54,16 @@ def clean_dir(dir : pathlib.Path) -> None: elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception as e: - print('Failed to delete %s. Reason: %s' % (file_path, e)) + print("Failed to delete %s. Reason: %s" % (file_path, e)) return + class test_export(unittest.TestCase): """Test aidge export""" def setUp(self): - self.EXPORT_PATH = pathlib.Path("dummy_export") + self.EXPORT_PATH: pathlib.Path = pathlib.Path("dummy_export") + self.BUILD_DIR: pathlib.Path = self.EXPORT_PATH / "build" def tearDown(self): pass @@ -87,11 +90,11 @@ class test_export(unittest.TestCase): # Export model aidge_core.export(self.EXPORT_PATH, model) - clean_dir(self.EXPORT_PATH / "build") self.assertTrue( self.EXPORT_PATH.is_dir(), "Export folder has not been generated" ) - os.makedirs(self.EXPORT_PATH / "build", exist_ok=True) + os.makedirs(self.BUILD_DIR, exist_ok=True) + clean_dir(self.BUILD_DIR) # if build dir existed already ensure its emptyness # Test compilation of export install_path = ( @@ -112,15 +115,15 @@ class test_export(unittest.TestCase): "-DPYBIND=1", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", ], - cwd=str(self.EXPORT_PATH / "build"), + cwd=str(self.BUILD_DIR), ) subprocess.check_call( ["cmake", "--build", "."], - cwd=str(self.EXPORT_PATH / "build"), + cwd=str(self.BUILD_DIR), ) subprocess.check_call( ["cmake", "--install", "."], - cwd=str(self.EXPORT_PATH / "build"), + cwd=str(self.BUILD_DIR), )