Skip to content

Commit

Permalink
test to find the IOError
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Sep 22, 2023
1 parent 4bf5499 commit 20620ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/cases/helper_cockroachdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@
# Turn on debugging for the test environment
ENV['DEBUG_COCKROACHDB_ADAPTER'] = "1"


# DEBUG: start debugging the closed for writing message.
def bugmsg(header, stdout)
bugged = ""
begin
print
true
rescue IOError
bugged = "💥 "
false
end
STDOUT.puts "🤞#{header.rjust(17)}: stdout=#{stdout.inspect} #{bugged}(at #{caller_locations(2, 1).first})"
end

trace_var :$stdout, (proc { bugmsg("$stdout=", _1) })

TracePoint.trace(:a_return) do |tp|
next unless tp.method_id == :reopen
next unless tp.self == $stdout

bugmsg("$stdout#reopen",$stdout)
end
# DEBUG: end debugging the closed for writing message.

# Load ActiveRecord test helper
require "cases/helper"

Expand Down
2 changes: 2 additions & 0 deletions test/cases/migration/foreign_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,12 @@ def test_add_foreign_key_with_prefix
def test_add_foreign_key_with_suffix
ActiveRecord::Base.table_name_suffix = "_s"
migration = CreateSchoolsAndClassesMigration.new
Debug.say "since we are silencing we don't see the error, but somehow the suffix is not coming back"
silence_stream($stdout) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("classes_s").size
ensure
silence_stream($stdout) { migration.migrate(:down) }
Debug.say "does the code goes up till here?"
ActiveRecord::Base.table_name_suffix = nil
end

Expand Down

0 comments on commit 20620ea

Please sign in to comment.