Implemented basename for compatibility with OS X and Windows
This commit is contained in:
parent
0d85790a9d
commit
0520a36723
4 changed files with 14 additions and 4 deletions
|
@ -167,7 +167,7 @@ void normal_log_assert(struct criterion_assert_stats *stats) {
|
|||
bool sf = criterion_options.short_filename;
|
||||
criterion_pimportant(CRITERION_PREFIX_DASHES,
|
||||
_(msg_assert_fail),
|
||||
FG_BOLD, sf ? basename(stats->file) : stats->file, RESET,
|
||||
FG_BOLD, sf ? basename_compat(stats->file) : stats->file, RESET,
|
||||
FG_RED, stats->line, RESET,
|
||||
line);
|
||||
|
||||
|
@ -185,7 +185,7 @@ void normal_log_test_crash(struct criterion_test_stats *stats) {
|
|||
bool sf = criterion_options.short_filename;
|
||||
criterion_pimportant(CRITERION_PREFIX_DASHES,
|
||||
_(msg_test_crash_line),
|
||||
FG_BOLD, sf ? basename(stats->file) : stats->file, RESET,
|
||||
FG_BOLD, sf ? basename_compat(stats->file) : stats->file, RESET,
|
||||
FG_RED, stats->progress, RESET);
|
||||
criterion_pimportant(CRITERION_PREFIX_FAIL, _(msg_test_crash),
|
||||
stats->test->category,
|
||||
|
|
|
@ -91,7 +91,7 @@ void tap_log_post_test(struct criterion_test_stats *stats) {
|
|||
#endif
|
||||
bool sf = criterion_options.short_filename;
|
||||
criterion_important(" %s:%u: Assertion failed: %s\n",
|
||||
sf ? basename(asrt->file) : asrt->file,
|
||||
sf ? basename_compat(asrt->file) : asrt->file,
|
||||
asrt->line,
|
||||
line);
|
||||
#ifdef VANILLA_WIN32
|
||||
|
@ -110,7 +110,7 @@ void tap_log_test_crash(struct criterion_test_stats *stats) {
|
|||
criterion_important("not ok - %s::%s unexpected signal after %s:%u\n",
|
||||
stats->test->category,
|
||||
stats->test->name,
|
||||
sf ? basename(stats->file) : stats->file,
|
||||
sf ? basename_compat(stats->file) : stats->file,
|
||||
stats->progress);
|
||||
}
|
||||
|
||||
|
|
|
@ -387,3 +387,11 @@ void *get_osx_section_end(const char *section) {
|
|||
return get_real_address(section_start) + secsize;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *basename_compat(const char *str) {
|
||||
const char *start = str;
|
||||
for (const char *c = str; *c; ++c)
|
||||
if ((*c == '/' || *c == '\\') && c[1])
|
||||
start = c + 1;
|
||||
return start;
|
||||
}
|
||||
|
|
|
@ -95,4 +95,6 @@ void *get_osx_section_end(const char *section);
|
|||
# define GET_SECTION_END(Name) SECTION_END(Name)
|
||||
# endif
|
||||
|
||||
const char *basename_compat(const char *str);
|
||||
|
||||
#endif /* !POSIX_COMPAT_H_ */
|
||||
|
|
Loading…
Add table
Reference in a new issue