[Feature #20244] Issue a single Warning.warn
call
Make the entire series of message lines a multiline string so that the `Warning.warn` hook can receive them in a single call.
This commit is contained in:
parent
67fe047821
commit
5326337d4f
8
dir.c
8
dir.c
@ -1082,9 +1082,13 @@ chdir_alone_block_p(void)
|
||||
if (rb_thread_current() != chdir_lock.thread)
|
||||
rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block");
|
||||
if (!block_given) {
|
||||
rb_warn("conflicting chdir during another chdir block");
|
||||
if (!NIL_P(chdir_lock.path)) {
|
||||
rb_compile_warn(RSTRING_PTR(chdir_lock.path), chdir_lock.line, "here");
|
||||
rb_warn("conflicting chdir during another chdir block\n"
|
||||
"%" PRIsVALUE ":%d: note: previous chdir was here",
|
||||
chdir_lock.path, chdir_lock.line);
|
||||
}
|
||||
else {
|
||||
rb_warn("conflicting chdir during another chdir block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,26 @@ class TestDir < Test::Unit::TestCase
|
||||
42
|
||||
end
|
||||
|
||||
assert_separately(["-", @root], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
root = ARGV.shift
|
||||
|
||||
$dir_warnings = []
|
||||
|
||||
def Warning.warn(message)
|
||||
$dir_warnings << message
|
||||
end
|
||||
|
||||
line2 = line1 = __LINE__; Dir.chdir(root) do
|
||||
line2 = __LINE__; Dir.chdir
|
||||
end
|
||||
|
||||
message = $dir_warnings.shift
|
||||
assert_include(message, "#{__FILE__}:#{line2}:")
|
||||
assert_include(message, "#{__FILE__}:#{line1}:")
|
||||
assert_empty($dir_warnings)
|
||||
end;
|
||||
|
||||
assert_equal(42, ret)
|
||||
ensure
|
||||
begin
|
||||
|
Loading…
x
Reference in New Issue
Block a user