From 4a54e8d06938f7683d88b5bf0348e65ebda4a3bb Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 00:43:07 -0400 Subject: [PATCH 1/8] remove exporting register! (not used) --- src/DiscreteEvents.jl | 2 +- src/types.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DiscreteEvents.jl b/src/DiscreteEvents.jl index dcdd44c..7a1f07f 100644 --- a/src/DiscreteEvents.jl +++ b/src/DiscreteEvents.jl @@ -48,7 +48,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, diff --git a/src/types.jl b/src/types.jl index 2c52f44..ace6d0e 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 From 82266bfea618e47c0a786115797674d2ee4242b7 Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 01:31:11 -0400 Subject: [PATCH 2/8] add Aqua to the tests --- Project.toml | 3 ++- test/runtests.jl | 4 ++++ test/test_aqua.jl | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/test_aqua.jl diff --git a/Project.toml b/Project.toml index 3be0269..2aff28b 100644 --- a/Project.toml +++ b/Project.toml @@ -17,6 +17,7 @@ Unitful = "1" julia = "1" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" @@ -24,4 +25,4 @@ 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"] diff --git a/test/runtests.jl b/test/runtests.jl index cb35eeb..c282896 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,4 +28,8 @@ end @safetestset "examples" begin include("test_examples.jl") end +if VERSION ≥ v"1.8" + @safetestset "Aqua" begin include("test_aqua.jl") end +end + println(".... finished testing DiscreteEvents.jl ....") diff --git a/test/test_aqua.jl b/test/test_aqua.jl new file mode 100644 index 0000000..93fb513 --- /dev/null +++ b/test/test_aqua.jl @@ -0,0 +1,6 @@ +using DiscreteEvents +using Aqua + +Aqua.test_all(DiscreteEvents; + ambiguities = false +) \ No newline at end of file From 2d08d93ef2b2cfda1b38c37f4afed0677996950d Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 14:46:57 -0400 Subject: [PATCH 3/8] Distributions is only used to access type Distribution --- src/DiscreteEvents.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DiscreteEvents.jl b/src/DiscreteEvents.jl index 7a1f07f..b353347 100644 --- a/src/DiscreteEvents.jl +++ b/src/DiscreteEvents.jl @@ -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") From 740743b167101fe0487fde4e7e3781688012b8b5 Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 14:47:23 -0400 Subject: [PATCH 4/8] aqua should test for ambiguities of parent pkg (not submodules) --- test/test_aqua.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 93fb513..a04569d 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -3,4 +3,5 @@ using Aqua Aqua.test_all(DiscreteEvents; ambiguities = false -) \ No newline at end of file +) +Aqua.test_ambiguities(DiscreteEvents) \ No newline at end of file From aecc07d03728b9989e900ecf16b13160dd1e6577 Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 14:47:41 -0400 Subject: [PATCH 5/8] add JET testing --- Project.toml | 1 + test/runtests.jl | 3 +++ test/test_jet.jl | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 test/test_jet.jl diff --git a/Project.toml b/Project.toml index 2aff28b..a0c5c9a 100644 --- a/Project.toml +++ b/Project.toml @@ -19,6 +19,7 @@ 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" diff --git a/test/runtests.jl b/test/runtests.jl index c282896..aacc0a8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -31,5 +31,8 @@ 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 ....") diff --git a/test/test_jet.jl b/test/test_jet.jl new file mode 100644 index 0000000..6910fc6 --- /dev/null +++ b/test/test_jet.jl @@ -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 \ No newline at end of file From 8ad0fed2f838d41923aadbc077c4e78aabab8cdb Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 14:49:08 -0400 Subject: [PATCH 6/8] fix 6th set in #56 --- src/clock.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clock.jl b/src/clock.jl index 7ca3e7f..2e7753e 100644 --- a/src/clock.jl +++ b/src/clock.jl @@ -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 From c15056967b8aa232d8a821fa5cd0577ef6efa224 Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 14:50:44 -0400 Subject: [PATCH 7/8] fix 12th set in #56 --- src/threads.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/threads.jl b/src/threads.jl index 05dd7a5..8426651 100644 --- a/src/threads.jl +++ b/src/threads.jl @@ -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!") From ed18ff68130258599711a82c544e5fe999b0a95a Mon Sep 17 00:00:00 2001 From: hdavid16 Date: Fri, 2 Jun 2023 15:14:06 -0400 Subject: [PATCH 8/8] disable aqua and jet tests for now --- test/runtests.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index aacc0a8..48358ac 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,11 +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 +# 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 ....")