Skip to content

Error with generate_mocks when using typedef with multiple types #8

@FSatCorp

Description

@FSatCorp

Hi,

I think I found a small problem with the parse_typedef function in inspect.py.

Here's a MWE to reproduce the problem:

uut.h:

typedef int mytype1, mytype2;

int uutfun();
mytype1 fun(mytype2 x)

uut.c:

#include "uut.h"

mytype1 fun(mytype2 x)
{
    return x;
}

int uutfun()
{
    return fun(5);
}

test.c:

#include "nala.h"
#include "uut.h"


TEST(types)
{
    fun_mock_ignore_in(3);
    ASSERT_EQ(uutfun(), 3);
}

When running make, the following error appears:

...
    | nala generate_mocks   -o build
error: 'Struct' object has no attribute 'args'
make: *** [test.mk:109: build/nala_mocks.ldflags] Error 1

When modifying uut.h like the following lines, it works:
uut.h:

typedef int mytype1;
typedef int mytype2;

int uutfun();
mytype1 fun(mytype2 x)

Unfortunately, this is not a real option as one often wants to mock third-party code (a framework, lib, etc.) and of course you don't want to patch that only to make unit tests work.

Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions