Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix START_TEST to look like valid C code. #158

Merged
merged 2 commits into from
Jun 20, 2018

Commits on Jun 15, 2018

  1. Fix START_TEST to look like valid C code.

    Instead of exporting the defined name as a bare function, export a
    struct that has a pointer to the function, but also its name, file and
    line number where it is defined.
    
    Store that information into a new `struct TTest`.
    
    After this commit, START_TEST(<testname>) will create three definitions:
    - <testname>_fn: The actual function;
    - <testname>_ttest: A `struct TTest` with the information about it;
    - <testname>: A pointer to <testname>_ttest.
    
    Functions `tcase_add_test()` and friends are updated to take a `TTest *`
    argument rather than a `TFun` and separate name. The runners are updated
    to find that information inside the linked `tc->ttest`. The call to
    `tcase_fn_start()` is moved from the defined functions to the runners
    (both the "fork" and the "nofork" one) which call it just before
    invoking the test function.
    
    A nice side-effect is that END_TEST is now optional, though the empty
    `#define` is kept for backwards compability.
    
    v2: Initialize the struct TTest by position to be compatible with older
    compilers that do not recognize named fields (e.g. VS 2010, VS 2012.)
    
    Tested:
    - `make check` still passes.
    - Removing END_TEST from test cases still produces valid code that
      builds and passes tests.
    filbranden committed Jun 15, 2018
    Configuration menu
    Copy the full SHA
    3987c1d View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2018

  1. Configuration menu
    Copy the full SHA
    2010bab View commit details
    Browse the repository at this point in the history