diff --git a/test/misc.jl b/test/misc.jl index 04992d90261b8..11ca85f74a7db 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -2,145 +2,6 @@ # Tests that do not really go anywhere else -# The following tests for deprecated functionality are disabled when --depwarn=error. -# TODO: Clean this up by reimplementing depwarn=error with a logger. -if Base.JLOptions().depwarn != 2 - -# Test info -@test contains(sprint(info, "test"), "INFO:") -@test contains(sprint(info, "test"), "INFO: test") -@test contains(sprint(info, "test ", 1, 2, 3), "INFO: test 123") -@test contains(sprint(io->info(io,"test", prefix="MYINFO: ")), "MYINFO: test") - -# Test warn -@test contains(sprint(Base.warn_once, "test"), "WARNING: test") -@test isempty(sprint(Base.warn_once, "test")) - -@test contains(sprint(warn), "WARNING:") -@test contains(sprint(warn, "test"), "WARNING: test") -@test contains(sprint(warn, "test ", 1, 2, 3), "WARNING: test 123") -@test contains(sprint(io->warn(io, "test", prefix="MYWARNING: ")), "MYWARNING: test") -@test contains(sprint(io->warn(io, "testonce", once=true)), "WARNING: testonce") -@test isempty(sprint(io->warn(io, "testonce", once=true))) -@test !isempty(sprint(io->warn(io, "testonce", once=true, key=hash("testonce",hash("testanother"))))) -let bt = backtrace() - ws = split(chomp(sprint(io->warn(io, "test", bt = bt))), '\n') - bs = split(chomp(sprint(Base.show_backtrace, bt)), '\n') - @test contains(ws[1],"WARNING: test") - for (l,b) in zip(ws[2:end],bs[2:end]) - @test contains(l, b) - end -end - -# PR #16213 -@eval module LogTest - function bar(io) - info(io,"barinfo") - warn(io,"barwarn") - Base.display_error(io,"barerror",backtrace()) - end - function pooh(io) - info(io,"poohinfo") - warn(io,"poohwarn") - Base.display_error(io,"pooherror",backtrace()) - end -end -function foo(io) - info(io,"fooinfo") - warn(io,"foowarn") - Base.display_error(io,"fooerror",backtrace()) -end - -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - - -logging(DevNull, LogTest, :bar; kind=:info) -@test all(contains.(sprint(LogTest.bar), ["WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull, LogTest; kind=:info) -@test all(contains.(sprint(LogTest.bar), ["WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull; kind=:info) -@test all(contains.(sprint(LogTest.bar), ["WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(kind=:info) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - - -logging(DevNull, LogTest, :bar; kind=:warn) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull, LogTest; kind=:warn) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull; kind=:warn) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "ERROR: \"fooerror\""])) - -logging(kind=:warn) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - - -logging(DevNull, LogTest, :bar; kind=:error) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn"])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull, LogTest; kind=:error) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn"])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn"])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull; kind=:error) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn"])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn"])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn"])) - -logging(kind=:error) -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - - -logging(DevNull, LogTest, :bar) -@test sprint(LogTest.bar) == "" -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull, LogTest) -@test sprint(LogTest.bar) == "" -@test sprint(LogTest.pooh) == "" -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -logging(DevNull) -@test sprint(LogTest.bar) == "" -@test sprint(LogTest.pooh) == "" -@test sprint(foo) == "" - -logging() -@test all(contains.(sprint(LogTest.bar), ["INFO: barinfo", "WARNING: barwarn", "ERROR: \"barerror\""])) -@test all(contains.(sprint(LogTest.pooh), ["INFO: poohinfo", "WARNING: poohwarn", "ERROR: \"pooherror\""])) -@test all(contains.(sprint(foo), ["INFO: fooinfo", "WARNING: foowarn", "ERROR: \"fooerror\""])) - -end - # test assert() method @test_throws AssertionError assert(false) let res = assert(true)