Skip to content

Commit

Permalink
[build tests] migrate buck integration test to Makefiles
Browse files Browse the repository at this point in the history
Summary: Only run the buck (and ant) tests if the tools can be found at ./configure-time.

Reviewed By: jberdine

Differential Revision: D4167586

fbshipit-source-id: e77b736
  • Loading branch information
jvillard authored and Facebook Github Bot committed Nov 15, 2016
1 parent 281d5b4 commit 2d846d8
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 960 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ ifeq ($(IS_FACEBOOK_TREE),yes)
include $(ROOT_DIR)/facebook/Makefile.env
endif

BUILD_SYSTEMS_TESTS = ant assembly project_root_rel
BUILD_SYSTEMS_TESTS = assembly project_root_rel
ifneq ($(ANT),no)
BUILD_SYSTEMS_TESTS += ant
endif
ifneq ($(BUCK),no)
BUILD_SYSTEMS_TESTS += buck
endif

DIRECT_TESTS=
ifeq ($(BUILD_C_ANALYZERS),yes)
Expand Down
2 changes: 2 additions & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
SHELL = bash
PLATFORM = $(shell uname)

ANT = @ANT@
ATDGEN = @ATDGEN@
bindir = @bindir@
BUCK = @BUCK@
BUILD_C_ANALYZERS = @BUILD_C_ANALYZERS@
BUILD_JAVA_ANALYZERS = @BUILD_JAVA_ANALYZERS@
CC = @CC@
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ else
fi
AC_SUBST([NCPU])

# tools that are optional, eg build systems to be run in integration tests
AC_CHECK_TOOL([ANT], [ant], [no])
AC_CHECK_TOOL([BUCK], [buck], [no])

AC_CONFIG_FILES([
Makefile.config
Expand Down
29 changes: 29 additions & 0 deletions infer/tests/build_systems/buck/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.

CURDIR = $(shell pwd)

TESTS_DIR = ../..
ROOT_DIR = $(TESTS_DIR)/../..

ANALYZER = infer
SOURCES = $(wildcard $(TESTS_DIR)/codetoanalyze/java/infer/*.java)
OBJECTS = $(ROOT_DIR)/buck-out/gen/infer/tests/codetoanalyze/java/infer/lib__compile__output/compile.jar
INFERPRINT_OPTIONS = --project-root $(ROOT_DIR) --issues-tests
CLEAN_EXTRAS = $(ROOT_DIR)/buck-out/ $(CURDIR)/buck-out/

include $(TESTS_DIR)/java.make
include $(TESTS_DIR)/base.make

$(JAR_OUTPUT): $(JAVA_SOURCE_FILES)
NO_BUCKD=1 buck build --no-cache //infer/tests/codetoanalyze/java/infer:compile

infer-out/report.json: $(INFER_BIN) $(JAVA_SOURCE_FILES)
$(call silent_on_success,\
cd $(ROOT_DIR) && \
NO_BUCKD=1 $(INFER_BIN) -a $(ANALYZER) --results-dir $(CURDIR)/infer-out -- \
buck build --no-cache //infer/tests/codetoanalyze/java/infer:compile)
187 changes: 187 additions & 0 deletions infer/tests/build_systems/buck/issues.exp

Large diffs are not rendered by default.

30 changes: 8 additions & 22 deletions infer/tests/build_systems/build_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# ./build_integration_test.py -- ant gradle
# # run no test
# ./build_integration_test.py --
# # run only the buck tests and record the output
# INFER_RECORD_INTEGRATION_TESTS=1 ./build_integration_test.py -- buck
# # run only the waf tests and record the output
# INFER_RECORD_INTEGRATION_TESTS=1 ./build_integration_test.py -- waf

from __future__ import absolute_import
from __future__ import division
Expand Down Expand Up @@ -61,7 +61,6 @@
EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs')

ALL_TESTS = [
'buck',
'clang_compilation_database',
'cmake',
'componentkit',
Expand Down Expand Up @@ -156,17 +155,12 @@ def run_analysis(clean_cmds, build_cmds, extra_check, should_fail, env=None):
# useful to compare the result of your migrated test with the
# issues.exp that this gives you.
if False:
inferprint_cmd = [INFERPRINT_BIN, '-q', '--issues-tests',
'-o', temp_out_dir] + extra_args
with tempfile.TemporaryFile(
mode='w',
suffix='.out',
prefix='issues.exp') as analysis_output:
try:
subprocess.check_call(inferprint_cmd, env=env)
except subprocess.CalledProcessError, exn:
if exn.returncode != should_fail:
raise
inferprint_cmd = (
[INFERPRINT_BIN, '-q', '--issues-tests', 'issues.exp',
'--from-json-report',
os.path.join(temp_out_dir, 'report.json')] +
extra_args)
subprocess.check_call(inferprint_cmd, env=env)

json_path = os.path.join(temp_out_dir, REPORT_JSON)
found_errors = utils.load_json_from_path(json_path)
Expand Down Expand Up @@ -356,14 +350,6 @@ def test_gradle_integration(
report_fname=report_fname,
env=env)

def test_buck_integration(self):
target = '//infer/tests/codetoanalyze/java/infer:compile'
test('buck', 'Buck',
ROOT_DIR,
[{'compile': ['buck', 'build', '--no-cache', target]}],
clean_commands=[['buck', 'clean']],
available=lambda: is_tool_available(['buck', '--version']))

def test_make_integration(
self,
enabled=None,
Expand Down
Loading

0 comments on commit 2d846d8

Please sign in to comment.