Skip to content
Snippets Groups Projects
Commit 015593e4 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

fix: created BUILD_DIR constant + coverage needs test

parent 28f302ca
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!116feat/release_pip
Pipeline #50926 failed
...@@ -25,3 +25,10 @@ include: ...@@ -25,3 +25,10 @@ include:
- '.gitlab/ci/windows_python.gitlab-ci.yml' - '.gitlab/ci/windows_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_windows.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
...@@ -16,6 +16,7 @@ import sys ...@@ -16,6 +16,7 @@ import sys
import subprocess import subprocess
import shutil import shutil
def initFiller(model): def initFiller(model):
# Initialize parameters (weights and biases) # Initialize parameters (weights and biases)
for node in model.get_nodes(): for node in model.get_nodes():
...@@ -40,11 +41,11 @@ def initFiller(model): ...@@ -40,11 +41,11 @@ def initFiller(model):
else: else:
pass 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): for filename in os.listdir(dir):
file_path = os.path.join(dir, filename) file_path = os.path.join(dir, filename)
try: try:
...@@ -53,14 +54,16 @@ def clean_dir(dir : pathlib.Path) -> None: ...@@ -53,14 +54,16 @@ def clean_dir(dir : pathlib.Path) -> None:
elif os.path.isdir(file_path): elif os.path.isdir(file_path):
shutil.rmtree(file_path) shutil.rmtree(file_path)
except Exception as e: 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 return
class test_export(unittest.TestCase): class test_export(unittest.TestCase):
"""Test aidge export""" """Test aidge export"""
def setUp(self): 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): def tearDown(self):
pass pass
...@@ -87,11 +90,11 @@ class test_export(unittest.TestCase): ...@@ -87,11 +90,11 @@ class test_export(unittest.TestCase):
# Export model # Export model
aidge_core.export(self.EXPORT_PATH, model) aidge_core.export(self.EXPORT_PATH, model)
clean_dir(self.EXPORT_PATH / "build")
self.assertTrue( self.assertTrue(
self.EXPORT_PATH.is_dir(), "Export folder has not been generated" 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 # Test compilation of export
install_path = ( install_path = (
...@@ -112,15 +115,15 @@ class test_export(unittest.TestCase): ...@@ -112,15 +115,15 @@ class test_export(unittest.TestCase):
"-DPYBIND=1", "-DPYBIND=1",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
], ],
cwd=str(self.EXPORT_PATH / "build"), cwd=str(self.BUILD_DIR),
) )
subprocess.check_call( subprocess.check_call(
["cmake", "--build", "."], ["cmake", "--build", "."],
cwd=str(self.EXPORT_PATH / "build"), cwd=str(self.BUILD_DIR),
) )
subprocess.check_call( subprocess.check_call(
["cmake", "--install", "."], ["cmake", "--install", "."],
cwd=str(self.EXPORT_PATH / "build"), cwd=str(self.BUILD_DIR),
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment