aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-24 12:01:23 +0100
committerLoïc Hoguin <[email protected]>2018-11-24 12:12:05 +0100
commitea066afe76802fb888abc58c1a4ac3d367e2379c (patch)
treec5777e013ecf312f4e4ff4d88b4635597bc93962
parenta63a34077cd001edee2e2b683d7721058f7f9f31 (diff)
downloaderlang.mk-ea066afe76802fb888abc58c1a4ac3d367e2379c.tar.gz
erlang.mk-ea066afe76802fb888abc58c1a4ac3d367e2379c.tar.bz2
erlang.mk-ea066afe76802fb888abc58c1a4ac3d367e2379c.zip
Error out on dash characters during bootstrap
-rw-r--r--plugins/bootstrap.mk4
-rw-r--r--test/plugin_bootstrap.mk34
2 files changed, 38 insertions, 0 deletions
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index e632c9b..cb459b2 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -421,6 +421,7 @@ ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
$(eval p := $(PROJECT))
+ $(if $(findstring -,$p),$(error Error: The dash cannot be used in application names))
$(eval n := $(PROJECT)_sup)
$(call render_template,bs_Makefile,Makefile)
$(verbose) echo "include erlang.mk" >> Makefile
@@ -436,6 +437,7 @@ ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
$(eval p := $(PROJECT))
+ $(if $(findstring -,$p),$(error Error: The dash cannot be used in application names))
$(call render_template,bs_Makefile,Makefile)
$(verbose) echo "include erlang.mk" >> Makefile
$(verbose) mkdir src/
@@ -464,6 +466,7 @@ ifneq ($(wildcard $(APPS_DIR)/$in),)
$(error Error: Application $in already exists)
endif
$(eval p := $(in))
+ $(if $(findstring -,$p),$(error Error: The dash cannot be used in application names))
$(eval n := $(in)_sup)
$(verbose) mkdir -p $(APPS_DIR)/$p/src/
$(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
@@ -481,6 +484,7 @@ ifneq ($(wildcard $(APPS_DIR)/$in),)
$(error Error: Application $in already exists)
endif
$(eval p := $(in))
+ $(if $(findstring -,$p),$(error Error: The dash cannot be used in application names))
$(verbose) mkdir -p $(APPS_DIR)/$p/src/
$(call render_template,bs_apps_Makefile,$(APPS_DIR)/$p/Makefile)
ifdef LEGACY
diff --git a/test/plugin_bootstrap.mk b/test/plugin_bootstrap.mk
index 94d5f7c..c253dd6 100644
--- a/test/plugin_bootstrap.mk
+++ b/test/plugin_bootstrap.mk
@@ -37,6 +37,40 @@ endif
{module, $(APP)_sup} = code:load_file($(APP)_sup), \
halt()"
+bootstrap-invalid-app-name: build clean
+
+ $i "Try to bootstrap a new OTP application named test_$@"
+ $t mkdir test_$@/
+ $t cp ../erlang.mk test_$@/
+ $t ! $(MAKE) -C test_$@ -f erlang.mk bootstrap $v
+
+bootstrap-invalid-lib-name: build clean
+
+ $i "Try to bootstrap a new OTP library named test_$@"
+ $t mkdir test_$@/
+ $t cp ../erlang.mk test_$@/
+ $t ! $(MAKE) -C test_$@ -f erlang.mk bootstrap-lib $v
+
+bootstrap-invalid-new-app-name: 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 "Try to create a new application my-app"
+ $t ! $(MAKE) -C $(APP) new-app in=my-app $v
+
+bootstrap-invalid-new-lib-name: 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 "Try to create a new library my-lib"
+ $t ! $(MAKE) -C $(APP) new-lib in=my-lib $v
+
bootstrap-lib: build clean
$i "Bootstrap a new OTP library named $(APP)"