Skip to content

Commit

Permalink
support relative gemfile reference when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcai committed Sep 30, 2024
1 parent fca88a3 commit fa85535
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- ruby: "head"
gemfile: gemfiles/rails_head.gemfile
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_head.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# $ BUNDLE_GEMFILE="$(pwd)/gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:50
# $ BUNDLE_GEMFILE="gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:50

source "https://rubygems.org"

Expand Down
10 changes: 7 additions & 3 deletions test/integration/tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def rake(cmd, options = {})
env_string = env.map {|key, value| "#{key.shellescape}=#{value.to_s.shellescape}" }.join(" ")
cmd = "env #{env_string} bundle exec rake -f perf.rake #{cmd} --trace"
puts "Running: #{cmd}"
result = Bundler.with_original_env { `cd '#{rails_app_path}' && #{cmd} 2>&1` }
result = Bundler.with_original_env do
# Ensure relative BUNDLE_GEMFILE is expanded so path is still correct after cd
ENV['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE']) if ENV['BUNDLE_GEMFILE']
`cd '#{rails_app_path}' && #{cmd} 2>&1`
end
if assert_success && !$?.success?
puts result
raise "Expected '#{cmd}' to return a success status.\nOutput: #{result}"
Expand All @@ -44,7 +48,7 @@ def rake(cmd, options = {})
end

test 'rails perf:library from git' do
# BUNDLE_GEMFILE="$(pwd)/gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:<linenumber>
# BUNDLE_GEMFILE="gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:<linenumber>

skip # unless ENV['USING_RAILS_GIT']

Expand All @@ -54,7 +58,7 @@ def rake(cmd, options = {})
end

test "rails perf:library with bad script" do
# BUNDLE_GEMFILE="$(pwd)/gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:<linenumber>
# BUNDLE_GEMFILE="gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:<linenumber>

skip # unless ENV['USING_RAILS_GIT']

Expand Down

0 comments on commit fa85535

Please sign in to comment.