Giter VIP home page Giter VIP logo

Comments (7)

vberlier avatar vberlier commented on August 22, 2024 1

I think I'm going to make things a bit more flexible by letting the user specify a regular expression:

$ gcc -E *.c | narmock -g --keep-args 'myproject_.*'

from narmock.

vberlier avatar vberlier commented on August 22, 2024

There are several reasons. The first one is that in system header files, argument names are not particularly pretty or usable. For example, this is what the declaration of mount in sys/mount.h looks like on my computer:

extern int mount (const char *__special_file, const char *__dir,
		  const char *__fstype, unsigned long int __rwflag,
		  const void *__data) __THROW;

Not overriding the arguments would make you write code like this:

MOCK(mount)->last_call->__special_file

Secondly, as far as I know, argument names are not guaranteed to be the same everywhere and can be vendor-specific. Even online references don't agree on a particular signature. Relying on vendor-specific argument names would make mock generation platform-dependent.

And of course, even if argument names were actually usable and standardized, it's perfectly valid C for them to be omitted in function declarations:

int add(int, int);

from narmock.

eerimoq avatar eerimoq commented on August 22, 2024

I think many project would benefit from function declaration names, especially bigger projects where mostly project-internal functions are mocked.

Unrelated, I suggest documenting which platform-functions (open/close/pipe/...) Narwhal uses as mocking these could result it unwanted/unexpected behaviour.

from narmock.

vberlier avatar vberlier commented on August 22, 2024

I guess this could be configurable with a command-line argument:

$ gcc -E *.c | narmock -g --keep-args

The process created for each test pretty much only uses write() to communicate data about the assertion and the result of the test through a pipe. I'm thinking about generating a function to reset all the mocks that would be called before reporting anything to the parent process.

from narmock.

eerimoq avatar eerimoq commented on August 22, 2024

Sounds good!

from narmock.

vberlier avatar vberlier commented on August 22, 2024

Just closed #6. Narwhal now calls narmock_reset_all_mocks right before and after running user code. This should make it extremely unlikely for mocks to interfere with the framework.

from narmock.

vberlier avatar vberlier commented on August 22, 2024

Just added a new -k flag that does exactly that in version 0.2.10.

from narmock.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.