summaryrefslogtreecommitdiff
path: root/test/rake/test_rake_backtrace.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rake/test_rake_backtrace.rb')
-rw-r--r--test/rake/test_rake_backtrace.rb52
1 files changed, 38 insertions, 14 deletions
diff --git a/test/rake/test_rake_backtrace.rb b/test/rake/test_rake_backtrace.rb
index cfd58f2..8db3b5a 100644
--- a/test/rake/test_rake_backtrace.rb
+++ b/test/rake/test_rake_backtrace.rb
@@ -1,7 +1,36 @@
require File.expand_path('../helper', __FILE__)
require 'open3'
+class TestBacktraceSuppression < Rake::TestCase
+ def test_bin_rake_suppressed
+ paths = ["something/bin/rake:12"]
+
+ actual = Rake::Backtrace.collapse(paths)
+
+ assert_equal [], actual
+ end
+
+ def test_system_dir_suppressed
+ path = RbConfig::CONFIG['rubylibprefix']
+ paths = [path + ":12"]
+
+ actual = Rake::Backtrace.collapse(paths)
+
+ assert_equal [], actual
+ end
+
+ def test_near_system_dir_isnt_suppressed
+ path = RbConfig::CONFIG['rubylibprefix']
+ paths = [" " + path + ":12"]
+
+ actual = Rake::Backtrace.collapse(paths)
+
+ assert_equal paths, actual
+ end
+end
+
class TestRakeBacktrace < Rake::TestCase
+ include RubyRunner
def setup
super
@@ -10,15 +39,9 @@ class TestRakeBacktrace < Rake::TestCase
Dir.pwd =~ Rake::Backtrace::SUPPRESS_PATTERN
end
- # TODO: factor out similar code in test_rake_functional.rb
- def rake(*args)
- Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, _, err, _|
- err.read
- }
- end
-
- def invoke(task_name)
- rake task_name.to_s
+ def invoke(*args)
+ rake(*args)
+ @err
end
def test_single_collapse
@@ -28,7 +51,7 @@ class TestRakeBacktrace < Rake::TestCase
end
}
- lines = invoke(:foo).split("\n")
+ lines = invoke("foo").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "foooo!", lines[1]
@@ -46,7 +69,7 @@ class TestRakeBacktrace < Rake::TestCase
end
}
- lines = invoke(:foo).split("\n")
+ lines = invoke("foo").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "barrr!", lines[1]
@@ -62,12 +85,12 @@ class TestRakeBacktrace < Rake::TestCase
end
}
- lines = rake("baz").split("\n")
+ lines = invoke("baz").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "bazzz!", lines[1]
assert_something_matches %r!Rakefile!i, lines
- lines = rake("--suppress-backtrace", ".ak.file", "baz").split("\n")
+ lines = invoke("--suppress-backtrace", ".ak.file", "baz").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "bazzz!", lines[1]
refute_match %r!Rakefile!i, lines[2]
@@ -83,7 +106,8 @@ class TestRakeBacktrace < Rake::TestCase
return
end
end
- flunk "expected #{pattern.inspect} to match something in:\n #{lines.join("\n ")}"
+ flunk "expected #{pattern.inspect} to match something in:\n" +
+ "#{lines.join("\n ")}"
end
end