Skip to content

Commit

Permalink
simplify JET (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov authored Sep 14, 2024
1 parent 9a66a46 commit d6aadeb
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions test/test_jet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@ using Test
using QuantumOpticsBase
using JET

using JET: ReportPass, BasicPass, InferenceErrorReport, UncaughtExceptionReport

# Custom report pass that ignores `UncaughtExceptionReport`
# Too coarse currently, but it serves to ignore the various
# "may throw" messages for runtime errors we raise on purpose
# (mostly on malformed user input)
struct MayThrowIsOk <: ReportPass end

# ignores `UncaughtExceptionReport` analyzed by `JETAnalyzer`
(::MayThrowIsOk)(::Type{UncaughtExceptionReport}, @nospecialize(_...)) = return

# forward to `BasicPass` for everything else
function (::MayThrowIsOk)(report_type::Type{<:InferenceErrorReport}, @nospecialize(args...))
BasicPass()(report_type, args...)
end

# imported to be declared as modules filtered out from analysis result
using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, RandomMatrices

@testset "jet" begin
if get(ENV,"JET_TEST","")=="true"
rep = report_package("QuantumOpticsBase";
report_pass=MayThrowIsOk(), # TODO have something more fine grained than a generic "do not care about thrown errors"
ignored_modules=( # TODO fix issues with these modules or report them upstream
AnyFrameModule(LinearAlgebra),
AnyFrameModule(LRUCache),
Expand All @@ -35,7 +18,7 @@ using LinearAlgebra, LRUCache, Strided, StridedViews, Dates, SparseArrays, Rando
AnyFrameModule(RandomMatrices))
)
@show rep
@test length(JET.get_reports(rep)) <= 29
@test length(JET.get_reports(rep)) <= 24
@test_broken length(JET.get_reports(rep)) == 0
end
end # testset

0 comments on commit d6aadeb

Please sign in to comment.