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

support relative gemfile reference when running tests #245

Merged
merged 2 commits into from
Sep 30, 2024
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
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Test Rails 7.1 and 7.2 (https://github.com/zombocom/derailed_benchmarks/pull/242)
- Switch from dead_end to syntax_suggest (https://github.com/zombocom/derailed_benchmarks/pull/243)
- require `ruby2_keywords` so drb doesn't break in ruby < 2.7 (https://github.com/zombocom/derailed_benchmarks/pull/244)
- support relative BUNDLE_GEMFILE in tests (https://github.com/zombocom/derailed_benchmarks/pull/245)

## 2.1.2

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
12 changes: 7 additions & 5 deletions test/integration/tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def teardown
end

def run!(cmd)
puts "Running: #{cmd}"
out = `#{cmd}`
raise "Could not run #{cmd}, output: #{out}" unless $?.success?
out
Expand All @@ -25,8 +24,11 @@ def rake(cmd, options = {})
env = options[:env] || {}
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 +46,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 +56,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
2 changes: 0 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"


require "ruby2_keywords" if RUBY_VERSION < "2.7"

require 'rails'
Expand All @@ -18,7 +17,6 @@
require 'derailed_benchmarks'

require File.expand_path("../rails_app/config/environment.rb", __FILE__)
require "rails/test_help"

ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
Expand Down