aboutsummaryrefslogtreecommitdiffstats
path: root/test/plugin_bootstrap.mk
diff options
context:
space:
mode:
Diffstat (limited to 'test/plugin_bootstrap.mk')
-rw-r--r--test/plugin_bootstrap.mk83
1 files changed, 70 insertions, 13 deletions
diff --git a/test/plugin_bootstrap.mk b/test/plugin_bootstrap.mk
index 16bfb58..2b62b6f 100644
--- a/test/plugin_bootstrap.mk
+++ b/test/plugin_bootstrap.mk
@@ -1,19 +1,13 @@
# Bootstrap plugin.
-BOOTSTRAP_CASES = app lib rel templates
+BOOTSTRAP_CASES = app lib rel sp tab templates
BOOTSTRAP_TARGETS = $(addprefix bootstrap-,$(BOOTSTRAP_CASES))
-BOOTSTRAP_CLEAN_TARGETS = $(addprefix clean-,$(BOOTSTRAP_TARGETS))
-.PHONY: bootstrap $(BOOTSTRAP_TARGETS) clean-bootstrap $(BOOTSTRAP_CLEAN_TARGETS)
-
-clean-bootstrap: $(BOOTSTRAP_CLEAN_TARGETS)
-
-$(BOOTSTRAP_CLEAN_TARGETS):
- $t rm -rf $(APP_TO_CLEAN)/
+.PHONY: bootstrap $(BOOTSTRAP_TARGETS)
bootstrap: $(BOOTSTRAP_TARGETS)
-bootstrap-app: build clean-bootstrap-app
+bootstrap-app: build clean
$i "Bootstrap a new OTP application named $(APP)"
$t mkdir $(APP)/
@@ -44,7 +38,7 @@ endif
{module, $(APP)_sup} = code:load_file($(APP)_sup), \
halt()"
-bootstrap-lib: build clean-bootstrap-lib
+bootstrap-lib: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
@@ -69,7 +63,7 @@ endif
{ok, []} = application:get_key($(APP), modules), \
halt()"
-bootstrap-rel: build clean-bootstrap-rel
+bootstrap-rel: build clean
$i "Bootstrap a new release-enabled OTP application named $(APP)"
$t mkdir $(APP)/
@@ -116,7 +110,68 @@ endif
$i "Check that there's no erl_crash.dump file"
$t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump
-bootstrap-templates: build clean-bootstrap-templates
+bootstrap-sp: 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 SP=2 $v
+
+ $i "Check that all bootstrapped files exist"
+ $t test -f $(APP)/Makefile
+ifdef LEGACY
+ $t test -f $(APP)/src/$(APP).app.src
+endif
+ $t test -f $(APP)/src/$(APP)_app.erl
+ $t test -f $(APP)/src/$(APP)_sup.erl
+
+ $i "Check that bootstrapped files have no tabs"
+ifdef LEGACY
+ $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP).app.src`"
+endif
+ $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_app.erl`"
+ $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_sup.erl`"
+
+# Everything looks OK, but let's compile the application to make sure.
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/ebin/$(APP)_app.beam
+ $t test -f $(APP)/ebin/$(APP)_sup.beam
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, [$(APP)_app, $(APP)_sup]} = application:get_key($(APP), modules), \
+ {module, $(APP)_app} = code:load_file($(APP)_app), \
+ {module, $(APP)_sup} = code:load_file($(APP)_sup), \
+ halt()"
+
+bootstrap-tab: 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 "Check that all bootstrapped files exist"
+ $t test -f $(APP)/Makefile
+ifdef LEGACY
+ $t test -f $(APP)/src/$(APP).app.src
+endif
+ $t test -f $(APP)/src/$(APP)_app.erl
+ $t test -f $(APP)/src/$(APP)_sup.erl
+
+ $i "Check that bootstrapped files have tabs"
+ifdef LEGACY
+ $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP).app.src`"
+endif
+ $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_app.erl`"
+ $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_sup.erl`"
+
+bootstrap-templates: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
@@ -135,6 +190,7 @@ bootstrap-templates: build clean-bootstrap-templates
$t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_rest n=my_rest
$t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_ws n=my_ws
$t $(MAKE) -C $(APP) --no-print-directory new t=ranch_protocol n=my_protocol
+ $t $(MAKE) -C $(APP) --no-print-directory new t=module n=my_module
# Here we disable warnings because templates contain missing behaviors.
$i "Build the application"
@@ -145,11 +201,12 @@ bootstrap-templates: build clean-bootstrap-templates
$t test -f $(APP)/ebin/my_fsm.beam
$t test -f $(APP)/ebin/my_server.beam
$t test -f $(APP)/ebin/my_sup.beam
+ $t test -f $(APP)/ebin/my_module.beam
$i "Check that all the modules can be loaded"
$t $(ERL) -pa $(APP)/ebin/ -eval " \
ok = application:start($(APP)), \
- {ok, Mods = [my_fsm, my_http, my_loop, my_protocol, my_rest, my_server, my_sup, my_ws]} \
+ {ok, Mods = [my_fsm, my_http, my_loop, my_module, my_protocol, my_rest, my_server, my_sup, my_ws]} \
= application:get_key($(APP), modules), \
[{module, M} = code:load_file(M) || M <- Mods], \
halt()"