mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use absolute path on find_method location for the runner
This commit is contained in:
parent
4bb9268474
commit
a9eb12393f
2 changed files with 6 additions and 5 deletions
|
@ -129,7 +129,7 @@ module Rails
|
||||||
location = method.source_location
|
location = method.source_location
|
||||||
start_line = location.last
|
start_line = location.last
|
||||||
end_line = method.source.split("\n").size + start_line - 1
|
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
|
||||||
end
|
end
|
||||||
methods_map
|
methods_map
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test "parse the filename and line" do
|
test "parse the filename and line" do
|
||||||
file = "test/test_unit/runner_test.rb"
|
file = "test/test_unit/runner_test.rb"
|
||||||
absolute_file = __FILE__
|
absolute_file = File.expand_path __FILE__
|
||||||
options = @options.parse(["#{file}:20"])
|
options = @options.parse(["#{file}:20"])
|
||||||
assert_equal absolute_file, options[:filename]
|
assert_equal absolute_file, options[:filename]
|
||||||
assert_equal 20, options[:line]
|
assert_equal 20, options[:line]
|
||||||
|
@ -90,21 +90,22 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test "run multiple files and run one file by line" do
|
test "run multiple files and run one file by line" do
|
||||||
line = __LINE__
|
line = __LINE__
|
||||||
|
absolute_file = File.expand_path(__FILE__)
|
||||||
options = @options.parse([__dir__, "#{__FILE__}:#{line}"])
|
options = @options.parse([__dir__, "#{__FILE__}:#{line}"])
|
||||||
|
|
||||||
assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
|
assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
|
||||||
assert_equal __FILE__, options[:filename]
|
assert_equal absolute_file, options[:filename]
|
||||||
assert_equal line, options[:line]
|
assert_equal line, options[:line]
|
||||||
|
|
||||||
runner = Rails::TestRunner.new(options)
|
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
|
end
|
||||||
|
|
||||||
test "running multiple files passing line number" do
|
test "running multiple files passing line number" do
|
||||||
line = __LINE__
|
line = __LINE__
|
||||||
options = @options.parse(["foobar.rb:8", "#{__FILE__}:#{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]
|
assert_equal line, options[:line]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue