17 Commits

Author SHA1 Message Date
Igor Sadchenko
6fce1ccc4b Review fixes. Add parameter skip_warning_as_error to skip threat a warning as an error 2020-04-14 19:03:55 +02:00
Igor Sadchenko
4baadb049d Review fixes 2020-04-14 19:03:55 +02:00
Igor Sadchenko
275b36fb09 Added pragma once option. Issue #510 2020-04-14 19:03:55 +02:00
Emilio Cobos Álvarez
a519f1bda4 Actually use the temp dir for temporary compiled objects.
If the cbindgen_output is an absolute path, then join() will just return it.

Really fixes #499.
2020-04-04 23:46:42 +02:00
Emilio Cobos Álvarez
39bae60ad7 Generate test object files in a temporary directory instead of in-tree
Closes #499

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2020-04-04 17:54:52 +02:00
AlaskanEmily
dfa6e5f982 Check for CFLAGS and CXXFLAGS when running tests
This is needed when running tests with clang/clang++, as some of the tests have
errors that clang reports which gcc does not such as unused static const
variables.
2020-02-25 01:24:27 +01:00
Emilio Cobos Álvarez
12248c2fef tests: Add a simple testing-helpers headers that tests can include.
This allows to assert easily as described in the previous commit.
2020-01-26 02:35:39 +01:00
Emilio Cobos Álvarez
bd831ded19 tests: Provide style definition to the C / C++ tests.
This will be useful to add static assertion to some tests like #463 wants to do.

For example, in the case of the test for #463, the test would need something
like:

    trailer = """
    #include <assert.h>

    #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus)
    static_assert(sizeof(struct P) == 4, "unexpected size for P");
    #else
    static_assert(sizeof(P) == 4, "unexpected size for P");
    #endif
    """

As more of these tests are added it may be worth just adding a helper header
like this to avoid some duplication:

    #include <assert.h>
    #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus)
    #define CBINDGEN_STRUCT(name) struct name
    #else
    #define CBINDGEN_STRUCT(name) name
    #endif

And so on, so the previous configuration would become just:

    trailer = """
    #include "testing-helpers.h" // Or whatever
    static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P");
    """

That may or may not be overkill to do as part of #463.
2020-01-26 02:35:39 +01:00
John VanEnk
70188bb3b2 Enable most warnings, and make them errors.
This adds `-Wall` and `-Werror` to the C and C++ compiler flags. It
also adds `-Wno-attributes` to disable warnings about unrecognized
attributes. This is needed because the `swift_name` test relies on
`__attribute__((swift_name(some_name)))` attribute.
2020-01-24 11:22:39 +01:00
John VanEnk
fb348d91e8 Change std=c++11 to std=c++17 to support inline variables.
The inline variables feature is used by the associated_in_body test.
2020-01-24 11:22:39 +01:00
Wodann
af95d87c05 Improve verbosity of cpp_compat test cases 2019-06-01 10:59:43 +09:00
Wodann
bbeff3e3aa Add option to generate C headers with C++ compatibility
By default C++ compatibility is disabled.
2019-06-01 10:57:50 +09:00
Wodann
767fce25d1 Add support for selection of a custom C++ compiler 2019-06-01 10:56:09 +09:00
Wodann
7970564887 Add stderr output of cbindgen to a tests error log upon failure 2019-06-01 10:56:09 +09:00
Emilio Cobos Álvarez
357f34460d Do a better job at detecting the final binary location.
Still not great, I guess we should convert the tests to run the library version
of cbindgen, but this trivially-fixes #342.
2019-05-23 16:40:06 +02:00
Alexis Beingessner
ee2af57499 require c++11 to run the test suite
fixes #330
2019-05-10 17:58:52 -04:00
Emilio Cobos Álvarez
2bb3e9ba66 Use cargo test instead of test.py.
This makes cargo test test all the stuff in tests/rust, and thus makes tests.py
unnecessary.

Co-authored-by: Axel Nennker <axel.nennker@telekom.de>
2019-04-20 00:30:58 +02:00