Skip to content

Commit

Permalink
Merge branch 'bin_test_runner'. #19216
Browse files Browse the repository at this point in the history
3 commits were missing when we merged the PR, probably they were lost
when that branch was rebased against latest master.
This merge, contains those 3 commits.
  • Loading branch information
arthurnn committed Mar 19, 2015
2 parents 9959e95 + a9eb123 commit 45786be
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ instance_eval File.read local_gemfile if File.exist? local_gemfile
group :test do
# FIX: Our test suite isn't ready to run in random order yet
gem 'minitest', '< 5.3.4'
gem 'method_source'

platforms :mri_19 do
gem 'ruby-prof', '~> 0.11.2'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PATH
railties (5.0.0.alpha)
actionpack (= 5.0.0.alpha)
activesupport (= 5.0.0.alpha)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)

Expand Down Expand Up @@ -261,7 +262,6 @@ DEPENDENCIES
json
kindlerb (= 0.1.1)
mail!
method_source
minitest (< 5.3.4)
mocha (~> 0.14)
mysql (>= 2.9.0)
Expand Down
4 changes: 0 additions & 4 deletions railties/lib/rails/generators/rails/app/templates/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ group :development, :test do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
<% end -%>
# Adds `Method#source` and `Method#comment` to get the source code of a
# method from the console
gem 'method_source'
<% end -%>
end
<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/test_unit/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_methods
location = method.source_location
start_line = location.last
end_line = method.source.split("\n").size + start_line - 1
methods_map << [location.first, test_method, start_line, end_line]
methods_map << [File.expand_path(location.first), test_method, start_line, end_line]
end
end
methods_map
Expand Down
4 changes: 2 additions & 2 deletions railties/lib/rails/test_unit/testing.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ task default: :test
desc "Runs all tests in test folder"
task :test do
$: << "test"
ARGV.shift if ARGV[0] == "test"
Rails::TestRunner.run(ARGV)
args = ARGV[0] == "test" ? ARGV[1..-1] : []
Rails::TestRunner.run(args)
end

namespace :test do
Expand Down
1 change: 1 addition & 0 deletions railties/railties.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Gem::Specification.new do |s|

s.add_dependency 'rake', '>= 0.8.7'
s.add_dependency 'thor', '>= 0.18.1', '< 2.0'
s.add_dependency 'method_source'

s.add_development_dependency 'actionview', version
end
7 changes: 0 additions & 7 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,6 @@ def test_inclusion_of_a_debugger
end
end

def test_inclusion_of_method_source
run_generator
assert_file "Gemfile" do |content|
assert_gem 'method_source'
end
end

def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]))
Expand Down
9 changes: 5 additions & 4 deletions railties/test/test_unit/runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase

test "parse the filename and line" do
file = "test/test_unit/runner_test.rb"
absolute_file = __FILE__
absolute_file = File.expand_path __FILE__
options = @options.parse(["#{file}:20"])
assert_equal absolute_file, options[:filename]
assert_equal 20, options[:line]
Expand Down Expand Up @@ -90,21 +90,22 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase

test "run multiple files and run one file by line" do
line = __LINE__
absolute_file = File.expand_path(__FILE__)
options = @options.parse([__dir__, "#{__FILE__}:#{line}"])

assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
assert_equal __FILE__, options[:filename]
assert_equal absolute_file, options[:filename]
assert_equal line, options[:line]

runner = Rails::TestRunner.new(options)
assert_equal [__FILE__], runner.test_files, 'Only returns the file that running by line'
assert_equal [absolute_file], runner.test_files, 'Only returns the file that running by line'
end

test "running multiple files passing line number" do
line = __LINE__
options = @options.parse(["foobar.rb:8", "#{__FILE__}:#{line}"])

assert_equal __FILE__, options[:filename], 'Returns the last file'
assert_equal File.expand_path(__FILE__), options[:filename], 'Returns the last file'
assert_equal line, options[:line]
end
end

0 comments on commit 45786be

Please sign in to comment.