Skip to content

Commit badbdfa

Browse files
committed
refactored tests
1 parent 96d80d5 commit badbdfa

File tree

5 files changed

+14
-28
lines changed

5 files changed

+14
-28
lines changed

Rakefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ require 'bundler/gem_tasks'
66
require 'rake/rdoctask'
77
require 'rake/testtask'
88

9-
BASE_TEST_FILE_LIST = %w(
10-
test/base/base.rb
11-
test/base/binding.rb
12-
test/base/catchpoint.rb)
9+
BASE_TEST_FILE_LIST = Dir['test/**/*_test.rb']
1310

1411
task :default => [:test_base]
1512

test/base/base.rb renamed to test/base/base_test.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#!/usr/bin/env ruby
2-
require 'test/unit'
2+
require_relative 'debug_test_base'
33

44
# Some tests of Debugger module in C extension ruby_debug
5-
class TestRubyDebug < Test::Unit::TestCase
6-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'ext')
7-
require 'ruby_debug'
8-
$:.shift
9-
5+
class TestRubyDebug < DebugTestBase
106
# test current_context
117
def test_current_context
128
assert_equal(false, Debugger.started?,

test/base/binding.rb renamed to test/base/binding_test.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
#!/usr/bin/env ruby
22

3-
require 'test/unit'
3+
require_relative 'debug_test_base'
44

55
# Test binding_n command
6-
class TestBinding < Test::Unit::TestCase
7-
8-
SRC_DIR = File.expand_path(File.dirname(__FILE__)) unless
9-
defined?(SRC_DIR)
10-
%w(ext lib).each do |dir|
11-
$:.unshift File.join(SRC_DIR, '..', '..', dir)
12-
end
13-
require File.join(SRC_DIR, '..', '..', 'lib', 'ruby-debug-base')
14-
$:.shift; $:.shift
15-
6+
class TestBinding < DebugTestBase
167
def test_basic
178
def inside_fn
189
s = 'some other string'

test/base/catchpoint.rb renamed to test/base/catchpoint_test.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
#!/usr/bin/env ruby
2-
require 'test/unit'
2+
require_relative 'debug_test_base'
33

44
# Test catchpoint in C ruby_debug extension.
55

6-
class TestRubyDebugCatchpoint < Test::Unit::TestCase
7-
8-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'ext')
9-
require 'ruby_debug'
10-
$:.shift
11-
6+
class TestRubyDebugCatchpoint < DebugTestBase
127
# test current_context
138
def test_catchpoints
149
assert_raise(RuntimeError) {Debugger.catchpoints}

test/base/debug_test_base.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'test/unit'
2+
require_relative '../../ext/ruby_debug/ruby_debug'
3+
require_relative '../../lib/ruby-debug-base'
4+
5+
class DebugTestBase < Test::Unit::TestCase
6+
7+
end

0 commit comments

Comments
 (0)