From 2ff1861555b236516c0017766218aeffb10aabe9 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Sun, 10 Dec 2023 23:09:39 -0500 Subject: [PATCH] simplify output file management: always append; change output format the format is now that of method defn --- src/StabilityCheck.jl | 7 +++---- src/utils.jl | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/StabilityCheck.jl b/src/StabilityCheck.jl index 8df9580ae..9ecd073f9 100644 --- a/src/StabilityCheck.jl +++ b/src/StabilityCheck.jl @@ -126,8 +126,7 @@ is_stable_method(m::Method, scfg :: SearchCfg = default_scfg) :: StCheck = begin # trace TS checks and store to a file if scfg.trace_checks - mkpath("checks") - fchecks = open("checks/$(m.name)", "w") + fchecks = open("checks", "a") end # preemptively load types DB if available: we may need to sample @@ -150,7 +149,7 @@ is_stable_method(m::Method, scfg :: SearchCfg = default_scfg) :: StCheck = begin @debug "is_stable_method: check against signature (2a)" try scfg.trace_checks && - println(fchecks, sig_types) + print_check(fchecks, m, sig_types) if is_stable_call(func, sig_types) scfg.trace_checks && close(fchecks) @@ -200,7 +199,7 @@ is_stable_method(m::Method, scfg :: SearchCfg = default_scfg) :: StCheck = begin # the actual stability check try scfg.trace_checks && - println(fchecks, ts) + print_check(fchecks, m, ts) if ! is_stable_call(func, ts) push!(unst, ts) if scfg.failfast diff --git a/src/utils.jl b/src/utils.jl index e5158ce75..8ad4b1aa6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -134,3 +134,12 @@ is_module_nested(m::Module, outer::Module) :: Bool = begin m = parentmodule(m) end end + +# Print type stability check in a form of pseudo-method declaration +print_check(io, m::Method, @nospecialize(types)) = begin + print(io, "function $(m.name)(") + for t in types + print(io, "::$t") + end + println(io, ")") +end