Просмотр исходного кода

Fix Dialyzer when a project has and uses parse transforms

Loïc Hoguin 6 лет назад
Родитель
Сommit
5ae9661dca
3 измененных файлов с 26 добавлено и 4 удалено
  1. 3 1
      plugins/dialyzer.mk
  2. 0 3
      test/core_app.mk
  3. 23 0
      test/plugin_dialyzer.mk

+ 3 - 1
plugins/dialyzer.mk

@@ -58,4 +58,6 @@ dialyze:
 else
 dialyze: $(DIALYZER_PLT)
 endif
-	$(verbose) dialyzer --no_native `$(ERL) -eval "$(subst $(newline),,$(call escape_dquotes,$(call filter_opts.erl)))" -extra $(ERLC_OPTS)` $(DIALYZER_DIRS) $(DIALYZER_OPTS)
+	$(verbose) dialyzer --no_native `$(ERL) \
+		-eval "$(subst $(newline),,$(call escape_dquotes,$(call filter_opts.erl)))" \
+		-extra $(ERLC_OPTS)` $(DIALYZER_DIRS) $(DIALYZER_OPTS) $(if $(wildcard ebin/),-pa ebin/)

+ 0 - 3
test/core_app.mk

@@ -1198,9 +1198,6 @@ core-app-pt: build clean
 		"-module(my_user)." \
 		"-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
 
-	$i "Compile my_pt first"
-	$t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
-
 	$i "Build the application; confirm the parse_transform is used"
 	$t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
 

+ 23 - 0
test/plugin_dialyzer.mk

@@ -303,3 +303,26 @@ dialyzer-plt-swallow-warnings: build clean
 
 	$i "Create the PLT file"
 	$t $(DIALYZER_MUTEX) $(MAKE) -C $(APP) plt $v
+
+dialyzer-pt: build clean
+
+	$i "Bootstrap a new OTP library named $(APP)"
+	$t mkdir $(APP)/
+	$t cp ../erlang.mk $(APP)/
+	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+	$i "Generate a parse_transform module"
+	$t printf "%s\n" \
+		"-module(my_pt)." \
+		"-export([parse_transform/2])." \
+		"parse_transform(Forms, _) ->" \
+		"	io:format(\"# Running my_pt parse_transform.~n\")," \
+		"	Forms." > $(APP)/src/my_pt.erl
+
+	$i "Generate a .erl file that uses the my_pt parse_transform"
+	$t printf "%s\n" \
+		"-module(my_user)." \
+		"-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
+
+	$i "Run Dialyzer"
+	$t $(DIALYZER_MUTEX) $(MAKE) -C $(APP) dialyze $v