diff --git a/share/ruby-install/functions.sh b/share/ruby-install/functions.sh index 7fad2a55..e2386c6b 100644 --- a/share/ruby-install/functions.sh +++ b/share/ruby-install/functions.sh @@ -12,21 +12,13 @@ function pre_install() } # -# Loads the packages from the file within the ruby's directory for the current -# package manager and sets $ruby_dependencies. +# Loads the dependencies.sh file for the ruby and sets $ruby_dependencies. # -function load_dependencies_from() +function load_dependencies() { - local file="$1" - - ruby_dependencies=($(fetch "$ruby/$file" "$package_manager" || return $?)) + source "$ruby_install_dir/$ruby/dependencies.sh" } -# -# Loads the dependencies from dependencies.txt and sets $ruby_dependencies. -# -function load_dependencies() { load_dependencies_from "dependencies"; } - # # Install the ruby's dependencies. # diff --git a/share/ruby-install/jruby/dependencies.sh b/share/ruby-install/jruby/dependencies.sh new file mode 100644 index 00000000..7b2a8822 --- /dev/null +++ b/share/ruby-install/jruby/dependencies.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +case "$package_manager" in + apt) ruby_dependencies=(openjdk-8-jdk) ;; + dnf) ruby_dependencies=(java-openjdk) ;; + yum) ruby_dependencies=(java-openjdk) ;; + pacman) ruby_dependencies=(jre8-openjdk) ;; + zypper) ruby_dependencies=(java-1.8.0-openjdk) ;; + pkg) ruby_dependencies=(openjdk) ;; + xbps) ruby_dependencies=(openjdk) ;; +esac diff --git a/share/ruby-install/jruby/dependencies.txt b/share/ruby-install/jruby/dependencies.txt deleted file mode 100644 index 4b7d2d10..00000000 --- a/share/ruby-install/jruby/dependencies.txt +++ /dev/null @@ -1,7 +0,0 @@ -apt: openjdk-8-jdk -dnf: java-openjdk -yum: java-openjdk -pacman: jre8-openjdk -zypper: java-1.8.0-openjdk -pkg: openjdk -xbps: openjdk diff --git a/share/ruby-install/mruby/dependencies.sh b/share/ruby-install/mruby/dependencies.sh new file mode 100644 index 00000000..9b751d60 --- /dev/null +++ b/share/ruby-install/mruby/dependencies.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +case "$package_manager" in + apt) + ruby_dependencies=( + build-essential + bison + ) + ;; + dnf) + ruby_dependencies=( + gcc + make + bison + ) + ;; + yum) + ruby_dependencies=( + gcc + make + bison + ) + ;; + port) ruby_dependencies=(bison) ;; + brew) ruby_dependencies=(bison) ;; + pacman) + ruby_dependencies=( + gcc + make + bison + ) + ;; + zypper) + ruby_dependencies=( + gcc + make + bison + ) + ;; + pkg) + ruby_dependencies=( + gcc + automake + bison + ) + ;; + xbps) ruby_dependencies=(base-devel) ;; +esac diff --git a/share/ruby-install/mruby/dependencies.txt b/share/ruby-install/mruby/dependencies.txt deleted file mode 100644 index 2e87f408..00000000 --- a/share/ruby-install/mruby/dependencies.txt +++ /dev/null @@ -1,9 +0,0 @@ -apt: build-essential bison -dnf: gcc make bison -yum: gcc make bison -port: bison -brew: bison -pacman: gcc make bison -zypper: gcc make bison -pkg: gcc automake bison -xbps: base-devel diff --git a/share/ruby-install/ruby/dependencies.sh b/share/ruby-install/ruby/dependencies.sh new file mode 100644 index 00000000..85fb0d50 --- /dev/null +++ b/share/ruby-install/ruby/dependencies.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash + +case "$package_manager" in + apt) + ruby_dependencies=( + xz-utils + build-essential + bison + zlib1g-dev + libyaml-dev + libssl-dev + libgdbm-dev + libreadline-dev + libncurses-dev + libffi-dev + ) + ;; + dnf) + ruby_dependencies=( + xz + gcc + automake + bison + zlib-devel + libyaml-devel + openssl-devel + gdbm-devel + readline-devel + ncurses-devel + libffi-devel + ) + ;; + yum) + ruby_dependencies=( + xz + gcc + automake + bison + zlib-devel + libyaml-devel + openssl-devel + gdbm-devel + readline-devel + ncurses-devel + libffi-devel + ) + ;; + port) + ruby_dependencies=( + xz + automake + bison + readline + libyaml + gdbm + libffi + ) + ;; + brew) + ruby_dependencies=( + xz + automake + bison + readline + libyaml + gdbm + libffi + ) + ;; + pacman) + ruby_dependencies=( + xz + gcc + make + bison + zlib + ncurses + openssl + readline + libyaml + gdbm + libffi + ) + ;; + zypper) + ruby_dependencies=( + xz + gcc + make + automake + zlib-devel + libyaml-devel + libopenssl-devel + gdbm-devel + readline-devel + ncurses-devel + libffi-devel + ) + ;; + pkg) + ruby_dependencies=( + openssl + readline + libyaml + gdbm + libffi + ) + ;; + xbps) + ruby_dependencies=( + base-devel + openssl-devel + zlib-devel + libyaml-devel + gdbm-devel + readline-devel + ncurses-devel + libffi-devel + ) + ;; +esac + +case "$package_manager" in + brew|port) + case "$ruby_version" in + 2.*|3.0.*) openssl_version="1.1" ;; + *) openssl_version="3" ;; + esac + ;; +esac + +# +# Install openssl@1.1 or openssl@3.0 depending on the Ruby version, +# only for homebrew. +# +case "$package_manager" in + brew) ruby_dependencies+=("openssl@${openssl_version}") ;; + port) ruby_dependencies+=("openssl${openssl_version/./}") ;; +esac diff --git a/share/ruby-install/ruby/dependencies.txt b/share/ruby-install/ruby/dependencies.txt deleted file mode 100644 index cdf4ab8f..00000000 --- a/share/ruby-install/ruby/dependencies.txt +++ /dev/null @@ -1,9 +0,0 @@ -apt: xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses-dev libffi-dev -dnf: xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel -yum: xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel -port: xz automake bison readline libyaml gdbm libffi -brew: xz automake bison readline libyaml gdbm libffi -pacman: xz gcc make bison zlib ncurses openssl readline libyaml gdbm libffi -zypper: xz gcc make automake zlib-devel libyaml-devel libopenssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel -pkg: openssl readline libyaml gdbm libffi -xbps: base-devel openssl-devel zlib-devel libyaml-devel gdbm-devel readline-devel ncurses-devel libffi-devel diff --git a/share/ruby-install/ruby/functions.sh b/share/ruby-install/ruby/functions.sh index 65da2d2a..0ce0cece 100755 --- a/share/ruby-install/ruby/functions.sh +++ b/share/ruby-install/ruby/functions.sh @@ -13,27 +13,6 @@ ruby_dir_name="ruby-$ruby_version" ruby_mirror="${ruby_mirror:-https://cache.ruby-lang.org/pub/ruby}" ruby_url="${ruby_url:-$ruby_mirror/$ruby_version_family/$ruby_archive}" -case "$package_manager" in - brew|port) - case "$ruby_version_family" in - 2.*|3.0) openssl_version="1.1" ;; - *) openssl_version="3" ;; - esac - ;; -esac - -# -# Install openssl@1.1 or openssl@3.0 depending on the Ruby version, -# only for homebrew. -# -function install_optional_deps() -{ - case "$package_manager" in - brew) install_packages "openssl@${openssl_version}" ;; - port) install_packages "openssl${openssl_version/./}" ;; - esac -} - # # Configures Ruby. # diff --git a/share/ruby-install/truffleruby-graalvm/dependencies.sh b/share/ruby-install/truffleruby-graalvm/dependencies.sh new file mode 100644 index 00000000..f57c348e --- /dev/null +++ b/share/ruby-install/truffleruby-graalvm/dependencies.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +case "$package_manager" in + apt) + ruby_dependencies=( + make + gcc + zlib1g-dev + libssl-dev + libxml2 + libyaml-dev + ) + ;; + dnf) + ruby_dependencies=( + make + gcc + zlib-devel + openssl-devel + libxml2 + libyaml-devel + ) + ;; + yum) + ruby_dependencies=( + make + gcc + zlib-devel + openssl-devel + libxml2 + libyaml-devel + ) + ;; + port) + ruby_dependencies=( + openssl + libyaml + ) + ;; + brew) + ruby_dependencies=( + openssl@1.1 + libyaml + ) + ;; + pacman) + ruby_dependencies=( + make + gcc + zlib + openssl + libxml2 + libyaml + ) + ;; + zypper) + ruby_dependencies=( + make + gcc + zlib-devel + libopenssl-devel + libxml2 + libyaml-devel + ) + ;; + pkg) + ruby_dependencies=( + gmake + gcc + openssl + libxml2 + libyaml + ) + ;; + xbps) + ruby_dependencies=( + base-devel + openssl-devel + zlib-devel + libxml2 + libyaml-devel + ) + ;; +esac diff --git a/share/ruby-install/truffleruby-graalvm/dependencies.txt b/share/ruby-install/truffleruby-graalvm/dependencies.txt deleted file mode 100644 index 887107d8..00000000 --- a/share/ruby-install/truffleruby-graalvm/dependencies.txt +++ /dev/null @@ -1,9 +0,0 @@ -apt: zlib1g-dev libssl-dev make gcc libxml2 libyaml-dev -dnf: zlib-devel openssl-devel make gcc libxml2 libyaml-devel -yum: zlib-devel openssl-devel make gcc libxml2 libyaml-devel -port: openssl libyaml -brew: openssl@1.1 libyaml -pacman: zlib openssl make gcc libxml2 libyaml -zypper: zlib-devel libopenssl-devel make gcc libxml2 libyaml-devel -pkg: openssl gmake gcc libxml2 libyaml -xbps: base-devel openssl-devel zlib-devel libxml2 libyaml-devel diff --git a/share/ruby-install/truffleruby/dependencies.sh b/share/ruby-install/truffleruby/dependencies.sh new file mode 100644 index 00000000..f57c348e --- /dev/null +++ b/share/ruby-install/truffleruby/dependencies.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +case "$package_manager" in + apt) + ruby_dependencies=( + make + gcc + zlib1g-dev + libssl-dev + libxml2 + libyaml-dev + ) + ;; + dnf) + ruby_dependencies=( + make + gcc + zlib-devel + openssl-devel + libxml2 + libyaml-devel + ) + ;; + yum) + ruby_dependencies=( + make + gcc + zlib-devel + openssl-devel + libxml2 + libyaml-devel + ) + ;; + port) + ruby_dependencies=( + openssl + libyaml + ) + ;; + brew) + ruby_dependencies=( + openssl@1.1 + libyaml + ) + ;; + pacman) + ruby_dependencies=( + make + gcc + zlib + openssl + libxml2 + libyaml + ) + ;; + zypper) + ruby_dependencies=( + make + gcc + zlib-devel + libopenssl-devel + libxml2 + libyaml-devel + ) + ;; + pkg) + ruby_dependencies=( + gmake + gcc + openssl + libxml2 + libyaml + ) + ;; + xbps) + ruby_dependencies=( + base-devel + openssl-devel + zlib-devel + libxml2 + libyaml-devel + ) + ;; +esac diff --git a/share/ruby-install/truffleruby/dependencies.txt b/share/ruby-install/truffleruby/dependencies.txt deleted file mode 100644 index 887107d8..00000000 --- a/share/ruby-install/truffleruby/dependencies.txt +++ /dev/null @@ -1,9 +0,0 @@ -apt: zlib1g-dev libssl-dev make gcc libxml2 libyaml-dev -dnf: zlib-devel openssl-devel make gcc libxml2 libyaml-devel -yum: zlib-devel openssl-devel make gcc libxml2 libyaml-devel -port: openssl libyaml -brew: openssl@1.1 libyaml -pacman: zlib openssl make gcc libxml2 libyaml -zypper: zlib-devel libopenssl-devel make gcc libxml2 libyaml-devel -pkg: openssl gmake gcc libxml2 libyaml -xbps: base-devel openssl-devel zlib-devel libxml2 libyaml-devel diff --git a/share/ruby-install/util.sh b/share/ruby-install/util.sh index 5b3dffc2..b16e1222 100644 --- a/share/ruby-install/util.sh +++ b/share/ruby-install/util.sh @@ -1,22 +1,5 @@ #!/usr/bin/env bash -# -# Searches a file for a key and echos the value. -# Nothing is returned if the key cannot be found. -# -function fetch() -{ - local file="$ruby_install_dir/$1.txt" - local key="$2" - local line - - while IFS="" read -r line; do - if [[ "$line" == "$key:"* ]]; then - echo "${line##$key:*([[:space:]])}" - fi - done < "$file" -} - # # Downloads a URL. # diff --git a/test/functions-tests/load_dependencies_from_test.sh b/test/functions-tests/load_dependencies_from_test.sh deleted file mode 100755 index 73bd8edb..00000000 --- a/test/functions-tests/load_dependencies_from_test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -. ./test/helper.sh -. ./share/ruby-install/functions.sh - -function setUp() -{ - ruby="ruby" - ruby_version="3.0.0" - package_manager="dnf" -} - -function test_load_dependencies_from() -{ - load_dependencies_from "dependencies" - - assertEquals "did not correctly set \$ruby_dependencies from \$ruby/dependencies.txt for \$package_manager" \ - "${ruby_dependencies[*]}" "xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" -} - -function tearDown() -{ - unset ruby ruby_version package_manager -} - -SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/functions-tests/load_dependencies_test.sh b/test/functions-tests/load_dependencies_test.sh index 42245b63..8ddb729b 100755 --- a/test/functions-tests/load_dependencies_test.sh +++ b/test/functions-tests/load_dependencies_test.sh @@ -14,7 +14,7 @@ function test_load_dependencies() { load_dependencies - assertEquals "did not correctly set \$ruby_dependencies from \$ruby/dependencies.txt for \$package_manager" \ + 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" } diff --git a/test/jruby-tests/dependencies_tests.sh b/test/jruby-tests/dependencies_tests.sh new file mode 100755 index 00000000..6ba2a254 --- /dev/null +++ b/test/jruby-tests/dependencies_tests.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +. ./test/helper.sh +. ./share/ruby-install/ruby-install.sh + +function setUp() +{ + ruby="jruby" + ruby_version="9.4.3.0" +} + +function test_when_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openjdk-8-jdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "java-openjdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "java-openjdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pacman() +{ + local original_package_manager="$package_manager" + package_manager="pacman" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "jre8-openjdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "java-1.8.0-openjdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pkg() +{ + local original_package_manager="$package_manager" + package_manager="pkg" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openjdk" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openjdk" + + package_manager="$original_package_manager" +} + +function tearDown() +{ + unset ruby ruby_version ruby_dependencies +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/mruby-tests/dependencies_tests.sh b/test/mruby-tests/dependencies_tests.sh new file mode 100755 index 00000000..caf9b451 --- /dev/null +++ b/test/mruby-tests/dependencies_tests.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +. ./test/helper.sh +. ./share/ruby-install/ruby-install.sh + +function setUp() +{ + ruby="mruby" + ruby_version="3.3.0" +} + +function test_when_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "build-essential bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gcc make bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gcc make bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_port() +{ + local original_package_manager="$package_manager" + package_manager="port" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_brew() +{ + local original_package_manager="$package_manager" + package_manager="brew" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pacman() +{ + local original_package_manager="$package_manager" + package_manager="pacman" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gcc make bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gcc make bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pkg() +{ + local original_package_manager="$package_manager" + package_manager="pkg" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gcc automake bison" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "base-devel" + + package_manager="$original_package_manager" +} + +function tearDown() +{ + unset ruby ruby_version ruby_dependencies +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/ruby-tests/dependencies_tests.sh b/test/ruby-tests/dependencies_tests.sh new file mode 100755 index 00000000..d7daff80 --- /dev/null +++ b/test/ruby-tests/dependencies_tests.sh @@ -0,0 +1,208 @@ +#!/usr/bin/env bash + +. ./test/helper.sh +. ./share/ruby-install/ruby-install.sh + +function setUp() +{ + ruby="ruby" + ruby_version="3.2.0" +} + +function test_when_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$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" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$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" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$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" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pacman() +{ + local original_package_manager="$package_manager" + package_manager="pacman" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$openssl_version" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "xz gcc make bison zlib ncurses openssl readline libyaml gdbm libffi" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$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" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pkg() +{ + local original_package_manager="$package_manager" + package_manager="pkg" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$openssl_version" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "openssl readline libyaml gdbm libffi" \ + "${ruby_dependencies[*]}" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertNull "accidentally set \$openssl_version" \ + "$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" \ + "${ruby_dependencies[*]}" + + 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" + package_manager="brew" + ruby_version="3.0.0" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$openssl_version" \ + "1.1" \ + "$openssl_version" + + assertTrue "did not add openssl@1.1 to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" openssl@1.1 "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_brew_and_ruby_version_is_greater_equal_to_3_1_0() +{ + local original_package_manager="$package_manager" + package_manager="brew" + ruby_version="3.1.0" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$openssl_version" \ + "3" \ + "$openssl_version" + + assertTrue "did not add openssl@3 to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" openssl@3 "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_port_and_ruby_version_is_less_than_3_1_0() +{ + local original_package_manager="$package_manager" + package_manager="port" + ruby_version="3.0.0" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$openssl_version" \ + "1.1" \ + "$openssl_version" + + assertTrue "did not add openssl11 to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" openssl11 "* ]]' + + package_manager="$original_package_manager" +} + +function test_package_manager_is_port_and_ruby_version_is_greater_equal_to_3_1_0() +{ + local original_package_manager="$package_manager" + package_manager="port" + ruby_version="3.1.0" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$openssl_version" \ + "3" \ + "$openssl_version" + + assertTrue "did not add openssl3 to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" openssl3 "* ]]' + + package_manager="$original_package_manager" +} + +function tearDown() +{ + unset ruby ruby_version ruby_dependencies openssl_version +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/ruby-tests/functions_tests.sh b/test/ruby-tests/functions_tests.sh index d9056946..a4074f23 100755 --- a/test/ruby-tests/functions_tests.sh +++ b/test/ruby-tests/functions_tests.sh @@ -19,84 +19,6 @@ function test_ruby_version_family() "$ruby_version_family" } -function test_openssl_version_when_package_manager_is_not_brew_or_port() -{ - local original_package_manager="$package_manager" - package_manager="apt" - - source "$ruby_install_dir/functions.sh" - source "$ruby_install_dir/ruby/functions.sh" - - assertNull "did not correctly set \$openssl_version" \ - "$openssl_version" - - package_manager="$original_package_manager" -} - -function test_openssl_version_when_package_manager_is_brew_and_ruby_version_is_less_than_3_1_0() -{ - local original_package_manager="$package_manager" - package_manager="brew" - ruby_version="3.0.0" - - source "$ruby_install_dir/functions.sh" - source "$ruby_install_dir/ruby/functions.sh" - - assertEquals "did not correctly set \$openssl_version" \ - "1.1" \ - "$openssl_version" - - package_manager="$original_package_manager" -} - -function test_openssl_version_when_package_manager_is_brew_and_ruby_version_is_greater_equal_to_3_1_0() -{ - local original_package_manager="$package_manager" - package_manager="brew" - ruby_version="3.1.0" - - source "$ruby_install_dir/functions.sh" - source "$ruby_install_dir/ruby/functions.sh" - - assertEquals "did not correctly set \$openssl_version" \ - "3" \ - "$openssl_version" - - package_manager="$original_package_manager" -} - -function test_openssl_version_when_package_manager_is_port_and_ruby_version_is_less_than_3_1_0() -{ - local original_package_manager="$package_manager" - package_manager="port" - ruby_version="3.0.0" - - source "$ruby_install_dir/functions.sh" - source "$ruby_install_dir/ruby/functions.sh" - - assertEquals "did not correctly set \$openssl_version" \ - "1.1" \ - "$openssl_version" - - package_manager="$original_package_manager" -} - -function test_openssl_version_when_package_manager_is_port_and_ruby_version_is_greater_equal_to_3_1_0() -{ - local original_package_manager="$package_manager" - package_manager="port" - ruby_version="3.1.0" - - source "$ruby_install_dir/functions.sh" - source "$ruby_install_dir/ruby/functions.sh" - - assertEquals "did not correctly set \$openssl_version" \ - "3" \ - "$openssl_version" - - package_manager="$original_package_manager" -} - function test_ruby_archive_ext() { assertEquals "did not set \$ruby_archive_ext to tar.xz" \ diff --git a/test/truffleruby-graalvm-tests/dependencies_tests.sh b/test/truffleruby-graalvm-tests/dependencies_tests.sh new file mode 100755 index 00000000..f684e47c --- /dev/null +++ b/test/truffleruby-graalvm-tests/dependencies_tests.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +. ./test/helper.sh +. ./share/ruby-install/ruby-install.sh + +function setUp() +{ + ruby="truffleruby-graalvm" + ruby_version="23.1.2" +} + +function test_when_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib1g-dev libssl-dev libxml2 libyaml-dev" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_port() +{ + local original_package_manager="$package_manager" + package_manager="port" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openssl libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_brew() +{ + local original_package_manager="$package_manager" + package_manager="brew" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openssl@1.1 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pacman() +{ + local original_package_manager="$package_manager" + package_manager="pacman" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib openssl libxml2 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel libopenssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pkg() +{ + local original_package_manager="$package_manager" + package_manager="pkg" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gmake gcc openssl libxml2 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "base-devel openssl-devel zlib-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function tearDown() +{ + unset ruby ruby_version ruby_dependencies +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/truffleruby-tests/dependencies_tests.sh b/test/truffleruby-tests/dependencies_tests.sh new file mode 100755 index 00000000..2a8b8825 --- /dev/null +++ b/test/truffleruby-tests/dependencies_tests.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +. ./test/helper.sh +. ./share/ruby-install/ruby-install.sh + +function setUp() +{ + ruby="truffleruby" + ruby_version="23.1.2" +} + +function test_when_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib1g-dev libssl-dev libxml2 libyaml-dev" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_port() +{ + local original_package_manager="$package_manager" + package_manager="port" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openssl libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_brew() +{ + local original_package_manager="$package_manager" + package_manager="brew" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "openssl@1.1 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pacman() +{ + local original_package_manager="$package_manager" + package_manager="pacman" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib openssl libxml2 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "make gcc zlib-devel libopenssl-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_pkg() +{ + local original_package_manager="$package_manager" + package_manager="pkg" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "gmake gcc openssl libxml2 libyaml" + + package_manager="$original_package_manager" +} + +function test_when_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertEquals "did not correctly set \$ruby_dependencies" \ + "${ruby_dependencies[*]}" \ + "base-devel openssl-devel zlib-devel libxml2 libyaml-devel" + + package_manager="$original_package_manager" +} + +function tearDown() +{ + unset ruby ruby_version ruby_dependencies +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/util-tests/fetch_test.sh b/test/util-tests/fetch_test.sh deleted file mode 100755 index d778db20..00000000 --- a/test/util-tests/fetch_test.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -. ./test/helper.sh - -ruby_install_dir="$test_fixtures_dir/fetch_test" - -test_file="$ruby_install_dir/db.txt" - -function setUp() -{ - mkdir -p "$ruby_install_dir" -} - -function test_fetch() -{ - local key="1.9.3" - local expected="1.9.3-p484" - - echo "$key: $expected" > "$test_file" - - local value=$(fetch "db" "$key") - - assertEquals "did not fetch the correct value" "$expected" "$value" -} - -function test_fetch_with_tabs() -{ - local key="ruby-1.9.3-p484.tar.bz2" - local expected="03f5b08804927ceabe5122cb90f5d0a9" - - echo -e "$key:\t$expected" > "$test_file" - - local value=$(fetch "db" "$key") - - assertEquals "did not remove the trailing tabs" "$expected" "$value" -} - -function test_fetch_with_excess_whitespace() -{ - local key="ruby-1.9.3-p484.tar.bz2" - local expected="03f5b08804927ceabe5122cb90f5d0a9" - - echo "$key: $expected" > "$test_file" - - local value=$(fetch "db" "$key") - - assertEquals "did not fetch the correct value" "$expected" "$value" -} - -function test_fetch_with_unknown_key() -{ - local key="foo" - local expected="" - - echo "bar: bar" > "$test_file" - - local value=$(fetch "db" "$key") - - assertEquals "returned the wrong value" "$expected" "$value" -} - -function tearDown() -{ - rm -rf "$ruby_install_dir" -} - -SHUNIT_PARENT=$0 . $SHUNIT2