From 3d285eb6ca85225fb8fb5529d188ebe2450060b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 5 Sep 2015 20:06:04 +0200 Subject: Add a test for .yrl files that include headers --- test/Makefile | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index cc185c3..9601f64 100644 --- a/test/Makefile +++ b/test/Makefile @@ -77,7 +77,7 @@ clean-core: clean-core-app clean-core-upgrade # Core: Building applications. -CORE_APP_CASES = asn1 hrl hrl-recursive mib xrl xrl-include yrl +CORE_APP_CASES = asn1 hrl hrl-recursive mib xrl xrl-include yrl yrl-include CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES)) CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS)) @@ -797,6 +797,114 @@ core-app-yrl: build clean-core-app-yrl [{module, M} = code:load_file(M) || M <- Mods], \ halt()" +core-app-yrl-include: build clean-core-app-yrl-include + + $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 "Download a .yrl file with includes from Erlang/OTP" + $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl + $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl + + $i "Generate unrelated .erl files" + $t echo "-module(boy)." > $(APP)/src/boy.erl + $t echo "-module(girl)." > $(APP)/src/girl.erl + + $i "Build the application" + $t $(MAKE) -C $(APP) $v + + $i "Check that all compiled files exist" + $t test -f $(APP)/$(APP).d + $t test -f $(APP)/ebin/$(APP).app + $t test -f $(APP)/ebin/boy.beam + $t test -f $(APP)/ebin/core_parse.beam + $t test -f $(APP)/ebin/girl.beam + $t test -f $(APP)/src/core_parse.erl + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [boy, core_parse, girl]} \ + = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + + $i "Touch the .yrl file; check that only required files are rebuilt" + $t printf "%s\n" \ + $(APP)/$(APP).d \ + $(APP)/ebin/$(APP).app \ + $(APP)/ebin/core_parse.beam \ + $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT + $t touch $(APP)/src/core_parse.yrl + $t $(MAKE) -C $(APP) $v + $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT - + $t rm $(APP)/EXPECT + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [boy, core_parse, girl]} \ + = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + + $i "Touch the .hrl file included; check that only required files are rebuilt" + $t printf "%s\n" \ + $(APP)/$(APP).d \ + $(APP)/ebin/$(APP).app \ + $(APP)/ebin/core_parse.beam \ + $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT + $t touch $(APP)/src/core_parse.hrl + $t $(MAKE) -C $(APP) $v + $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT - + $t rm $(APP)/EXPECT + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [boy, core_parse, girl]} \ + = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + + $i "Clean the application" + $t $(MAKE) -C $(APP) clean $v + + $i "Check that source files still exist" + $t test -f $(APP)/Makefile + $t test -f $(APP)/erlang.mk + $t test -f $(APP)/src/$(APP).app.src + $t test -f $(APP)/src/boy.erl + $t test -f $(APP)/src/core_parse.hrl + $t test -f $(APP)/src/core_parse.yrl + $t test -f $(APP)/src/girl.erl + + $i "Check that all build artifacts are removed, including intermediates" + $t test ! -e $(APP)/$(APP).d + $t test ! -e $(APP)/ebin/ + $t test ! -e $(APP)/src/core_parse.erl + + $i "Build the application again" + $t $(MAKE) -C $(APP) $v + + $i "Check that all compiled files exist" + $t test -f $(APP)/$(APP).d + $t test -f $(APP)/ebin/$(APP).app + $t test -f $(APP)/ebin/boy.beam + $t test -f $(APP)/ebin/core_parse.beam + $t test -f $(APP)/ebin/girl.beam + $t test -f $(APP)/src/core_parse.erl + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, Mods = [boy, core_parse, girl]} \ + = application:get_key($(APP), modules), \ + [{module, M} = code:load_file(M) || M <- Mods], \ + halt()" + clean-core-app: $(CORE_APP_CLEAN_TARGETS) $(CORE_APP_CLEAN_TARGETS): -- cgit v1.2.3