Sha256: 1331085682b5dc407cefd89db1a33184dcbbb072fd25b7d27f683bb1ed6d0ccb

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env ruby
require File.expand_path("../helper", __FILE__)

# Test history commands

class TestHistory < Test::Unit::TestCase

  @@SRC_DIR = File.dirname(__FILE__) unless 
    defined?(@@SRC_DIR)

  include TestHelper

  unless defined?(@@FILE_HISTORY)
    @@FILE_HISTORY = '.rdebug_hist'
  end

  def test_basic
    # FIXME: Disable for now.
    assert true, 'FIXME'
    return

    # 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(%w(.. rdbg.rb))
      debugged=File.join(%w(. example 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/)
      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
    
    

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-debug-0.10.5.rc1 test/test-hist.rb