aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-11-24 17:04:35 +0100
committerLoïc Hoguin <[email protected]>2020-11-24 17:04:35 +0100
commit2a75881eca04064f46eb75a980446350f779fcef (patch)
treeeed7fa2e20e5a71df6fb4197d896faddb1cd7901
parentc02685b2c8a233a96acb95c913524920c982126c (diff)
downloaderlang.mk-2a75881eca04064f46eb75a980446350f779fcef.tar.gz
erlang.mk-2a75881eca04064f46eb75a980446350f779fcef.tar.bz2
erlang.mk-2a75881eca04064f46eb75a980446350f779fcef.zip
Add more Hex tests
-rw-r--r--test/Makefile2
-rw-r--r--test/core_deps.mk33
-rw-r--r--test/plugin_hex.mk69
3 files changed, 76 insertions, 28 deletions
diff --git a/test/Makefile b/test/Makefile
index 4a8b5e3..8d1a5e8 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -124,7 +124,7 @@ endef
all:: core
clean::
- $t rm -rf erl_crash.dump packages/ test_*/
+ $t rm -rf erl_crash.dump packages/ $(filter-out test_rebar_git/,$(wildcard test_*/))
init: clean
$i "Prefetch Rebar if necessary"
diff --git a/test/core_deps.mk b/test/core_deps.mk
index 2aa3312..977fcaf 100644
--- a/test/core_deps.mk
+++ b/test/core_deps.mk
@@ -594,39 +594,22 @@ endif
core-deps-fetch-hex: init
- $i "Bootstrap a new OTP application named $(APP)"
+ $i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
-
- $i "Add hex_core to the list of build dependencies"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "define HEX_CONFIG\n#{api_url => <<\"http://localhost:4000/api\">>}\nendef\n"}' $(APP)/Makefile
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add extra Hex metadata"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "define HEX_TARBALL_EXTRA_METADATA\n#{licenses => [<<\"ISC\">>]}\nendef\n"}' $(APP)/Makefile
+ $i "Add Cowboy 1.0.0 to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile
-# $i "Add Cowboy 1.0.0 to the list of dependencies"
-# $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile
-#
-#ifdef LEGACY
-# $i "Add Cowboy to the applications key in the .app.src file"
-# $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
-#endif
+ifdef LEGACY
+ $i "Add Cowboy to the applications key in the .app.src file"
+ $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
+endif
$i "Build the application"
$t $(MAKE) -C $(APP) $v
- $i "Experiment with Hex"
- $t $(MAKE) -C $(APP) hex-user-create HEX_USERNAME=essen HEX_PASSWORD=1234567 [email protected]
- $t $(MAKE) -C $(APP) hex-key-add HEX_USERNAME=essen HEX_PASSWORD=1234567
- $t $(MAKE) -C $(APP) hex-tarball-create
- $t $(MAKE) -C $(APP) hex-release-publish
- $t perl -ni.bak -e 'print;if ($$.==7) {print "PROJECT_DESCRIPTION = REPLACED DESCRIPTION\n"}' $(APP)/Makefile
- $t $(MAKE) -C $(APP) hex-release-replace
- $t $(MAKE) -C $(APP) hex-release-retire
- $t $(MAKE) -C $(APP) hex-release-unretire
- $t $(MAKE) -C $(APP) hex-release-delete
-
$i "Check that all dependencies were fetched"
$t test -d $(APP)/deps/cowboy
$t test -d $(APP)/deps/cowlib
diff --git a/test/plugin_hex.mk b/test/plugin_hex.mk
index e8b11c2..bdf9d81 100644
--- a/test/plugin_hex.mk
+++ b/test/plugin_hex.mk
@@ -27,6 +27,7 @@ hex-user-create: init
$i "Check that the user exists"
$t curl -sf http://localhost:4000/api/users/$(APP) >/dev/null
+# @todo Fix this.
#hex-user-create-password-with-dollar-sign: init
#
# $i "Bootstrap a new OTP application named $(APP)"
@@ -43,6 +44,7 @@ hex-user-create: init
# $i "Check that the user exists"
# $t curl --user "$(APP):123$$567" -sf http://localhost:4000/api/users/$(APP) >/dev/null
+# @todo Fix this.
#hex-user-create-password-with-backslash: init
#
# $i "Bootstrap a new OTP application named $(APP)"
@@ -94,8 +96,71 @@ hex-key-add: init
$i "Check that the key exists"
$t curl --user $(APP):1234567 -sf http://localhost:4000/api/keys/$(shell hostname)-erlang-mk >/dev/null
-# @todo hex-tarball-create
-# @todo hex-tarball-create-with-deps
+hex-tarball-create: init
+
+ $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 "Create a release tarball"
+ $t $(MAKE) -C $(APP) hex-tarball-create $v
+
+ $i "Confirm the tarball contents can be extracted"
+ $t cd $(APP)/.erlang.mk/ && tar xf $(APP).tar
+
+ $i "Confirm the tarball contains a CHECKSUM file"
+ $t test -f $(APP)/.erlang.mk/CHECKSUM
+
+ $i "Confirm the tarball contains a VERSION file containing '3'"
+ $t cat $(APP)/.erlang.mk/VERSION | grep -q ^3$$
+
+ $i "Confirm the tarball contains a valid metadata.config file"
+ $t $(ERL) -eval " \
+ {ok, _} = file:consult(\"$(APP)/.erlang.mk/metadata.config\"), \
+ halt(0)"
+
+ $i "Confirm the tarball contains a contents.tar.gz file that can be extracted"
+ $t cd $(APP)/.erlang.mk/ && tar xf contents.tar.gz
+
+ $i "Confirm contents.tar.gz contains the expected files"
+ $t printf "%s\n" \
+ erlang.mk \
+ Makefile \
+ ebin/$(APP).app \
+ src/$(APP)_app.erl \
+ src/$(APP)_sup.erl | sort > $(APP)/.erlang.mk/EXPECT
+ $t cd $(APP)/.erlang.mk/ && tar tf contents.tar.gz | sort | diff EXPECT -
+
+hex-tarball-create-with-deps: init
+
+ $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 "Add Cowlib to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\ndep_cowlib_commit = 2.10.1\n"}' $(APP)/Makefile
+
+ifdef LEGACY
+ $i "Add Cowlib to the applications key in the .app.src file"
+ $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowlib,\n"}' $(APP)/src/$(APP).app.src
+endif
+
+ $i "Create a release tarball"
+ $t $(MAKE) -C $(APP) hex-tarball-create $v
+
+ $i "Confirm the tarball contents can be extracted"
+ $t cd $(APP)/.erlang.mk/ && tar xf $(APP).tar
+
+ $i "Confirm the tarball contains a metadata.config file that lists Cowlib as requirement"
+ $t $(ERL) -eval " \
+ {ok, Metadata} = file:consult(\"$(APP)/.erlang.mk/metadata.config\"), \
+ {_, [{<<\"cowlib\">>, Cowlib}]} = lists:keyfind(<<\"requirements\">>, 1, Metadata), \
+ {_, <<\"cowlib\">>} = lists:keyfind(<<\"app\">>, 1, Cowlib), \
+ {_, false} = lists:keyfind(<<\"optional\">>, 1, Cowlib), \
+ {_, <<\"2.10.1\">>} = lists:keyfind(<<\"requirement\">>, 1, Cowlib), \
+ halt(0)"
hex-release-publish: init