code_size_compare: make sure _remove_worktree executed

Add try and finally to make sure we remove worktree as expected even
if we hit errors by accident.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-07-26 17:12:57 +08:00
parent 9e8b671b1c
commit 6ae94a0a72

View file

@ -423,9 +423,11 @@ class CodeSizeCalculator:
"""
git_worktree_path = self._create_git_worktree()
self._build_libraries(git_worktree_path)
res = self._gen_raw_code_size(git_worktree_path)
self._remove_worktree(git_worktree_path)
try:
self._build_libraries(git_worktree_path)
res = self._gen_raw_code_size(git_worktree_path)
finally:
self._remove_worktree(git_worktree_path)
return res