Browse Source

Fix of handling relx.config release version

Krister Svanlund 8 years ago
parent
commit
6ddfc12cb3
2 changed files with 25 additions and 2 deletions
  1. 7 1
      plugins/relx.mk
  2. 18 1
      test/plugin_relx.mk

+ 7 - 1
plugins/relx.mk

@@ -58,7 +58,13 @@ else
 
 
 define get_relx_release.erl
 define get_relx_release.erl
 	{ok, Config} = file:consult("$(RELX_CONFIG)"),
 	{ok, Config} = file:consult("$(RELX_CONFIG)"),
-	{release, {Name, Vsn}, _} = lists:keyfind(release, 1, Config),
+	{release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),
+	Vsn = case Vsn0 of
+		{cmd, Cmd} -> os:cmd(Cmd);
+		semver -> "";
+		{semver, _} -> "";
+		VsnStr -> Vsn0
+	end,
 	io:format("~s ~s", [Name, Vsn]),
 	io:format("~s ~s", [Name, Vsn]),
 	halt(0).
 	halt(0).
 endef
 endef

+ 18 - 1
test/plugin_relx.mk

@@ -3,7 +3,7 @@
 # Sleeps when interacting with relx script are necessary after start and upgrade
 # Sleeps when interacting with relx script are necessary after start and upgrade
 # as both of those interactions are not synchronized.
 # as both of those interactions are not synchronized.
 
 
-RELX_CASES = rel relup start-stop tar
+RELX_CASES = rel relup start-stop tar vsn
 RELX_TARGETS = $(addprefix relx-,$(RELX_CASES))
 RELX_TARGETS = $(addprefix relx-,$(RELX_CASES))
 
 
 .PHONY: relx $(RELX_TARGETS)
 .PHONY: relx $(RELX_TARGETS)
@@ -195,3 +195,20 @@ relx-tar: build clean
 
 
 	$i "Check that tarball exists"
 	$i "Check that tarball exists"
 	$t test -f $(APP)/_rel/$(APP)_release/$(APP)_release-1.tar.gz
 	$t test -f $(APP)/_rel/$(APP)_release/$(APP)_release-1.tar.gz
+
+relx-vsn: build clean
+
+	$i "Bootstrap a new release named $(APP)"
+	$t mkdir $(APP)/
+	$t cp ../erlang.mk $(APP)/
+	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+
+	$i "Replace the vsn"
+	$t sed -i.bak s/"\"1\""/"{cmd, \"echo -n 2\"}"/ $(APP)/relx.config
+
+	$i "Build the release"
+	$t $(MAKE) -C $(APP) $v
+
+	$i "Check that the correct release exists"
+	$t ! test -d $(APP)/_rel/$(APP)_release/releases/1
+	$t test -d $(APP)/_rel/$(APP)_release/releases/2