clang-tidy: try to remove old directories
Just like the existing meson build codes, this patch tries to delete old
clang-tidy build directories before making a new one.
Tested:
Tested both cmake and meson repos, old directories are deleted as
expected before making a new one.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I36a484d5832a1f427ef0e1b9b1f28183ccdc387e
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index d1b8ef9..02b5846 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -745,10 +745,9 @@
def analyze(self):
if os.path.isfile('.clang-tidy'):
- try:
- os.mkdir("tidy-build")
- except FileExistsError as e:
- pass
+ shutil.rmtree("tidy-build", ignore_errors=True)
+ os.mkdir("tidy-build")
+
# clang-tidy needs to run on a clang-specific build
check_call_cmd('cmake', '-DCMAKE_C_COMPILER=clang',
'-DCMAKE_CXX_COMPILER=clang++',
@@ -756,7 +755,7 @@
'-H.',
'-Btidy-build')
# we need to cd here because otherwise clang-tidy doesn't find the
- # .clang-tidy file in the roots of repos. Its arguably a "bug"
+ # .clang-tidy file in the roots of repos. It's arguably a "bug"
# with run-clang-tidy at a minimum it's "weird" that it requires
# the .clang-tidy to be up a dir
os.chdir("tidy-build")
@@ -765,6 +764,7 @@
'.')
finally:
os.chdir("..")
+ shutil.rmtree("tidy-build", ignore_errors=True)
maybe_make_valgrind()
maybe_make_coverage()
@@ -892,7 +892,7 @@
check_call_cmd('meson', 'setup', '--reconfigure', 'build',
*meson_flags)
except:
- shutil.rmtree('build')
+ shutil.rmtree('build', ignore_errors=True)
check_call_cmd('meson', 'setup', 'build', *meson_flags)
def build(self):
@@ -960,6 +960,7 @@
# Run clang-tidy only if the project has a configuration
if os.path.isfile('.clang-tidy'):
os.environ["CXX"] = "clang++"
+ shutil.rmtree("build-clang", ignore_errors=True)
check_call_cmd('meson', 'setup', 'build-clang')
os.chdir("build-clang")
try:
@@ -970,6 +971,7 @@
raise
finally:
os.chdir("..")
+ shutil.rmtree("build-clang", ignore_errors=True)
# Run the basic clang static analyzer otherwise
else: