crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Interpreter: fails std test spec/std/thread_spec.cr:26

Open cyangle opened this issue 2 years ago • 2 comments

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)

cyangle avatar Jul 11 '22 03:07 cyangle

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.

asterite avatar Jul 11 '22 11:07 asterite

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.

cyangle avatar Jul 11 '22 13:07 cyangle