3 ms·
> fusefs tests. Absolutely impossible to do in C. I considered Rust, but went with C++ so they could live in base. They are too closely coupled to fusefs(5)
by faitswulff 3y ago
> fusefs tests. Absolutely impossible to do in C. I considered Rust, but went with C++ so they could live in base. They are too closely coupled to fusefs(5) to live out-of-tree.
Can anyone comment on why this is impossible in C?
- loeg 3y ago"Impossible" is mild hyperbole. Googletest makes it relatively easy to structure complicated mocked tests in a way that is verbose but not impossible in C.
- bluGill 3y agoNot impossible, but a big pain. vtables can be done by hand, but C++ does that for you. I don't know rust or the problem they are talking about, but I believe something like that.
- steveklabnik 3y agoThe OP has since elaborated: > I don't think anybody has claimed this yet. But I _have_ made a similar claim, that some things can't be written in C. I'll elaborate on the project that started this thread: the fusefs test suite. When I designed the fusefs test suite, I based it around the priniciple of Mocking. Each test case has a client thread that does normal file system access, and a server thread that implements a fuse file server. But it isn't a full implementation of a fuse file server; it's just a shim around a mock object. For each test case, the file server's behavior is programmed with expectations. The mocking technique is so limited and awkward to use in C that almost nobody bothers. Just compare the documentation for CMockery (C) with Mockall (Rust). C++'s Googlemock is somewhere in between. https://lists.freebsd.org/archives/freebsd-hackers/2024-January/002852.html https://lists.freebsd.org/archives/freebsd-hackers/2024-Janu...
- Ferret7446 3y agoMocking is a horrible principle. It is probably the worst of the various types of test doubles, in terms of the kind of test design they imply. Software engineering would be significantly better off, IMO, if mocking were so awkward that no one bothers to do it, ever, in any language.
- steveklabnik 3y agoI don't fully agree but what I will say is that I perceive mocking to be not that easy or good in Rust, so it is surprising to me to see it cited positively.