Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aqua.jl and JET.jl tests #57

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ Unitful = "1"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Documenter", "NBInclude", "Printf", "Test", "SafeTestsets"]
test = ["Documenter", "NBInclude", "Printf", "Test", "SafeTestsets", "Aqua"]
5 changes: 3 additions & 2 deletions src/DiscreteEvents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module DiscreteEvents
"Gives the package version."
const version = v"0.3.5"

using Unitful, Random, DataStructures, Logging, .Threads, Distributions
using Unitful, Random, DataStructures, Logging, .Threads
import Distributions: Distribution
import Unitful: FreeUnits, Time

include("types.jl")
Expand All @@ -48,7 +49,7 @@ include("macros.jl")

export Clock, RTClock, setUnit!, 𝐶,
Action, Timing, at, after, every, before, until,
tau, sample_time!, fun, event!, periodic!, register!,
tau, sample_time!, fun, event!, periodic!,
incr!, run!, stop!, resume!, sync!, resetClock!,
Prc, process!, interrupt!, delay!, wait!, now!,
createRTClock, stopRTClock,
Expand Down
2 changes: 1 addition & 1 deletion src/clock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function step!(clk::Clock, ::Idle, σ::Run)
clk.ac[ix].load += token.t
break
elseif token isa Forward
assign(clk, token.ev, token.id)
_assign(clk, token.ev, token.id)
elseif token isa Error
return nothing
else
Expand Down
2 changes: 1 addition & 1 deletion src/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function fork!(master::Clock)
put!(master.ac[i].forth, Startup(Ref(master))) # send pointer and id
end
else
println(stderr, "clock already has $(length(clk.ac)) active clocks!")
println(stderr, "clock already has $(length(master.ac)) active clocks!")
end
else
println(stderr, "no parallel threads available!")
Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mutable struct Prc
arg::Tuple
kw::Base.Iterators.Pairs

Prc( id, f::Function, arg...; kw...) = new(id, nothing, nothing, f, arg, kw)
Prc(id, f::Function, arg...; kw...) = new(id, nothing, nothing, f, arg, kw)
Prc(f::Function, arg...; kw...) = new(1, nothing, nothing, f, arg, kw)
end

Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ end

@safetestset "examples" begin include("test_examples.jl") end

# if VERSION ≥ v"1.8"
# @safetestset "Aqua" begin include("test_aqua.jl") end
# end
# if get(ENV,"JET_TEST","") == "true"
# @safetestset "JET" begin include("test_jet.jl") end
# end

println(".... finished testing DiscreteEvents.jl ....")
7 changes: 7 additions & 0 deletions test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using DiscreteEvents
using Aqua

Aqua.test_all(DiscreteEvents;
ambiguities = false
)
Aqua.test_ambiguities(DiscreteEvents)
27 changes: 27 additions & 0 deletions test/test_jet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using DiscreteEvents
using JET
using Test

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

@testset "JET checks" begin
rep = report_package("DiscreteEvents";
report_pass=MayThrowIsOk(),
)
@show rep
@test_broken length(JET.get_reports(rep)) == 0
end