Skip to content

Commit 0de71bb

Browse files
committed
Improve formating of generated amast(-test).c files
1 parent 41df5e3 commit 0de71bb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ files_to_check = run_command(
138138
FIND,
139139
meson.project_source_root() / 'libs',
140140
meson.project_source_root() / 'apps',
141+
meson.project_source_root() / 'tools',
141142
'-name',
142143
'*.h',
143144
'-or',

tools/unity/unity.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void create_amast_c_file(
371371

372372
/* Copy content of all source files to amast.c */
373373
for (int i = 0; i < db->src.len; i++) {
374-
fprintf(src_file, "/* %s */\n", get_repo_fname(db->src.fnames[i]));
374+
fprintf(src_file, "\n/* %s */\n\n", get_repo_fname(db->src.fnames[i]));
375375
assert(*ntests < (AM_COUNTOF(*tests) - 1));
376376
AM_ASSERT(strstr(db->src.fnames[i], "test") == NULL);
377377
file_append(
@@ -402,7 +402,9 @@ static void create_amast_test_c_file(
402402

403403
/* Copy content of all source files to amast.c */
404404
for (int i = 0; i < db->src_test.len; i++) {
405-
fprintf(src_file, "/* %s */\n", get_repo_fname(db->src_test.fnames[i]));
405+
fprintf(
406+
src_file, "\n/* %s */\n\n", get_repo_fname(db->src_test.fnames[i])
407+
);
406408
assert(*ntests < (AM_COUNTOF(*tests) - 1));
407409
AM_ASSERT(strstr(db->src_test.fnames[i], "test") != NULL);
408410
file_append(
@@ -415,10 +417,13 @@ static void create_amast_test_c_file(
415417
}
416418

417419
/* Add the final main function to amast_test.c */
418-
fprintf(src_file, "int main(void) {\n");
420+
fprintf(src_file, "\nint main(void) {\n");
419421
for (int i = 0; i < *ntests; i++) {
420422
fprintf(src_file, " %s();\n", tests[i]);
421423
}
424+
fprintf(src_file, "\n");
425+
fprintf(src_file, " printf(\"Amast unit tests passed!\\n\");\n");
426+
fprintf(src_file, "\n");
422427
fprintf(src_file, " return 0;\n");
423428
fprintf(src_file, "}\n");
424429
fprintf(src_file, "\n");

0 commit comments

Comments
 (0)