Skip to content

Commit

Permalink
Add tests for NoLongCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytheway committed Jun 19, 2019
1 parent 91946b2 commit 5c72b74
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
compiler: clang
addons: &clang8
apt:
packages: ["clang-8", "libclang-8-dev", "llvm-8-dev", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
packages: ["clang-8", "libclang-8-dev", "llvm-8-dev", "llvm-8-tools", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
sources: [*apt_sources, llvm-toolchain-xenial-8]

# Finally check the compiler variants
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ then
if [ "$CATA_CLANG_TIDY" = "plugin" ]
then
make -j$num_jobs CataAnalyzerPlugin
CATA_CLANG_TIDY=$PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin/clang-tidy
export PATH=$PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin:$PATH
if ! which FileCheck
then
ls -l tools/clang-tidy-plugin/clang-tidy-plugin-support/bin
ls -l /usr/bin
echo "Missing FileCheck"
exit 1
fi
CATA_CLANG_TIDY=clang-tidy
lit -v tools/clang-tidy-plugin/test
fi

"$CATA_CLANG_TIDY" --version
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ -n "${CODE_COVERAGE}" ]; then
fi

if [ -n "$CATA_CLANG_TIDY" ]; then
travis_retry pip install --user compiledb
travis_retry pip install --user compiledb lit
fi

# Influenced by https://github.com/zer0main/battleship/blob/master/build/windows/requirements.sh
Expand Down
3 changes: 3 additions & 0 deletions tools/clang-tidy-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ else()
target_compile_options(
CataAnalyzerPlugin PRIVATE -fno-exceptions -fno-rtti)
endif()

configure_file(test/lit.site.cfg.in test/lit.site.cfg @ONLY)
configure_file(test/.clang-tidy test/.clang-tidy COPYONLY)
1 change: 1 addition & 0 deletions tools/clang-tidy-plugin/test/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WarningsAsErrors: '-*'
23 changes: 23 additions & 0 deletions tools/clang-tidy-plugin/test/lit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
import os
import lit.formats

config.name = 'clang-tidy-cata'
config.test_format = lit.formats.ShTest(True)
config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = os.path.join(
config.plugin_build_root, 'test')

config.suffixes = ['.cpp']

check_clang_tidy = os.getenv('CHECK_CLANG_TIDY')
if not check_clang_tidy:
check_clang_tidy = os.path.join(
config.plugin_build_root, 'clang-tidy-plugin-support', 'bin',
'check_clang_tidy.py')

cata_plugin = os.path.join(
config.plugin_build_root, 'libCataAnalyzerPlugin.so')

config.substitutions.append(('%check_clang_tidy', check_clang_tidy))
config.substitutions.append(('%cata_plugin', cata_plugin))
6 changes: 6 additions & 0 deletions tools/clang-tidy-plugin/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

config.plugin_build_root = "@CMAKE_CURRENT_BINARY_DIR@"

lit_config.load_config(
config, os.path.join("@CMAKE_CURRENT_SOURCE_DIR@", "test", "lit.cfg"))
4 changes: 4 additions & 0 deletions tools/clang-tidy-plugin/test/no-long.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %check_clang_tidy %s cata-no-long %t -- -plugins=%cata_plugin --

long a;
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Variable 'a' declared as long. Prefer int or int64_t. [cata-no-long]

0 comments on commit 5c72b74

Please sign in to comment.