diff options
author | Loïc Hoguin <[email protected]> | 2024-11-13 12:42:45 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2024-11-13 12:42:45 +0100 |
commit | 5ee44b11987671506ed2187622c2a70f4a2c6d70 (patch) | |
tree | 1f54e492673d39f72616a383ae87c3c1894987e3 /test/core_compat.mk | |
parent | d3485e7eb64e16a1b482208bd1d7be24bfa58c43 (diff) | |
download | erlang.mk-improve-rebar-config.tar.gz erlang.mk-improve-rebar-config.tar.bz2 erlang.mk-improve-rebar-config.zip |
Improve rebar.config generationimprove-rebar-config
We now provide the version as a tagged tuple indicating
whether this is a branch, tag or ref. This should help
rebar automatically upgrade dependencies, and remove
an annoying warning when rebar is used.
In order to detect the type of version the dependencies
must be available, therefore the rebar.config target now
depends on the deps target.
To test this the Cowboy package version had to be changed
from 1.0.4 to master. This is a breaking change, but I do
not expect too many people to still use 1.0.4.
Diffstat (limited to 'test/core_compat.mk')
-rw-r--r-- | test/core_compat.mk | 72 |
1 files changed, 68 insertions, 4 deletions
diff --git a/test/core_compat.mk b/test/core_compat.mk index 238d7ad..b759a2b 100644 --- a/test/core_compat.mk +++ b/test/core_compat.mk @@ -91,7 +91,71 @@ core-compat-rebar: init $i "Use rebar3 to build the application" $t cd $(APP) && ./rebar3 compile $v -core-compat-rebar-deps-git: init +core-compat-rebar-deps-git-branch: init + + $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 "Add Cowboy as a dependency" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = git https://github.com/ninenines/cowboy master\n"}' $(APP)/Makefile + + $i "Run 'make rebar.config'" + $t $(MAKE) -C $(APP) rebar.config $v + + $i "Check that rebar.config was created" + $t test -f $(APP)/rebar.config + + $i "Check that Cowboy is listed in rebar.config with a branch" + $t $(ERL) -eval " \ + {ok, C} = file:consult(\"$(APP)/rebar.config\"), \ + {_, [{cowboy, _, {git, _, {branch, \"master\"}}}]} = lists:keyfind(deps, 1, C), \ + halt()" + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $i "Download rebar3" + $t curl --retry 5 -s -L -o $(APP)/rebar3 $(REBAR3_BINARY) + $t chmod +x $(APP)/rebar3 + + $i "Use rebar3 to build the application" + $t cd $(APP) && ./rebar3 compile $v + +core-compat-rebar-deps-git-ref: init + + $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 "Add Cowboy as a dependency" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = git https://github.com/ninenines/cowboy 7e160b49\n"}' $(APP)/Makefile + + $i "Run 'make rebar.config'" + $t $(MAKE) -C $(APP) rebar.config $v + + $i "Check that rebar.config was created" + $t test -f $(APP)/rebar.config + + $i "Check that Cowboy is listed in rebar.config with a branch" + $t $(ERL) -eval " \ + {ok, C} = file:consult(\"$(APP)/rebar.config\"), \ + {_, [{cowboy, _, {git, _, {ref, \"7e160b49\"}}}]} = lists:keyfind(deps, 1, C), \ + halt()" + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $i "Download rebar3" + $t curl --retry 5 -s -L -o $(APP)/rebar3 $(REBAR3_BINARY) + $t chmod +x $(APP)/rebar3 + + $i "Use rebar3 to build the application" + $t cd $(APP) && ./rebar3 compile $v + +core-compat-rebar-deps-git-tag: init $i "Bootstrap a new OTP library named $(APP)" $t mkdir $(APP)/ @@ -107,10 +171,10 @@ core-compat-rebar-deps-git: init $i "Check that rebar.config was created" $t test -f $(APP)/rebar.config - $i "Check that Cowboy is listed in rebar.config" + $i "Check that Cowboy is listed in rebar.config with a tag" $t $(ERL) -eval " \ {ok, C} = file:consult(\"$(APP)/rebar.config\"), \ - {_, [{cowboy, _, {git, _, \"2.9.0\"}}]} = lists:keyfind(deps, 1, C), \ + {_, [{cowboy, _, {git, _, {tag, \"2.9.0\"}}}]} = lists:keyfind(deps, 1, C), \ halt()" $i "Distclean the application" @@ -174,7 +238,7 @@ core-compat-rebar-deps-pkg: init $i "Check that Cowboy is listed in rebar.config" $t $(ERL) -eval " \ {ok, C} = file:consult(\"$(APP)/rebar.config\"), \ - {_, [{cowboy, _, {git, \"https://github.com/\" ++ _, _}}]} = lists:keyfind(deps, 1, C), \ + {_, [{cowboy, _, {git, \"https://github.com/\" ++ _, {branch, _}}}]} = lists:keyfind(deps, 1, C), \ halt()" $i "Distclean the application" |