Include update alternatives for clang
Also, clean up some of the possible errors in the tidy process to make
sure that things like CD are cleaned up properly.
Tested:
I wish I knew why my docker environment seems to be different than when
jenkins runs it, but alas, this continues to pass on my machine when I
run it against a bmcweb tree with a clang-tidy file in it.
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: Ic88fd9ef3227b21c0d60d2c2d68d21ef15e3bd40
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index 6bad754..99fc22e 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -267,6 +267,13 @@
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
+
+RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \
+ --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \
+ --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \
+ --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \
+ --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py
+
RUN pip3 install inflection
RUN pip3 install pycodestyle
RUN pip3 install jsonschema
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index dbca46f..b15d0c8 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -731,15 +731,24 @@
return
if os.path.isfile('.clang-tidy'):
- os.mkdir("tidy-build")
+ try:
+ os.mkdir("tidy-build")
+ except FileExistsError as e:
+ pass
+ # clang-tidy needs to run on a clang-specific build
+ check_call_cmd('cmake', '-DCMAKE_C_COMPILER=clang',
+ '-DCMAKE_CXX_COMPILER=clang++',
+ '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
+ '-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"
+ # 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")
try:
- # clang-tidy needs to run on a clang-specific build
- check_call_cmd('cmake', '-DCMAKE_C_COMPILER=clang',
- '-DCMAKE_CXX_COMPILER=clang++',
- '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '..')
-
- check_call_cmd('run-clang-tidy-10.py', '-p', '.')
+ check_call_cmd('run-clang-tidy.py', "-header-filter=.*", '-p',
+ '.')
finally:
os.chdir("..")
@@ -935,7 +944,7 @@
# Run clang-tidy only if the project has a configuration
if os.path.isfile('.clang-tidy'):
- check_call_cmd('run-clang-tidy-10.py', '-p',
+ check_call_cmd('run-clang-tidy.py', '-p',
'build')
# Run the basic clang static analyzer otherwise
else: