Skip to content

Commit

Permalink
[tests] convert pmd-xml test to Makefile
Browse files Browse the repository at this point in the history
Reviewed By: jberdine

Differential Revision: D4329648

fbshipit-source-id: c4bb17a
  • Loading branch information
jvillard authored and facebook-github-bot committed Dec 15, 2016
1 parent dece9f1 commit 25e35e8
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ endif
ifneq ($(NDKBUILD),no)
BUILD_SYSTEMS_TESTS += ndk_build
endif
ifneq ($(PYTHON_lxml),no)
BUILD_SYSTEMS_TESTS += results_xml
endif

DIRECT_TESTS=
ifeq ($(BUILD_C_ANALYZERS),yes)
Expand Down
1 change: 1 addition & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MKDIR_P = $(shell $(MKDIR_P_CMD))
NCPU = @NCPU@
NDKBUILD = @NDKBUILD@
prefix = @prefix@
PYTHON_lxml = @PYTHON_lxml@
USER_JAVA_HOME = @USER_JAVA_HOME@
XCODE_SELECT = @XCODE_SELECT@

Expand Down
5 changes: 4 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ else
fi
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])
if test ! -z "$SANDCASTLE"; then
BUCK=buck
Expand All @@ -280,6 +281,8 @@ if test x"$NDKBUILD" = x"no"; then
[$PATH$PATH_SEPARATOR$ANDROID_NDK$PATH_SEPARATOR/opt/android_ndk/r10e])
fi

AC_CHECK_PYTHON_MODULE([$PYTHON27], [lxml])

AC_CONFIG_FILES([
Makefile.config
])
Expand Down
17 changes: 0 additions & 17 deletions infer/tests/build_systems/build_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs')

ALL_TESTS = [
'pmd-xml',
'reactive',
'unknown_ext',
'utf8_in_pwd',
Expand Down Expand Up @@ -428,22 +427,6 @@ def test_reactive_multiple_capture(self):
{'compile': ['analyze'],
'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__':
# hackish capturing of the arguments after '--'
Expand Down

This file was deleted.

24 changes: 24 additions & 0 deletions infer/tests/build_systems/results_xml/Makefile
Original file line number Diff line number Diff line change
@@ -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 > $@
3 changes: 3 additions & 0 deletions infer/tests/build_systems/results_xml/issues.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name="hello.c"
method="test"
rule="NULL_DEREFERENCE"
23 changes: 23 additions & 0 deletions m4/ac_check_python_module.m4
Original file line number Diff line number Diff line change
@@ -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]))
])

0 comments on commit 25e35e8

Please sign in to comment.