Comments (7)
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.
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.
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.
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.
Sounds good!
from narmock.
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.
Just added a new -k
flag that does exactly that in version 0.2.10.
from narmock.
Related Issues (10)
- Mocking a function taking void as its only argument does not work HOT 1
- pycparser 2.21 breaks generation HOT 2
- mocking open fails HOT 1
- variadic an idea HOT 5
- Function declaration parsing fails HOT 2
- Suggestion: call_count as int HOT 1
- Reset all the mocks HOT 1
- mock_return_once() HOT 4
- Compiler error messages with and without function pointers in MOCK() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from narmock.