Skip to content

Commit

Permalink
Drop gdbm as a dependency for ruby >= 3.1.0 (closes #483).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jul 11, 2024
1 parent 053ab9a commit 8b25635
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 16 deletions.
15 changes: 8 additions & 7 deletions share/ruby-install/ruby/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ case "$package_manager" in
zlib1g-dev
libyaml-dev
libssl-dev
libgdbm-dev
libreadline-dev
libncurses-dev
libffi-dev
Expand All @@ -24,7 +23,6 @@ case "$package_manager" in
zlib-devel
libyaml-devel
openssl-devel
gdbm-devel
readline-devel
ncurses-devel
libffi-devel
Expand All @@ -41,7 +39,6 @@ case "$package_manager" in
openssl
readline
libyaml
gdbm
libffi
)
;;
Expand All @@ -54,7 +51,6 @@ case "$package_manager" in
zlib-devel
libyaml-devel
libopenssl-devel
gdbm-devel
readline-devel
ncurses-devel
libffi-devel
Expand All @@ -67,7 +63,6 @@ case "$package_manager" in
bison
readline
libyaml
gdbm
libffi
)
;;
Expand All @@ -76,7 +71,6 @@ case "$package_manager" in
openssl
readline
libyaml
gdbm
libffi
)
;;
Expand All @@ -86,14 +80,21 @@ case "$package_manager" in
openssl-devel
zlib-devel
libyaml-devel
gdbm-devel
readline-devel
ncurses-devel
libffi-devel
)
;;
esac

if [[ "$ruby_version" < "3.1.0" ]]; then
case "$package_manager" in
apt) ruby_dependencies+=(libgdbm-dev) ;;
dnf|yum|zypper|xbps) ruby_dependencies+=(gdbm-devel) ;;
*) ruby_dependencies+=(gdbm) ;;
esac
fi

case "$package_manager" in
brew|port)
case "$ruby_version" in
Expand Down
5 changes: 3 additions & 2 deletions test/functions-tests/load_dependencies_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
function setUp()
{
ruby="ruby"
ruby_version="3.0.0"
ruby_version="3.3.0"
package_manager="dnf"
}

Expand All @@ -15,7 +15,8 @@ function test_load_dependencies()
load_dependencies

assertEquals "did not correctly set \$ruby_dependencies from \$ruby/dependencies.sh for \$package_manager" \
"${ruby_dependencies[*]}" "xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel"
"xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \
"${ruby_dependencies[*]}"
}

function tearDown()
Expand Down
98 changes: 91 additions & 7 deletions test/ruby-tests/dependencies_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function test_when_package_manager_is_apt()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses-dev libffi-dev" \
"xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libreadline-dev libncurses-dev libffi-dev" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -37,7 +37,7 @@ function test_when_package_manager_is_dnf()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \
"xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -54,7 +54,7 @@ function test_when_package_manager_is_yum()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \
"xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -71,7 +71,7 @@ function test_when_package_manager_is_pacman()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"xz gcc make bison zlib ncurses openssl readline libyaml gdbm libffi" \
"xz gcc make bison zlib ncurses openssl readline libyaml libffi" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -88,7 +88,7 @@ function test_when_package_manager_is_zypper()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"xz gcc make automake zlib-devel libyaml-devel libopenssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \
"xz gcc make automake zlib-devel libyaml-devel libopenssl-devel readline-devel ncurses-devel libffi-devel" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -105,7 +105,7 @@ function test_when_package_manager_is_pkg()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"openssl readline libyaml gdbm libffi" \
"openssl readline libyaml libffi" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
Expand All @@ -122,12 +122,96 @@ function test_when_package_manager_is_xbps()
"$openssl_version"

assertEquals "did not correctly set \$ruby_dependencies" \
"base-devel openssl-devel zlib-devel libyaml-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \
"base-devel openssl-devel zlib-devel libyaml-devel readline-devel ncurses-devel libffi-devel" \
"${ruby_dependencies[*]}"

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_apt()
{
local original_package_manager="$package_manager"
package_manager="apt"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add libgdbm-dev to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" libgdbm-dev "* ]]'

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_dnf()
{
local original_package_manager="$package_manager"
package_manager="dnf"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add gdbm-devel to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]'

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_yum()
{
local original_package_manager="$package_manager"
package_manager="yum"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add gdbm-devel to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]'

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_zypper()
{
local original_package_manager="$package_manager"
package_manager="zypper"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add gdbm-devel to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]'

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_xbps()
{
local original_package_manager="$package_manager"
package_manager="xbps"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add gdbm-devel to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]'

package_manager="$original_package_manager"
}

function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_other()
{
local original_package_manager="$package_manager"
package_manager="brew"
ruby_version="3.0.7"

source "$ruby_install_dir/$ruby/dependencies.sh"

assertTrue "did not add gdbm-devel to \$ruby_dependencies" \
'[[ " ${ruby_dependencies[*]} " == *" gdbm "* ]]'

package_manager="$original_package_manager"
}

function test_when_package_manager_is_brew_and_ruby_version_is_less_than_3_1_0()
{
local original_package_manager="$package_manager"
Expand Down

0 comments on commit 8b25635

Please sign in to comment.