@ -42,7 +42,7 @@ from mesonbuild.mesonlib import (
is_sunos , windows_proof_rmtree , python_command , version_compare , split_args , quote_arg ,
is_sunos , windows_proof_rmtree , python_command , version_compare , split_args , quote_arg ,
relpath , is_linux , git , search_version , do_conf_file , do_conf_str , default_prefix ,
relpath , is_linux , git , search_version , do_conf_file , do_conf_str , default_prefix ,
MesonException , EnvironmentException , OptionKey ,
MesonException , EnvironmentException , OptionKey ,
windows_proof_rm , quiet_git
windows_proof_rm
)
)
from mesonbuild . programs import ExternalProgram
from mesonbuild . programs import ExternalProgram
@ -3030,7 +3030,6 @@ class AllPlatformTests(BasePlatformTests):
self . assertNotIn ( dummydir , out )
self . assertNotIn ( dummydir , out )
@skipIfNoExecutable ( ' clang-tidy ' )
@skipIfNoExecutable ( ' clang-tidy ' )
@unittest . skipIf ( not is_git_repo ( ) , ' Skipping because this is not in git repo ' )
def test_clang_tidy_fix ( self ) :
def test_clang_tidy_fix ( self ) :
if self . backend is not Backend . ninja :
if self . backend is not Backend . ninja :
raise SkipTest ( f ' Clang-tidy is for now only supported on Ninja, not { self . backend . name } ' )
raise SkipTest ( f ' Clang-tidy is for now only supported on Ninja, not { self . backend . name } ' )
@ -3039,15 +3038,27 @@ class AllPlatformTests(BasePlatformTests):
if is_osx ( ) :
if is_osx ( ) :
raise SkipTest ( ' Apple ships a broken clang-tidy that chokes on -pipe. ' )
raise SkipTest ( ' Apple ships a broken clang-tidy that chokes on -pipe. ' )
testdir = os . path . join ( self . unit_test_dir , ' 68 clang-tidy ' )
testdir = os . path . join ( self . unit_test_dir , ' 68 clang-tidy ' )
# Ensure that test project is in git even when running meson from tarball.
srcdir = os . path . join ( self . builddir , ' src ' )
shutil . copytree ( testdir , srcdir )
git_init ( srcdir )
testdir = srcdir
self . new_builddir ( )
dummydir = os . path . join ( testdir , ' dummydir.h ' )
dummydir = os . path . join ( testdir , ' dummydir.h ' )
testfile = os . path . join ( testdir , ' cttest.cpp ' )
fixedfile = os . path . join ( testdir , ' cttest_fixed.cpp ' )
self . init ( testdir , override_envvars = { ' CXX ' : ' c++ ' } )
self . init ( testdir , override_envvars = { ' CXX ' : ' c++ ' } )
# Make sure test files are different
self . assertNotEqual ( Path ( testfile ) . read_text ( encoding = ' utf-8 ' ) ,
Path ( fixedfile ) . read_text ( encoding = ' utf-8 ' ) )
out = self . run_target ( ' clang-tidy-fix ' )
out = self . run_target ( ' clang-tidy-fix ' )
self . assertIn ( ' cttest.cpp:4:20 ' , out )
self . assertIn ( ' cttest.cpp:4:20 ' , out )
self . assertNotIn ( dummydir , out )
self . assertNotIn ( dummydir , out )
ret = quiet_git ( [ ' diff ' , ' --exit-code ' , ' test cases/unit/68 clang-tidy/cttest.cpp ' ] , ' . ' )
# Make sure the test file is fixed
self . assertFalse ( ret [ 0 ] )
self . assertEqual ( Path ( testfile ) . read_text ( encoding = ' utf-8 ' ) ,
# Restore the file
Path ( fixedfile ) . read_text ( encoding = ' utf-8 ' ) )
quiet_git ( [ ' checkout ' , ' -- ' , ' test cases/unit/68 clang-tidy/cttest.cpp ' ] , ' . ' )
def test_identity_cross ( self ) :
def test_identity_cross ( self ) :
testdir = os . path . join ( self . unit_test_dir , ' 69 cross ' )
testdir = os . path . join ( self . unit_test_dir , ' 69 cross ' )