Browse Source

Give ebin paths when creating the PLT

Before we had Dialyzer look for BEAM files in every subfolders
of every deps. This resulted in the PLT bundling extra files
and/or Dialyzer failing because some of them are not built with
+debug_info, or because there are duplicates (in test logs for
example). Now Dialyzer will only look in ebin/.
Loïc Hoguin 8 years ago
parent
commit
0b1932ec65
2 changed files with 33 additions and 3 deletions
  1. 4 2
      plugins/dialyzer.mk
  2. 29 1
      test/plugin_dialyzer.mk

+ 4 - 2
plugins/dialyzer.mk

@@ -42,8 +42,10 @@ define filter_opts.erl
 endef
 
 $(DIALYZER_PLT): deps app
-	$(verbose) dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) \
-		`test -f $(ERLANG_MK_TMP)/deps.log && cat $(ERLANG_MK_TMP)/deps.log`
+	$(eval DEPS_LOG := $(shell test -f $(ERLANG_MK_TMP)/deps.log && \
+		while read p; do test -d $$p/ebin && echo $$p/ebin; done <$(ERLANG_MK_TMP)/deps.log))
+	$(verbose) dialyzer --build_plt --apps erts kernel stdlib \
+		$(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS_LOG)
 
 plt: $(DIALYZER_PLT)
 

+ 29 - 1
test/plugin_dialyzer.mk

@@ -1,6 +1,6 @@
 # Dialyzer plugin.
 
-DIALYZER_CASES = app apps-only apps-with-local-deps beam check custom-plt deps erlc-opts local-deps opts plt-apps
+DIALYZER_CASES = app apps-only apps-with-local-deps beam check custom-plt deps erlc-opts local-deps opts plt-apps plt-ebin-only
 DIALYZER_TARGETS = $(addprefix dialyzer-,$(DIALYZER_CASES))
 
 ifneq ($(shell which sem 2>/dev/null),)
@@ -263,3 +263,31 @@ dialyzer-plt-apps: build clean
 
 	$i "Confirm that runtime_tools was included in the PLT"
 	$t dialyzer --plt_info --plt $(APP)/.$(APP).plt | grep -q runtime_tools
+
+dialyzer-plt-ebin-only: build clean
+
+	$i "Bootstrap a new OTP application named $(APP)"
+	$t mkdir $(APP)/
+	$t cp ../erlang.mk $(APP)/
+	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
+
+	$i "Add Cowlib to the list of dependencies"
+	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib_commit = master\n"}' $(APP)/Makefile
+
+	$i "Build the application"
+	$t $(MAKE) -C $(APP) $v
+
+	$i "Run Cowlib tests to fetch autopatched dependencies"
+	$t $(MAKE) -C $(APP)/deps/cowlib tests $v
+
+	$i "Run Dialyzer"
+	$t $(DIALYZER_MUTEX) $(MAKE) -C $(APP) dialyze $v
+
+	$i "Check that the PLT file was created"
+	$t test -f $(APP)/.$(APP).plt
+
+	$i "Confirm that Cowlib was included in the PLT"
+	$t dialyzer --plt_info --plt $(APP)/.$(APP).plt | grep -q cowlib
+
+	$i "Confirm that rebar files were not included in the PLT"
+	$t ! dialyzer --plt_info --plt $(APP)/.$(APP).plt | grep -q rebar