Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip overwriting ~/.pearrc for PHP 5.3 and older #1236

Merged
merged 3 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/travis/build/script/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def setup
sh.if "$? -ne 0" do
install_php_on_demand(version)
end
sh.else do
sh.fold "pearrc" do
sh.echo "Writing $HOME/.pearrc", ansi: :yellow
overwrite_pearrc(version)
sh.cmd "pear config-show", echo: true
unless php_5_3_or_older?
sh.else do
sh.fold "pearrc" do
sh.echo "Writing $HOME/.pearrc", ansi: :yellow
overwrite_pearrc(version)
sh.cmd "pear config-show", echo: true
end
end
end
sh.cmd "phpenv global #{version}", assert: true
Expand Down Expand Up @@ -191,6 +193,10 @@ def composer_self_update
end
end

def php_5_3_or_older?
!hhvm? && Gem::Version.new(version) < Gem::Version.new('5.4')
end

def overwrite_pearrc(version)
pear_config = %q(
[
Expand Down
14 changes: 14 additions & 0 deletions spec/build/script/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
xit { should include_sexp [:cmd, 'curl -s -o archive.tar.bz2 $archive_url && tar xjf archive.tar.bz2 --directory /', timing: true] }
end

context 'with php 5.4' do
describe 'writes ~/.pearrc if necessary' do
before { data[:config][:php] = '5.4' }
it { should include_sexp [:echo, 'Writing $HOME/.pearrc', ansi: :yellow] }
end
end

context 'with php 5.3' do
describe 'does not write ~/.pearrc' do
before { data[:config][:php] = '5.3' }
it { should_not include_sexp [:echo, 'Writing $HOME/.pearrc', ansi: :yellow] }
end
end

describe 'installs php 7' do
before { data[:config][:php] = '7' }
it { should include_sexp [:cmd, 'ln -s ~/.phpenv/versions/7.0 ~/.phpenv/versions/7', assert: true, timing: true] }
Expand Down