crystal
crystal copied to clipboard
Interpreter: fails std test spec/std/thread_spec.cr:26
Bug Report
Run spec/std/thread_spec.cr with interpreter, it produces one failed test:
$ cr i spec/std/thread_spec.cr
Using compiled compiler at .build/crystal
..F.
Failures:
1) Thread returns current thread object
Expected: value.same? #<Thread:0x7efe27cbd230 @gc_thread_handler=Pointer(Void).null, @th=139630052709952, @exception=nil, @main_fiber=#<Fiber:0x7efe27cd3d10: main>, @next=nil, @previous=nil, @event_base=nil, @detached=Atomic(UInt8)(@value=1), @func=#<Proc(Nil):0x7efe29583740:closure>, @scheduler=nil> (object_id: 139630054462000)
got: #<Thread:0x7efe27cbd230 @gc_thread_handler=Pointer(Void).null, @th=139630052709952, @exception=nil, @main_fiber=#<Fiber:0x7efe27cd3d10: main>, @next=nil, @previous=nil, @event_base=nil, @detached=Atomic(UInt8)(@value=1), @func=#<Proc(Nil):0x7efe29583740:closure>, @scheduler=nil> (object_id: 139630054462000)
# ?:0
Finished in 137.73 milliseconds
4 examples, 1 failures, 0 errors, 0 pending
Failed examples:
crystal spec spec/std/thread_spec.cr:26 # Thread returns current thread object
It fails at line 31 current.should_not be(Thread.current)
Right... I think the interpreter runs in one thread, so anything executed in it will be in that thread.
For this to work the interpreter needs to be aware of threads. Given that multithreading is still in preview, I don't think I'm going to be working on this any time soon. For now we could disable those specs for interpreted mode, at least to eventually make the entire test suite pass.
The interpreter could run majority of std lib tests successfully. A lot of the failing tests fork new processes. Fixing #12241 could really help the test coverage.