diff options
author | Loïc Hoguin <[email protected]> | 2015-09-25 15:02:18 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-09-25 15:02:18 +0200 |
commit | c1131f4f7420d009c8a05e5de9dd0888127aa0aa (patch) | |
tree | 82bca447620e483b0de1de6b8ab6ed7104b526ee /test/core_app.mk | |
parent | ace7252ee3e34e803345236950e93dae590bb7c1 (diff) | |
download | erlang.mk-c1131f4f7420d009c8a05e5de9dd0888127aa0aa.tar.gz erlang.mk-c1131f4f7420d009c8a05e5de9dd0888127aa0aa.tar.bz2 erlang.mk-c1131f4f7420d009c8a05e5de9dd0888127aa0aa.zip |
Fix error messages appearing when using parse transforms
The errors were happening in the rebar.config generation
code. In addition to the fix, three tests were added:
a project that uses a pt from its own code with -compile
directives, a project that uses a pt from a dep with the
pt set as ERLC_OPTS, and the inclusion of parse transform
options in the generated rebar.config when compatibility
is desired.
Diffstat (limited to 'test/core_app.mk')
-rw-r--r-- | test/core_app.mk | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/test/core_app.mk b/test/core_app.mk index 55bf7b2..84c6588 100644 --- a/test/core_app.mk +++ b/test/core_app.mk @@ -1,6 +1,6 @@ # Core: Building applications. -CORE_APP_CASES = asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive mib no-app no-makedep xrl xrl-include yrl yrl-include +CORE_APP_CASES = asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive mib no-app no-makedep pt pt-erlc-opts xrl xrl-include yrl yrl-include CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES)) CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS)) @@ -954,6 +954,81 @@ endif [{module, M} = code:load_file(M) || M <- Mods], \ halt()" +core-app-pt: build clean-core-app-pt + + $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 "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." + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + +core-app-pt-erlc-opts: build clean-core-app-pt-erlc-opts + + $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 "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep" + $t mkdir -p $(APP)/deps/my_pt_dep/ + $t cp ../erlang.mk $(APP)/deps/my_pt_dep/ + $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v + + $i "Generate a parse_transform module in my_pt_dep" + $t printf "%s\n" \ + "-module(my_pt)." \ + "-export([parse_transform/2])." \ + "parse_transform(Forms, _) ->" \ + " io:format(\"*** Running my_pt parse_transform.~n\")," \ + " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl + + $i "Add my_pt_dep to the list of dependencies" + $t sed -i.bak '2i\ +BUILD_DEPS = my_pt_dep\ +' $(APP)/Makefile + + $i "Generate .erl files" + $t echo "-module(boy)." > $(APP)/src/boy.erl + $t echo "-module(girl)." > $(APP)/src/girl.erl + + $i "Add the my_pt parse_transform to ERLC_OPTS" + $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile + + $i "Build the application; confirm the parse_transform is used" + $t $(MAKE) -C $(APP) | grep "*** Running my_pt parse_transform." + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + core-app-xrl: build clean-core-app-xrl $i "Bootstrap a new OTP library named $(APP)" |