[tests] convert pmd-xml test to Makefile

Reviewed By: jberdine

Differential Revision: D4329648

fbshipit-source-id: c4bb17a
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent dece9f1386
commit 25e35e8bec

@ -28,6 +28,9 @@ endif
ifneq ($(NDKBUILD),no) ifneq ($(NDKBUILD),no)
BUILD_SYSTEMS_TESTS += ndk_build BUILD_SYSTEMS_TESTS += ndk_build
endif endif
ifneq ($(PYTHON_lxml),no)
BUILD_SYSTEMS_TESTS += results_xml
endif
DIRECT_TESTS= DIRECT_TESTS=
ifeq ($(BUILD_C_ANALYZERS),yes) ifeq ($(BUILD_C_ANALYZERS),yes)

@ -47,6 +47,7 @@ MKDIR_P = $(shell $(MKDIR_P_CMD))
NCPU = @NCPU@ NCPU = @NCPU@
NDKBUILD = @NDKBUILD@ NDKBUILD = @NDKBUILD@
prefix = @prefix@ prefix = @prefix@
PYTHON_lxml = @PYTHON_lxml@
USER_JAVA_HOME = @USER_JAVA_HOME@ USER_JAVA_HOME = @USER_JAVA_HOME@
XCODE_SELECT = @XCODE_SELECT@ XCODE_SELECT = @XCODE_SELECT@

@ -264,7 +264,8 @@ else
fi fi
AC_SUBST([NCPU]) AC_SUBST([NCPU])
# progs that are optional, eg build systems to be run in integration tests # optional progs and libraries that, eg build systems to be run in integration tests
AC_CHECK_TOOL([ANT], [ant], [no]) AC_CHECK_TOOL([ANT], [ant], [no])
if test ! -z "$SANDCASTLE"; then if test ! -z "$SANDCASTLE"; then
BUCK=buck BUCK=buck
@ -280,6 +281,8 @@ if test x"$NDKBUILD" = x"no"; then
[$PATH$PATH_SEPARATOR$ANDROID_NDK$PATH_SEPARATOR/opt/android_ndk/r10e]) [$PATH$PATH_SEPARATOR$ANDROID_NDK$PATH_SEPARATOR/opt/android_ndk/r10e])
fi fi
AC_CHECK_PYTHON_MODULE([$PYTHON27], [lxml])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile.config Makefile.config
]) ])

@ -61,7 +61,6 @@ CODETOANALYZE_DIR = os.path.join(SCRIPT_DIR, 'codetoanalyze')
EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs') EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs')
ALL_TESTS = [ ALL_TESTS = [
'pmd-xml',
'reactive', 'reactive',
'unknown_ext', 'unknown_ext',
'utf8_in_pwd', 'utf8_in_pwd',
@ -428,22 +427,6 @@ class BuildIntegrationTest(unittest.TestCase):
{'compile': ['analyze'], {'compile': ['analyze'],
'infer_args': ['--reactive']}]) 'infer_args': ['--reactive']}])
def test_pmd_xml_output(self):
def pmd_check(infer_out):
assert os.path.exists(os.path.join(infer_out, 'report.xml'))
try:
from lxml import etree
has_lxml = True
except ImportError:
has_lxml = False
test('pmd-xml', 'PMD XML output',
CODETOANALYZE_DIR,
[{'compile': ['clang', '-c', 'hello.c'],
'infer_args': ['--pmd-xml']}],
extra_check=pmd_check,
available=lambda: has_lxml)
if __name__ == '__main__': if __name__ == '__main__':
# hackish capturing of the arguments after '--' # hackish capturing of the arguments after '--'

@ -1,7 +0,0 @@
[
{
"bug_type": "NULL_DEREFERENCE",
"file": "hello.c",
"procedure": "test"
}
]

@ -0,0 +1,24 @@
# Copyright (c) 2016 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
TESTS_DIR = ../..
ANALYZER = infer
CODETOANALYZE_DIR = ../codetoanalyze
CLANG_OPTIONS = -c
INFER_OPTIONS = --project-root $(CODETOANALYZE_DIR) --pmd-xml
INFERPRINT_OPTIONS = --issues-tests
SOURCES = $(CODETOANALYZE_DIR)/hello.c
include $(TESTS_DIR)/clang.make
issues.exp.test: infer-out/report.json
# grab only a few interesting fields from the xml to prevent flakiness
@grep --only-matching -e ' \(name\|method\|rule\)="[^"]*"' infer-out/report.xml > $@

@ -0,0 +1,3 @@
name="hello.c"
method="test"
rule="NULL_DEREFERENCE"

@ -0,0 +1,23 @@
dnl Copyright (c) 2015 - present Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD style license found in the
dnl LICENSE file in the root directory of this source tree. An additional grant
dnl of patent rights can be found in the PATENTS file in the same directory.
dnl AC_CHECK_PYTHON_MODULE([python],[module])
dnl
dnl checks if the given module is available from the given Python interpreter
AC_DEFUN([AC_CHECK_PYTHON_MODULE],
[dnl
AC_MSG_CHECKING([for Python module $2])
if printf "import %s" $2 | $1 - 1> /dev/null 2> /dev/null; then
AC_MSG_RESULT([ok])
AS_TR_SH([PYTHON_$2])=yes
else
AC_MSG_RESULT([unavailable])
AS_TR_SH([PYTHON_$2])=no
fi
AC_SUBST(AS_TR_SH([PYTHON_$2]))
])
Loading…
Cancel
Save