Skip to content

Commit

Permalink
debug test in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 16, 2024
1 parent 64451ec commit 0c2ce10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/sqlite3/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def initialize file, options = {}, zvfs = nil
# See adr/2024-09-fork-safety.md for more information on fork safety.
def close
if Process.pid != @owner_pid
warn "WARNING: An open sqlite database connection was inherited from a forked process and " \
warn "An open sqlite database connection was inherited from a forked process and " \
"is being discarded. This is a memory leak. If possible, please close all sqlite " \
"database connections before forking."
"database connections before forking.", uplevel: 1
discard
else
_close
Expand Down
7 changes: 4 additions & 3 deletions test/test_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,10 @@ def test_close_in_a_new_process_calls_discard_and_warns
db.define_singleton_method(:discard) do
called = true
end
db.instance_variable_set(:@owner_pid, Process.pid + 1)

assert_output(nil, /WARNING: An open sqlite database connection was inherited from a forked process/) do
db.instance_variable_set(:@owner_pid, 1)
pp db
Kernel.warn "this is a warning"
assert_output(nil, /warning: An open sqlite database connection was inherited from a forked process/) do
db.close
end
assert(called)
Expand Down

0 comments on commit 0c2ce10

Please sign in to comment.