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

Sometimes tests from only one compilation unit are registered #50

Merged
merged 1 commit into from
Sep 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/criterion/criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
SECTION_("cr_tst") \
struct criterion_test IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
IDENTIFIER_(Category, Name, impl), \
&IDENTIFIER_(Category, Name, extra) \
} SECTION_SUFFIX_; \
}; \
SECTION_("cr_tst") \
struct criterion_test *IDENTIFIER_(Category, Name, ptr) \
= &IDENTIFIER_(Category, Name, meta) SECTION_SUFFIX_; \
TEST_PROTOTYPE_(Category, Name)

# define TestSuite(...) CR_EXPAND(TestSuite_(__VA_ARGS__, .sentinel_ = 0))
Expand All @@ -70,11 +72,13 @@
.line_ = 0, \
__VA_ARGS__ \
)); \
SECTION_("cr_sts") \
struct criterion_suite SUITE_IDENTIFIER_(Name, meta) = { \
#Name, \
&SUITE_IDENTIFIER_(Name, extra), \
} SECTION_SUFFIX_
}; \
SECTION_("cr_sts") \
struct criterion_suite *SUITE_IDENTIFIER_(Name, ptr) \
= &SUITE_IDENTIFIER_(Name, meta) SECTION_SUFFIX_

CR_BEGIN_C_API

Expand Down
26 changes: 13 additions & 13 deletions src/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
#endif

#ifdef _MSC_VER
struct criterion_test SECTION_START_(cr_tst);
struct criterion_suite SECTION_START_(cr_sts);
struct criterion_test SECTION_END_(cr_tst);
struct criterion_suite SECTION_END_(cr_sts);
struct criterion_test *SECTION_START_(cr_tst);
struct criterion_suite *SECTION_START_(cr_sts);
struct criterion_test *SECTION_END_(cr_tst);
struct criterion_suite *SECTION_END_(cr_sts);
#endif

IMPL_SECTION_LIMITS(struct criterion_test, cr_tst);
IMPL_SECTION_LIMITS(struct criterion_suite, cr_sts);
IMPL_SECTION_LIMITS(struct criterion_test*, cr_tst);
IMPL_SECTION_LIMITS(struct criterion_suite*, cr_sts);

// This is here to make the test suite & test sections non-empty
TestSuite();
Expand Down Expand Up @@ -98,11 +98,11 @@ struct criterion_test_set *criterion_init(void) {
struct criterion_ordered_set *suites = new_ordered_set(cmp_suite, dtor_suite_set);

FOREACH_SUITE_SEC(s) {
if (!s->name)
break;
if (!*s)
continue;

struct criterion_suite_set css = {
.suite = *s,
.suite = **s,
};
insert_ordered_set(suites, &css, sizeof (css));
}
Expand All @@ -118,13 +118,13 @@ struct criterion_test_set *criterion_init(void) {
};

FOREACH_TEST_SEC(test) {
if (!test->category)
break;
if (!*test)
continue;

if (!*test->category)
if (!(*test)->category)
continue;

criterion_register_test(set, test);
criterion_register_test(set, *test);
}

return set;
Expand Down
12 changes: 6 additions & 6 deletions src/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
# include "criterion/types.h"
# include "posix-compat.h"

DECL_SECTION_LIMITS(struct criterion_test, cr_tst);
DECL_SECTION_LIMITS(struct criterion_suite, cr_sts);
DECL_SECTION_LIMITS(struct criterion_test*, cr_tst);
DECL_SECTION_LIMITS(struct criterion_suite*, cr_sts);

struct criterion_test_set *criterion_init(void);

# define FOREACH_TEST_SEC(Test) \
for (struct criterion_test *Test = GET_SECTION_START(cr_tst); \
Test < (struct criterion_test*) GET_SECTION_END(cr_tst); \
for (struct criterion_test **Test = GET_SECTION_START(cr_tst); \
Test < (struct criterion_test**) GET_SECTION_END(cr_tst); \
++Test)

# define FOREACH_SUITE_SEC(Suite) \
for (struct criterion_suite *Suite = GET_SECTION_START(cr_sts); \
Suite < (struct criterion_suite*) GET_SECTION_END(cr_sts); \
for (struct criterion_suite **Suite = GET_SECTION_START(cr_sts); \
Suite < (struct criterion_suite**) GET_SECTION_END(cr_sts); \
++Suite)

#endif /* !CRITERION_RUNNER_H_ */