aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-04 17:56:41 +0200
committerLoïc Hoguin <[email protected]>2015-09-04 17:56:41 +0200
commite8c27180012f1ba9aa3e872ff7401475524c9d9a (patch)
tree26fe111fcb30ad30db6730babc67ce419a367277 /test
parent0573fb869c9f63872d9061877192def7229e6b0f (diff)
downloaderlang.mk-e8c27180012f1ba9aa3e872ff7401475524c9d9a.tar.gz
erlang.mk-e8c27180012f1ba9aa3e872ff7401475524c9d9a.tar.bz2
erlang.mk-e8c27180012f1ba9aa3e872ff7401475524c9d9a.zip
Add test for xrl files
Diffstat (limited to 'test')
-rw-r--r--test/Makefile97
1 files changed, 97 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
index 6bf179c..91b76fd 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -470,6 +470,103 @@ core-app-mib: build clean-core-app-mib
[{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)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Generate .xrl files"
+ $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
+ $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
+
+ $i "Generate unrelated .erl files"
+ $t echo "-module(boy)." > $(APP)/src/boy.erl
+ $t echo "-module(girl)." > $(APP)/src/girl.erl
+
+ $i "Disable warnings; our test .xrl files aren't perfect"
+ $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
+
+ $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/erlang_scan.beam
+ $t test -f $(APP)/ebin/girl.beam
+ $t test -f $(APP)/ebin/lfe_scan.beam
+ $t test -f $(APP)/src/erlang_scan.erl
+ $t test -f $(APP)/src/lfe_scan.erl
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
+ = application:get_key($(APP), modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Touch one .xrl file; check that only required files are rebuilt"
+ $t printf "%s\n" \
+ $(APP)/$(APP).d \
+ $(APP)/ebin/$(APP).app \
+ $(APP)/ebin/erlang_scan.beam \
+ $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
+ $t touch $(APP)/src/erlang_scan.xrl
+ $t $(MAKE) -C $(APP) $v
+ $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | 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, erlang_scan, girl, lfe_scan]} \
+ = 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/erlang_scan.xrl
+ $t test -f $(APP)/src/girl.erl
+ $t test -f $(APP)/src/lfe_scan.xrl
+
+ $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/erlang_scan.erl
+ $t test ! -e $(APP)/src/lfe_scan.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/erlang_scan.beam
+ $t test -f $(APP)/ebin/girl.beam
+ $t test -f $(APP)/ebin/lfe_scan.beam
+ $t test -f $(APP)/src/erlang_scan.erl
+ $t test -f $(APP)/src/lfe_scan.erl
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
+ = 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):