Open watzon opened 1 year ago
Traced the issue to stubbable.cr, line 129-164. Seems like there are some cases that it's not handling well.
The original issue has been resolved, however there's another issue that prevents mocking File
. The compiler does not allow casting a union of a pointer and nil to non-nil. For instance:
a = true ? Pointer(UInt8).null : nil
b = a.as(Pointer(UInt8))
p! a, typeof(a), b, typeof(b)
I'm not sure if this is intended or a bug in the compiler. This code works for other non-pointer types.
https://gitlab.com/arctic-fox/spectator/-/jobs/3648109240#L35
Ahh that's what that question was in reference to
It doesn't appear that the issue with pointers in unions will be fixed soon. A workaround in Spectator would be substantial. There's a possible fix that may even reduce compilation time, but it could take a while to implement.
Was this issue finally resolved?
I don't think it has been resolved. This issue is the root cause. Reworking Spectator to use a different storage method, that doesn't use unions of pointers, would fix the issue. Mocks have been extracted to their own shard. This issue shouldn't be present in that shard. Eventually Spectator will be updated to use the mocks shard. The mock injection feature should support mocking of File
.
Not sure if this is part of the intended purpose of mocks or not, but I'm attempting to mock the
File
class and I get the following error: