-
Notifications
You must be signed in to change notification settings - Fork 4
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
Broken in 1.6+ #13
Comments
Yeah, Cassette tends to not play well with nightly. I don't think any of the errors are on my end so I'm mostly likely just going to sit tight and wait for things to be fixed in Julia and Cassette. |
I can at least report the the tests of Cassette.jl Multiple mocks: Error During Test at /~/.julia/packages/SimpleMock/zgRuh/test/mock_fun.jl:33
Got exception outside of a @test
MethodError: no method matching Int64(::Mock{SimpleMock.var"#15#17"{SimpleMock.var"#15#16#18"}})
Closest candidates are:
(::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
(::Type{T})(::BigInt) where T<:Union{Int128, Int16, Int32, Int64, Int8} at gmp.jl:356
(::Type{T})(::Base.TwicePrecision) where T<:Number at twiceprecision.jl:243
...
Stacktrace:
[1] call
@ ~/.julia/packages/Cassette/Wjztv/src/context.jl:456 [inlined]
[2] fallback
@ ~/.julia/packages/Cassette/Wjztv/src/context.jl:454 [inlined]
[3] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Type{Int64}, ::Mock{SimpleMock.var"#15#17"{SimpleMock.var"#15#16#18"}})
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:545
[4] overdub
@ ./abstractarray.jl:1113 [inlined]
[5] overdub
@ ./array.jl:265 [inlined]
[6] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(unsafe_copyto!), ::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}, ::Int64, ::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}, ::Int64, ::Int64)
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[7] overdub
@ ./array.jl:811 [inlined]
[8] overdub
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:56 [inlined]
[9] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Test.scrub_backtrace), ::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[10] overdub
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:62 [inlined]
[11] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Test.scrub_exc_stack), ::Vector{Any})
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[12] overdub
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:165 [inlined]
[13] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Type{Test.Error}, ::Symbol, ::Expr, ::MethodError, ::Vector{Any}, ::LineNumberNode)
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[14] overdub
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:553 [inlined]
[15] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Test.do_test), ::Test.Threw, ::Expr)
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[16] overdub
@ ~/.julia/packages/SimpleMock/zgRuh/test/mock_fun.jl:37 [inlined]
[17] overdub(::Cassette.Context{nametype(##334), SimpleMock.Metadata{false}, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::var"#13#14", ::Mock{SimpleMock.var"#15#17"{SimpleMock.var"#15#16#18"}}, ::Mock{SimpleMock.var"#15#17"{SimpleMock.var"#15#16#18"}})
@ Cassette ~/.julia/packages/Cassette/Wjztv/src/overdub.jl:0
[18] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base ./essentials.jl:707
[19] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)
@ Base ./essentials.jl:706
[20] mock(::Function, ::Symbol, ::Function, ::Vararg{Function, N} where N; filters::Vector{Function})
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:140
[21] #mock#35
@ ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:113 [inlined]
[22] mock(::Function, ::Function, ::Function)
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:113
[23] macro expansion
@ ~/.julia/packages/SimpleMock/zgRuh/test/mock_fun.jl:34 [inlined]
[24] macro expansion
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
[25] top-level scope
@ ~/.julia/packages/SimpleMock/zgRuh/test/mock_fun.jl:34
[26] include(fname::String)
@ Base.MainInclude ./client.jl:444
[27] macro expansion
@ ~/.julia/packages/SimpleMock/zgRuh/test/runtests.jl:14 [inlined]
[28] macro expansion
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
[29] macro expansion
@ ~/.julia/packages/SimpleMock/zgRuh/test/runtests.jl:14 [inlined]
[30] macro expansion
@ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
[31] top-level scope
@ ~/.julia/packages/SimpleMock/zgRuh/test/runtests.jl:10
[32] include(fname::String)
@ Base.MainInclude ./client.jl:444
[33] top-level scope
@ none:6
[34] eval(m::Module, e::Any)
@ Core ./boot.jl:360
[35] exec_options(opts::JLOptions)
@ Base ./client.jl:261
[36] _start()
@ Base ./client.jl:485 |
We get a similar error in our tests in Trixi.jl at
|
Yeah, I noticed this on the beta. Was hoping an RC would fix it, but apparently not. As you've also inferred, I think this is on Cassette's end. |
Still seeing errors in 1.6 RC3, unfortunately. I haven't really had time to dig into debugging. |
Oh this is what's up! I was about to ask what I was missing since I couldn't even get the examples from the documentation to work: julia> using SimpleMock
julia> f(x) = x + 1
julia> mock(+) do plus
@assert plus isa Mock
@assert f(0) != 1 # The call to + is mocked.
@assert called_once_with(plus, 0, 1)
end
ERROR: type TypeofVararg has no field name
Stacktrace:
[1] getproperty(x::Core.TypeofVararg, f::Symbol)
@ Base ./Base.jl:33
[2] (::SimpleMock.var"#43#45"{Vector{Any}, Vector{Expr}})(T::Core.TypeofVararg)
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:187
[3] foreach
@ ./abstractarray.jl:2146 [inlined]
[4] make_overdub(#unused#::Type{Cassette.Context{SimpleMock.var"####279#Name", M, T, P, B, H} where {M, T<:Union{Nothing, Cassette.Tag}, P<:Cassette.AbstractPass, B<:Union{Nothing, IdDict{Module, Dict{Symbol, Cassette.BindingMeta}}}, H<:Union{Cassette.DisableHooks, Nothing}}}, f::typeof(+), sig::Tuple{Core.TypeofVararg})
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:183
[5] (::SimpleMock.var"#37#38"{UnionAll, Bool})(k::Tuple{typeof(+), Core.TypeofVararg})
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:131
[6] foreach(f::SimpleMock.var"#37#38"{UnionAll, Bool}, itr::Tuple{Tuple{typeof(+), Core.TypeofVararg}})
@ Base ./abstractarray.jl:2146
[7] mock(f::Function, ctx::Symbol, args::Function; filters::Vector{Function})
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:127
[8] #mock#35
@ ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:113 [inlined]
[9] mock(f::Function, args::Function)
@ SimpleMock ~/.julia/packages/SimpleMock/zgRuh/src/mock_fun.jl:113
[10] top-level scope
@ REPL[47]:1 I would love to use SimpleMock to write unit tests for TcpInstruments. @christopher-dG without knowing anything about how Cassette works, is there anything I can do to help debug this? |
Unfortunately an example that uses SimpleMock is not super useful to the Cassette devs, so we need to try to find an example with just Cassette. If you've got time to kill and want to go try learning about the internals of this package and Cassette to do so, feel free! But actually, a new direction involving @femtomc's Mixtape.jl instead of Cassette is looking quite promising so if that pans out it'll solve this issue. |
Re -- https://github.com/femtomc/Mixtape.jl. Yes, promising ... but there are drawbacks, including instability of internal APIs to I also discovered that if you do method overlay using |
What is the status of this issue? What is needed to have at least a partial solution to make CI work? I'm not familiarized with the code, but I can inspect to see if there is a possible workaround for this. Looking at CI logs, what I see is that the only test that fails is the one for "Multiple mock", and in particular the problem occurs in the call to invokelatest() for overdub. |
If I change a little bit the test that is failing as it follows then it does pass: @testset "Multiple mocks 2" begin
mock((*) => Mock((a, b) -> a + b), (/) => Mock((a, b) -> a + b)) do mul, div
@test 1 * 1 != 1
@test 1 / 1 != 1
@test called_once_with(mul, 1, 1)
@test called_once_with(div, 1, 1)
end
end When the Mocks implemented are just |
Looks like some methods in julia and Cassette have changed and it breaks the functionality here:
To reproduce:
The text was updated successfully, but these errors were encountered: