mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 21:27:11 -07:00
Migrate completion tests to Cucumber.
Also retire Fish 2.x + macOS test; installation of custom brew didn't work out anymore.
This commit is contained in:
parent
ed6039e533
commit
0c15f199cd
12 changed files with 364 additions and 236 deletions
42
test/features/support/helpers.rb
Normal file
42
test/features/support/helpers.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
def list_installed_candidates
|
||||
candidates = {}
|
||||
|
||||
Dir["#{ENV['HOME']}/.sdkman/candidates/*/*"].each do |candidate_dir|
|
||||
%r{/([^/]+)/([^/]+)$}.match(candidate_dir) do |match|
|
||||
candidate = match[1]
|
||||
version = match[2]
|
||||
candidates[candidate] = [] unless candidates.key?(candidate)
|
||||
candidates[candidate].push version unless version == 'current'
|
||||
end
|
||||
end
|
||||
|
||||
candidates
|
||||
end
|
||||
|
||||
def installed?(candidate, version = nil)
|
||||
candidates = list_installed_candidates
|
||||
candidates.key?(candidate) && (version.nil? || candidates[candidate].include?(version))
|
||||
end
|
||||
|
||||
def run_bash_command(cmd)
|
||||
stdout, stderr, status = Open3.capture3("bash -c 'source \"$HOME/.sdkman/bin/sdkman-init.sh\"; #{cmd}'")
|
||||
unless status.success?
|
||||
warn(stderr)
|
||||
raise "Bash command failed: #{stderr}"
|
||||
end
|
||||
|
||||
stdout
|
||||
end
|
||||
|
||||
def run_fish_command(cmd)
|
||||
# NB: Fish errors out if we don't set terminal dimensions
|
||||
stdout, stderr, status = Open3.capture3("fish -c 'stty rows 80 columns 80; #{cmd}'")
|
||||
unless status.success?
|
||||
warn(stderr)
|
||||
raise 'Fish command failed'
|
||||
end
|
||||
|
||||
stdout
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue