summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-04 16:50:27 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-04 18:26:31 +0100
commit02c39dd8eef95941d1dcfe8fc11ab469ba2670b3 (patch)
treee31a071456d6660e8dbafe04774dfbf7f971577d
parent512cceea4e5b9f6898523b147810b55de32c82d0 (diff)
downloadbundler-02c39dd8eef95941d1dcfe8fc11ab469ba2670b3.tar.gz
Move sudo specs setup to `rake spec:sudo`
-rw-r--r--.travis.yml5
-rw-r--r--Rakefile15
2 files changed, 15 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml
index 5faa930a95..638d19b6e1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,10 +2,7 @@ language: ruby
dist: bionic
script:
- bin/parallel_rspec spec
- - sudo sed -i '/secure_path/d' /etc/sudoers
- - test "$(ruby -v)" = "$(sudo -E ruby -v)"
- - sudo -E bin/rake spec:sudo
- - sudo chown -R $(whoami) tmp
+ - bin/rake spec:sudo
- BUNDLER_SPEC_PRE_RECORDED=1 bin/rake spec:realworld
before_script:
diff --git a/Rakefile b/Rakefile
index eac9148c60..814a23492c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -55,7 +55,20 @@ namespace :spec do
end
desc "Run the spec suite with the sudo tests"
- task :sudo => %w[set_sudo spec]
+ task :sudo => %w[set_sudo] do
+ require "open3"
+
+ output, status = Open3.capture2e("sudo sed -i '/secure_path/d' /etc/sudoers")
+ raise "Couldn't configure sudo to preserve path: #{output}" unless status.success?
+
+ raise "Couldn't configure sudo correctly to preserve path" unless `ruby -v` == `sudo -E ruby -v`
+
+ begin
+ sh("sudo -E bin/rspec")
+ ensure
+ system("sudo", "chown", "-R", ENV["USER"], "tmp")
+ end
+ end
task :set_sudo do
ENV["BUNDLER_SUDO_TESTS"] = "1"