Commit Graph

706 Commits

Author SHA1 Message Date
mvandervoord 4706da4453 another try 2020-03-19 10:17:30 -04:00
mvandervoord 44c8d4718a Further tweaks to testing 2020-03-19 10:09:22 -04:00
mvandervoord 9b393ad4fb Further style changes to match standard.
Pull in latest Unity.
Update testing parameters to include Ruby 2.7
2020-03-19 10:00:12 -04:00
mvandervoord 67858837d1 Update coding style to match our own official coding guidelines 2020-03-18 19:16:58 -04:00
Mark VanderVoord 9f8624a722 Merge pull request #283 from michaelbadcrumble/master
Cleaner implementation of Meson build support
2020-03-18 15:20:07 -04:00
mvandervoord 0f196a52cf Deal with more complex array length expressions. (thanks @jlindgren90 !) 2020-03-18 15:19:23 -04:00
mvandervoord 8885be7e55 Support alternative header file extension support (thanks @Tuc-an) 2020-03-18 15:08:21 -04:00
mvandervoord ae677d6481 Tweak to support test runner generator returning includes with extensions now. 2020-03-18 12:29:52 -04:00
mvandervoord 6aafb8184f Update to latest Unity 2020-03-18 11:55:43 -04:00
Mark VanderVoord bd0a8bfd38 Merge pull request #272 from jlindgren90/master
Some minor optimizations
2020-03-16 13:45:10 -04:00
Mark VanderVoord 300ebb86fd Merge branch 'master' into master 2020-03-16 13:44:41 -04:00
mvandervoord 3cfa437460 Make skeleton path configurable 2020-03-12 17:08:51 -04:00
mvandervoord f5abf20f4b Add ability to generate skeleton from header. woo! 2020-03-12 12:20:33 -04:00
Mark VanderVoord 2eb209b2a8 Merge pull request #286 from andred/for-merge
cmock_generator_plugin_callback: allow usage with Clang scan-build
2020-02-13 22:01:07 -05:00
André Draszik ccfe2690f4 cmock_generator_plugin_callback: allow usage with Clang scan-build
Running a project through Clang's scan-build produces countless
warnings like

build/test/mocks/mock_handleTroubleEvents.c:321:5: warning: Value stored to 'call_instance' is never read
    call_instance = CMOCK_GUTS_NONE;
    ^               ~~~~~~~~~~~~~~~

scan-build correctly determines that in the following snippet

    UNITY_CLR_DETAILS();
    if (Mock.checkForActiveTroubleAfterDebounce_CallbackFunctionPointer != NULL)
      call_instance = CMOCK_GUTS_NONE;
    call_instance = Mock.startStopTimer_CallInstance;

as generated by Ceedling / CMock, the first assignment to
call_instance is completely unused.

The sheer amount of warnings makes it very hard to impossible to
spot real problems in one's code, and creates huge code analysis
reports that just distract from actual problems in one's code.

Without being too invasive, we can instruct scan-build to ignore
this dead store using
    https://clang-analyzer.llvm.org/faq.html#dead_store

Signed-off-by: André Draszik <git@andred.net>
2020-02-14 02:56:21 +00:00
Mark VanderVoord 46db68699c Merge pull request #279 from laurensmiers/fix_bug_pull_request
Fix parsing of inline function declarations/macro's
2020-02-12 13:14:11 -05:00
Michael Brockus 4d0ea1afda Update meson.build 2020-01-27 23:18:39 -08:00
Michael Brockus a1b6da1773 Update meson.build 2020-01-27 23:17:18 -08:00
John Lindgren 3093a440dd expect: Optimize mock_verify() for the successful case.
Remove unconditional UNITY_SET_DETAIL/UNITY_CLEAR_DETAILS pair and
only call UNITY_SET_DETAIL if we are failing.
2020-01-27 15:24:06 -05:00
John Lindgren 574d532df7 callback: mock_verify() has no effect.
callback has a later priority than expect, so setting call_instance
to CMOCK_GUTS_NONE at this point has no effect.  This mock_verify()
has probably been obsolete for a long time.
2020-01-27 15:24:06 -05:00
laurensmiers 87cae74434 Re-use global function declaration regex in inline-function parsing 2020-01-15 00:04:28 +01:00
laurensmiers fda0b13fe5 Remove debug prints 2020-01-14 22:23:31 +01:00
laurensmiers 1c67efc485 Update inline function parsing documentation 2020-01-14 22:18:17 +01:00
laurensmiers 9571c52d70 Replace search for first bracket/semicolon with regex matching first function declaration
The regex matches the function declaration at the start of the
string (post-match).
2020-01-14 22:18:17 +01:00
laurens faceb864b8 Fix deleting of next line in user supplied inline function pattern
If we have a 'empty' macro, f.e.:
\#if <something>
\#define MY_LIBRARY_INLINE
\#endif
and using the user pattern 'MY_LIBRARY_INLINE', we would get the
following effect:
match = 'MY_LIBRARY_INLINE\n' <--- NOTE THAT THE NEWLINE IS PART OF THE MATCH
post-match = '#endif\n' <--- NO BEGINNING NEWLINE SINCE IT IS PART OF
THE MATCH ABOVE

And lead to the new header:
\#if <something>
Which gives a compilation error since the preprocessor-if is not
terminated properly.

The root cause is that we add a any-whitespace-character regex to the
user regex.
This any-whitespace-character regex was added only to cleanup the
 whitespaces after a user regex.

So the next line will be deleted if we check for any whitespace
character (THIS INCLUDES A NEWLINE!) after the user regex.
But this had the side effect that when matching a user regex, the newline was
also seen as part of the match. Which in the case of an empty macro
 would mean that in the cleanup of the post-match, we would delete the
 line immediately after the empty macro (\#endif in the example above).
So instead of matching with every whitespace character (which includes
newlines!), we explicitly only check for whitespaces.

Taking the example above, this has the desired effect:
match = 'MY_LIBRARY_INLINE' <--- NOTE THAT THE NEWLINE IS NO LONGER PART OF THE MATCH
post-match = '\n#endif\n' <--- BEGINNING NEWLINE NOW

Now the cleanup after a define will see the beginning newline in the
post-match and only remove that newline and now the preprocessor-if is
terminated properly
2020-01-14 22:18:17 +01:00
laurensmiers cf0e55b6e4 Fix system test compile error
if there is no semicolon in the file, first_semicolon is nil, so check
it before using it.
2020-01-14 22:18:17 +01:00
laurensmiers cfe1b4ef3d Handle user defined inline macro's
First squash all multiline macro's, it makes parsing easier. Otherwise
the regex to remove the macro would become more comples if we have to
deal with newlines etc.

When we have a match, we check if the last line in the pre_match is
the beginning of a macro declaration.
If it is, we remove the beginning of this macro
declaration (#define<space>) and remove the body of the macro from the
post_match, which is basically everything until the next newline.
There is a possible edge case (pretty unlikely but still):
if there is no newline in the post_match, meaning it is a macro at the
end of the line, we should delete it as well, hence the '[\n]?' in the
post match regex.
2020-01-14 22:18:17 +01:00
laurens 3254aef5e5 Handle headers which only have inline-function-declarations
This means there is NO opening bracket, since there are no struct
declarations or inline function definitions.
2020-01-14 22:18:17 +01:00
laurens 7a5d712d79 Expand inline function declaration test
Add a random struct in between to make sure we are not touching it
+
multiple newlines are allowed in the function declaration before the
semicolon, add a test to make sure we handle this.
2020-01-14 22:18:17 +01:00
laurens 550e141c59 Handle inline function declarations when mocking inline functions
When a inline function was declared in a file, we would find the
declaration and remove the function body. However, since it is a
declaration, there is NO function body, so we were deleting a random
piece of code that was between square brackets in the file.

To properly handle this, we have to detect if we are dealing with a
function declaration or a function definition.
If we are dealing with a function declaration, a semicolon
will come BEFORE the first square bracket.
If we are dealing with a function definition, a square bracket will
come BEFORE the first semicolon (the first semicolon will be in the
inline function body, so between the square brackets).
So we determine the location of the first semicolon and the first
square bracket after the function name and apply the logic described
above to handle function declarations.

If we are dealing with a function declaration, we don't do anything,
we just move to the next match.
This will result in redeclarations of the inline function, but this is
allowed in C and I'd rather not touch the file anymore than necessary.
2020-01-14 22:16:32 +01:00
laurens 972814622f Some more debug info 2020-01-14 22:15:14 +01:00
laurens c7f24da4f7 Some debug info during inline function parsing 2020-01-14 22:15:14 +01:00
laurens f291ed217c Trying to reproduce bug pull request 2020-01-14 22:15:14 +01:00
Mark VanderVoord bd5fbc30eb Merge pull request #271 from jvcdk/maintenance/update-submodules
Update submodule unity to current master.
2019-12-06 06:10:36 -05:00
Jørn Villesen Christensen 81345af180 Update submodule unity to current master. 2019-12-06 10:15:09 +01:00
mvandervoord 649005a917 Verify multiline functions are being parsed properly. 2019-12-05 09:15:47 -05:00
Mark VanderVoord 1e6634ca93 Merge pull request #270 from michaelbadcrumble/meson_support
Keep Meson support back to 0.50.0:
2019-12-04 06:03:07 -05:00
Michael Brockus ddf9030b9a Keep Meson support back to version 0.50.0 2019-12-03 22:49:15 -08:00
Michael Brockus 532ddd2c3d Update root meson.build 2019-12-03 22:45:39 -08:00
mvandervoord 7035578605 Grab the latest vendor tools 2019-12-03 18:48:28 -05:00
mvandervoord 91d5e578d8 Add support for function pointers using the shorthand notation 2019-11-18 09:09:42 -05:00
Mark VanderVoord 2afdebd228 Merge pull request #268 from jlindgren90/master
Allow arbitrary parentheses within length of array arguments.
2019-11-17 13:18:03 -05:00
John Lindgren 615b3874b8 Allow arbitrary parentheses within length of array arguments.
Previously, CMock would fail to parse a function like this one:

    void broken(uint8_t arg[((uint8_t)8)]);
2019-11-15 16:55:05 -05:00
Mark VanderVoord a6ec9f968a Merge pull request #267 from jlindgren90/master
Revert "Add quick pointer check before memory comparisons (#224)"
2019-11-15 13:11:19 -05:00
John Lindgren 03ddcb9bad Revert "Add quick pointer check before memory comparisons (#224)"
It didn't add direct comparisons only for pointer arguments, but
also other types of arguments like structs, which can't be compared
with '==' and cause a compiler error instead.

To reproduce, just enable the :array plugin in
system/test_interactions/expect_and_return_custom_types.yml:

In function ‘foo’:
error: invalid operands to binary != (have ‘EXAMPLE_STRUCT_T’ {aka
‘struct _EXAMPLE_STRUCT_T’} and ‘EXAMPLE_STRUCT_T’ {aka ‘struct
 _EXAMPLE_STRUCT_T’})
   59 |     if (cmock_call_instance->Expected_a != a) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~

This reverts commit 4df532afcc.
2019-11-15 12:46:28 -05:00
Mark VanderVoord 7dcb78c629 Merge pull request #265 from laurensmiers/master
User provided patterns for inline function mocking
2019-11-15 11:56:32 -05:00
laurens c0162e1ea6 Remove double unit test for inline_function_patterns 2019-11-15 16:25:23 +01:00
laurens 02cf882d36 Update documentation of :inline_function_patterns 2019-11-15 09:34:50 +01:00
laurens cb55b73522 Simplify inline function removal during source/function parsing
- If inlines are included, we don't do anything since they are
  disguised already as normal functions
- If inlines are NOT included, we remove anything that has inline in
  it
2019-11-14 13:38:10 +01:00
laurens 0f6e4604ff Remove inline specific keywords before starting function parsing 2019-11-14 13:37:57 +01:00