Sha256: 7b392fbebf73ceae6049328935796aa9e24539c685cb6108fef74d13f29b121b

Contents?: true

Size: 1.69 KB

Versions: 18

Compression:

Stored size: 1.69 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'webrick'
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end

class BugCrashOnDebug < Test::Unit::TestCase
  
  def test_on_progress_raise
    server = WEBrick::HTTPServer.new( :Port => 9999 )
    server.mount_proc("/test") do|req,res|
      res.body = "hi"
      res['Content-Type'] = "text/html"
    end

    thread = Thread.new(server) do|srv|
      srv.start
    end

    c = Curl::Easy.new('http://127.0.0.1:9999/test')
    c.on_progress do|x|
      raise "error"
    end
    c.perform

    assert false, "should not reach this point"

  rescue => e
    assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
    c.close
  ensure
    server.shutdown
  end

  def test_on_progress_abort
    server = WEBrick::HTTPServer.new( :Port => 9999 )
    server.mount_proc("/test") do|req,res|
      res.body = "hi"
      res['Content-Type'] = "text/html"
    end

    thread = Thread.new(server) do|srv|
      srv.start
    end

    # see: https://github.com/taf2/curb/issues/192,
    # to pass:
    # 
    # c = Curl::Easy.new('http://127.0.0.1:9999/test')
    # c.on_progress do|x|
    #   puts "we're in the progress callback"
    #   false
    # end
    # c.perform
    # 
    #  notice no return keyword
    #
    c = Curl::Easy.new('http://127.0.0.1:9999/test')
    c.on_progress do|x|
      puts "we're in the progress callback"
      return false
    end
    c.perform

    assert false, "should not reach this point"

  rescue => e
    assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
    c.close
  ensure
    server.shutdown
  end

end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
curb-1.0.1 tests/bug_crash_on_progress.rb
curb-1.0.0 tests/bug_crash_on_progress.rb
curb-0.9.11 tests/bug_crash_on_progress.rb
curb-0.9.10 tests/bug_crash_on_progress.rb
curb-0.9.9 tests/bug_crash_on_progress.rb
curb-0.9.8 tests/bug_crash_on_progress.rb
curb-0.9.7 tests/bug_crash_on_progress.rb
curb-0.9.6 tests/bug_crash_on_progress.rb
curb-0.9.5 tests/bug_crash_on_progress.rb
curb-0.9.4 tests/bug_crash_on_progress.rb
curb-0.9.3 tests/bug_crash_on_progress.rb
curb-0.9.2 tests/bug_crash_on_progress.rb
curb-0.9.1 tests/bug_crash_on_progress.rb
curb-0.9.0 tests/bug_crash_on_progress.rb
curb-0.8.8 tests/bug_crash_on_progress.rb
curb-0.8.7 tests/bug_crash_on_progress.rb
gus-curb-0.8.7 tests/bug_crash_on_progress.rb
curb-0.8.6 tests/bug_crash_on_progress.rb