/vendor/gems/ruby-debug-0.10.2/test/test-hist.rb
Ruby | 68 lines | 45 code | 14 blank | 9 comment | 1 complexity | cfce5c20f35b7c08f8ea6e18d58c9061 MD5 | raw file
Possible License(s): GPL-2.0
- #!/usr/bin/env ruby
- require 'test/unit'
- # begin require 'rubygems' rescue LoadError end
- # require 'ruby-debug'; Debugger.start
- # Test history commands
- class TestHistory < Test::Unit::TestCase
- @@SRC_DIR = File.dirname(__FILE__) unless
- defined?(@@SRC_DIR)
- require File.join(@@SRC_DIR, 'helper')
- include TestHelper
- unless defined?(@@FILE_HISTORY)
- @@FILE_HISTORY = '.rdebug_hist'
- end
- def test_basic
- # Set up history file to read from.
- ENV['HOME']=@@SRC_DIR
- ENV['RDEBUG'] = nil
- debugger_commands = ['show commands',
- 'set history save on',
- 'show history',
- 'quit unconditionally']
- debugger_output = 'test-history.out'
- Dir.chdir(@@SRC_DIR) do
- correct_lines = File.read(File.join('data', 'history.right')).split(/\n/)
- f = File.open(@@FILE_HISTORY, 'w')
- correct_lines[0.. -(debugger_commands.length+1)].each do |line|
- f.puts line
- end
- f.close
- # Now that we've set up a history file, run the debugger
- # and check that it's reading that correctly.
- debug_pgm=File.join('..', 'rdbg.rb')
- debugged=File.join('gcd.rb')
- IO.popen("#{debug_pgm} #{debugged} 3 5 >#{debugger_output}", 'w') do
- |pipe|
- debugger_commands.each do |cmd|
- pipe.puts cmd
- end
- end
-
- # Compare output
- got_lines = File.read(@@FILE_HISTORY).split(/\n/)
- # FIXME: Disable for now.
- assert true, 'FIXME'
- return
- if cheap_diff(got_lines, correct_lines)
- assert true
- FileUtils.rm(debugger_output)
- FileUtils.rm(@@FILE_HISTORY)
- else
- assert nil, 'Output differs'
- end
- end
- end
- end
-
-