Summary: Added a simple Erlang project to be used as a test for Rebar3 integration, in the following commits. Also, updated the copyright linter to understand Erlang. Reviewed By: ngorogiannis, mmarescotti Differential Revision: D28096899 fbshipit-source-id: 94f15c277master
parent
3939a66da8
commit
f7278e53af
@ -0,0 +1,5 @@
|
||||
1. Start an Erlang shell:
|
||||
rebar3 shell
|
||||
|
||||
2. Run main function:
|
||||
erl_hi_app:main().
|
@ -0,0 +1,11 @@
|
||||
% Copyright (c) Facebook, Inc. and its affiliates.
|
||||
%
|
||||
% This source code is licensed under the MIT license found in the
|
||||
% LICENSE file in the root directory of this source tree.
|
||||
|
||||
{erl_opts, []}.
|
||||
{deps, []}.
|
||||
|
||||
{shell, [
|
||||
{apps, [erl_hi]}
|
||||
]}.
|
@ -0,0 +1,14 @@
|
||||
% Copyright (c) Facebook, Inc. and its affiliates.
|
||||
%
|
||||
% This source code is licensed under the MIT license found in the
|
||||
% LICENSE file in the root directory of this source tree.
|
||||
{application, erl_hi, [
|
||||
{description, "A simple Erlang application"},
|
||||
{vsn, "0.1.0"},
|
||||
{registered, []},
|
||||
{applications, [
|
||||
kernel,
|
||||
stdlib
|
||||
]},
|
||||
{modules, []}
|
||||
]}.
|
@ -0,0 +1,48 @@
|
||||
% Copyright (c) Facebook, Inc. and its affiliates.
|
||||
%
|
||||
% This source code is licensed under the MIT license found in the
|
||||
% LICENSE file in the root directory of this source tree.
|
||||
|
||||
-module(erl_hi_app).
|
||||
|
||||
-export([main/0]).
|
||||
|
||||
odd_matcher([_, _ | T]) ->
|
||||
odd_matcher(T);
|
||||
odd_matcher([_]) ->
|
||||
ok.
|
||||
|
||||
maybe_good_matcher([_]) ->
|
||||
ok;
|
||||
maybe_good_matcher(Xs) ->
|
||||
case length(Xs) rem 2 of
|
||||
0 -> maybe_good_matcher(half_it(Xs));
|
||||
1 -> maybe_good_matcher(Xs ++ Xs ++ Xs ++ [rabbit])
|
||||
end.
|
||||
|
||||
half_it([]) ->
|
||||
[];
|
||||
half_it([_, X | T]) ->
|
||||
[X | half_it(T)].
|
||||
|
||||
guarded(Xs) ->
|
||||
if
|
||||
length(Xs) rem 2 == 1 -> odd_matcher(Xs);
|
||||
true -> ok
|
||||
end.
|
||||
|
||||
main() ->
|
||||
% ok
|
||||
maybe_good_matcher("odd"),
|
||||
% ok
|
||||
maybe_good_matcher("even"),
|
||||
% ok
|
||||
guarded("odd"),
|
||||
% ok
|
||||
guarded("even"),
|
||||
% ok
|
||||
odd_matcher("odd"),
|
||||
% nok [FN]
|
||||
odd_matcher("even"),
|
||||
% nok [FN] (not a good matcher after all)
|
||||
maybe_good_matcher("").
|
@ -0,0 +1,41 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
TESTS_DIR = ../..
|
||||
|
||||
INFERPRINT_OPTIONS = --issues-tests
|
||||
|
||||
REBAR3_DIRS = erl_hi
|
||||
|
||||
CLEAN_EXTRA = \
|
||||
$(REBAR3_DIRS:%=../codetoanalyze/rebar3/%/target) \
|
||||
$(REBAR3_DIRS:%=../codetoanalyze/rebar3/%/com) \
|
||||
$(REBAR3_DIRS:%=infer-out-%) \
|
||||
$(REBAR3_DIRS:%=issues-%.exp.test)
|
||||
|
||||
include $(TESTS_DIR)/infer.make
|
||||
|
||||
infer-out/report.json:
|
||||
$(QUIET)$(MKDIR_P) $(@D)
|
||||
$(QUIET)touch $@
|
||||
|
||||
infer-out-%/report.json: $(JAVA_DEPS) $(SOURCES)
|
||||
$(QUIET)cd ../codetoanalyze/rebar3/$* && \
|
||||
$(call silent_on_success,Testing rebar3 Erlang integration: $*,\
|
||||
$(INFER_BIN) --results-dir $(CURDIR)/$(@D) \
|
||||
--project-root $(CURDIR)/$(TESTS_DIR) -- \
|
||||
$(REBAR3) compile)
|
||||
|
||||
issues-%.exp.test: infer-out-%/report.json
|
||||
$(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@ -o $(<D)
|
||||
|
||||
issues.exp.test: $(foreach r3dir,$(REBAR3_DIRS),issues-$(r3dir).exp.test)
|
||||
# erase the contents of the file
|
||||
$(QUIET): > $@
|
||||
# remember the file name so it's easier to know which bug is from where
|
||||
$(QUIET)for r3dir in $(REBAR3_DIRS); do \
|
||||
echo "-- $$r3dir" >> $@; \
|
||||
cat issues-$$r3dir.exp.test >> $@; \
|
||||
done
|
@ -0,0 +1 @@
|
||||
-- erl_hi
|
Loading…
Reference in new issue