Commit 4d88f649 authored by Douwe Maan's avatar Douwe Maan

Merge branch '38280-undefined-run_command-when-running-rake-gitlab-check' into 'master'

Resolve "Undefined run_command when running rake gitlab:check"

Closes #38280

See merge request gitlab-org/gitlab-ce!14469
parents 3f4653ad c505a523
---
title: Some checks in `rake gitlab:check` were failling with 'undefined method `run_command`'
merge_request: 14469
author:
type: fixed
......@@ -9,7 +9,7 @@ module SystemCheck
end
def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(run_command(%W(#{Gitlab.config.git.bin_path} --version)))
@current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W(#{Gitlab.config.git.bin_path} --version)))
end
def check?
......
......@@ -9,7 +9,7 @@ module SystemCheck
end
def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(run_command(%w(ruby --version)))
@current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%w(ruby --version)))
end
def check?
......
require 'spec_helper'
describe SystemCheck::BaseCheck do
context 'helpers on instance level' do
it 'responds to SystemCheck::Helpers methods' do
expect(subject).to respond_to :fix_and_rerun, :for_more_information, :see_installation_guide_section,
:finished_checking, :start_checking, :try_fixing_it, :sanitized_message, :should_sanitize?, :omnibus_gitlab?,
:sudo_gitlab
end
it 'responds to Gitlab::TaskHelpers methods' do
expect(subject).to respond_to :ask_to_continue, :os_name, :prompt, :run_and_match, :run_command,
:run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :all_repos,
:repository_storage_paths_args, :user_home, :checkout_or_clone_version, :clone_repo, :checkout_version
end
end
end
......@@ -75,4 +75,24 @@ describe Gitlab::TaskHelpers do
subject.checkout_version(tag, clone_path)
end
end
describe '#run_command' do
it 'runs command and return the output' do
expect(subject.run_command(%w(echo it works!))).to eq("it works!\n")
end
it 'returns empty string when command doesnt exist' do
expect(subject.run_command(%w(nonexistentcommand with arguments))).to eq('')
end
end
describe '#run_command!' do
it 'runs command and return the output' do
expect(subject.run_command!(%w(echo it works!))).to eq("it works!\n")
end
it 'returns and exception when command exit with non zero code' do
expect { subject.run_command!(['bash', '-c', 'exit 1']) }.to raise_error Gitlab::TaskFailedError
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment