Commit cad7a1bad40c302fef02306708f6ce6279680cb4

Edward Thomson 2020-06-05T08:42:38

clar: include the function name

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 65e13a6..4950201 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -108,7 +108,7 @@ done:
 		git_buf details = GIT_BUF_INIT;
 		git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}",
 			git_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs);
-		clar__fail(__FILE__, __LINE__,
+		clar__fail(__FILE__, __func__, __LINE__,
 			"checked out contents did not match expected", details.ptr, 0);
 		git_buf_dispose(&details);
 	}
diff --git a/tests/clar.c b/tests/clar.c
index f4c7688..9b58126 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -96,6 +96,7 @@ fixture_path(const char *base, const char *fixture_name);
 
 struct clar_error {
 	const char *file;
+	const char *function;
 	size_t line_number;
 	const char *error_msg;
 	char *description;
@@ -603,6 +604,7 @@ void clar__skip(void)
 
 void clar__fail(
 	const char *file,
+	const char *function,
 	size_t line,
 	const char *error_msg,
 	const char *description,
@@ -619,6 +621,7 @@ void clar__fail(
 	_clar.last_report->last_error = error;
 
 	error->file = file;
+	error->function = function;
 	error->line_number = line;
 	error->error_msg = error_msg;
 
@@ -635,6 +638,7 @@ void clar__fail(
 void clar__assert(
 	int condition,
 	const char *file,
+	const char *function,
 	size_t line,
 	const char *error_msg,
 	const char *description,
@@ -643,11 +647,12 @@ void clar__assert(
 	if (condition)
 		return;
 
-	clar__fail(file, line, error_msg, description, should_abort);
+	clar__fail(file, function, line, error_msg, description, should_abort);
 }
 
 void clar__assert_equal(
 	const char *file,
+	const char *function,
 	size_t line,
 	const char *err,
 	int should_abort,
@@ -758,7 +763,7 @@ void clar__assert_equal(
 	va_end(args);
 
 	if (!is_equal)
-		clar__fail(file, line, err, buf, should_abort);
+		clar__fail(file, function, line, err, buf, should_abort);
 }
 
 void cl_set_cleanup(void (*cleanup)(void *), void *opaque)
diff --git a/tests/clar.h b/tests/clar.h
index 49bb4fb..8c22382 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -86,16 +86,16 @@ const char *cl_fixture_basename(const char *fixture_name);
 /**
  * Assertion macros with explicit error message
  */
-#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 1)
-#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 1)
-#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 1)
+#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 1)
+#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 1)
+#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 1)
 
 /**
  * Check macros with explicit error message
  */
-#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 0)
-#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 0)
-#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 0)
+#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 0)
+#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 0)
+#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 0)
 
 /**
  * Assertion macros with no error message
@@ -114,38 +114,39 @@ const char *cl_fixture_basename(const char *fixture_name);
 /**
  * Forced failure/warning
  */
-#define cl_fail(desc) clar__fail(__FILE__, __LINE__, "Test failed.", desc, 1)
-#define cl_warning(desc) clar__fail(__FILE__, __LINE__, "Warning during test execution:", desc, 0)
+#define cl_fail(desc) clar__fail(__FILE__, __func__, __LINE__, "Test failed.", desc, 1)
+#define cl_warning(desc) clar__fail(__FILE__, __func__, __LINE__, "Warning during test execution:", desc, 0)
 
 #define cl_skip() clar__skip()
 
 /**
  * Typed assertion macros
  */
-#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2))
-#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2))
+#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2))
+#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2))
 
-#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2))
-#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2))
+#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2))
+#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2))
 
-#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len))
-#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len))
+#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len))
+#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len))
 
-#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len))
-#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len))
+#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len))
+#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len))
 
-#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
-#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2))
-#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2))
+#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
+#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2))
+#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2))
 
-#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0))
+#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__func__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0))
 
-#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
+#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__func__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
 
 void clar__skip(void);
 
 void clar__fail(
 	const char *file,
+	const char *func,
 	size_t line,
 	const char *error,
 	const char *description,
@@ -154,6 +155,7 @@ void clar__fail(
 void clar__assert(
 	int condition,
 	const char *file,
+	const char *func,
 	size_t line,
 	const char *error,
 	const char *description,
@@ -161,6 +163,7 @@ void clar__assert(
 
 void clar__assert_equal(
 	const char *file,
+	const char *func,
 	size_t line,
 	const char *err,
 	int should_abort,
diff --git a/tests/clar/print.h b/tests/clar/print.h
index b020a9a..dbfd276 100644
--- a/tests/clar/print.h
+++ b/tests/clar/print.h
@@ -126,7 +126,7 @@ static void clar_print_tap_ontest(const char *test_name, int test_number, enum c
 		printf("    at:\n");
 		printf("      file: '"); print_escaped(error->file); printf("'\n");
 		printf("      line: %" PRIuZ "\n", error->line_number);
-		printf("      function: '%s::%s'\n", _clar.active_suite, test_name);
+		printf("      function: '%s'\n", error->function);
 		printf("    ---\n");
 
 		break;
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 4723a06..65b8923 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -4,7 +4,7 @@
 #include "git2/sys/repository.h"
 
 void cl_git_report_failure(
-	int error, int expected, const char *file, int line, const char *fncall)
+	int error, int expected, const char *file, const char *func, int line, const char *fncall)
 {
 	char msg[4096];
 	const git_error *last = git_error_last();
@@ -18,7 +18,7 @@ void cl_git_report_failure(
 	else
 		p_snprintf(msg, 4096, "no error, expected non-zero return");
 
-	clar__assert(0, file, line, fncall, msg, 1);
+	clar__assert(0, file, func, line, fncall, msg, 1);
 }
 
 void cl_git_mkfile(const char *filename, const char *content)
@@ -507,6 +507,7 @@ void clar__assert_equal_file(
 	int ignore_cr,
 	const char *path,
 	const char *file,
+	const char *func,
 	int line)
 {
 	char buf[4000];
@@ -519,7 +520,7 @@ void clar__assert_equal_file(
 
 	while ((bytes = p_read(fd, buf, sizeof(buf))) != 0) {
 		clar__assert(
-			bytes > 0, file, line, "error reading from file", path, 1);
+			bytes > 0, file, func, line, "error reading from file", path, 1);
 
 		if (ignore_cr)
 			bytes = strip_cr_from_buf(buf, bytes);
@@ -532,7 +533,7 @@ void clar__assert_equal_file(
 				buf, sizeof(buf), "file content mismatch at byte %"PRIdZ,
 				(ssize_t)(total_bytes + pos));
 			p_close(fd);
-			clar__fail(file, line, path, buf, 1);
+			clar__fail(file, func, line, path, buf, 1);
 		}
 
 		expected_data += bytes;
@@ -541,8 +542,8 @@ void clar__assert_equal_file(
 
 	p_close(fd);
 
-	clar__assert(!bytes, file, line, "error reading from file", path, 1);
-	clar__assert_equal(file, line, "mismatched file length", 1, "%"PRIuZ,
+	clar__assert(!bytes, file, func, line, "error reading from file", path, 1);
+	clar__assert_equal(file, func, line, "mismatched file length", 1, "%"PRIuZ,
 		(size_t)expected_bytes, (size_t)total_bytes);
 }
 
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index 12175c6..e3b7bd9 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -12,15 +12,15 @@
  *
  * Use this wrapper around all `git_` library calls that return error codes!
  */
-#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __LINE__)
+#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __func__, __LINE__)
 
-#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __LINE__)
+#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __func__, __LINE__)
 
-#define cl_git_expect(expr, expected, file, line) do { \
+#define cl_git_expect(expr, expected, file, func, line) do { \
 	int _lg2_error; \
 	git_error_clear(); \
 	if ((_lg2_error = (expr)) != expected) \
-		cl_git_report_failure(_lg2_error, expected, file, line, "Function call failed: " #expr); \
+		cl_git_report_failure(_lg2_error, expected, file, func, line, "Function call failed: " #expr); \
 	} while (0)
 
 /**
@@ -31,7 +31,7 @@
 #define cl_git_fail(expr) do { \
 	if ((expr) == 0) \
 		git_error_clear(), \
-		cl_git_report_failure(0, 0, __FILE__, __LINE__, "Function call succeeded: " #expr); \
+		cl_git_report_failure(0, 0, __FILE__, __func__, __LINE__, "Function call succeeded: " #expr); \
 	} while (0)
 
 /**
@@ -41,7 +41,7 @@
 	int _win32_res; \
 	if ((_win32_res = (expr)) == 0) { \
 		git_error_set(GIT_ERROR_OS, "Returned: %d, system error code: %lu", _win32_res, GetLastError()); \
-		cl_git_report_failure(_win32_res, 0, __FILE__, __LINE__, "System call failed: " #expr); \
+		cl_git_report_failure(_win32_res, 0, __FILE__, __func__, __LINE__, "System call failed: " #expr); \
 	} \
 	} while(0)
 
@@ -58,22 +58,24 @@
 typedef struct {
 	int error;
 	const char *file;
+	const char *func;
 	int line;
 	const char *expr;
 	char error_msg[4096];
 } cl_git_thread_err;
 
 #ifdef GIT_THREADS
-# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __LINE__)
+# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __func__, __LINE__)
 #else
 # define cl_git_thread_pass(threaderr, expr) cl_git_pass(expr)
 #endif
 
-#define cl_git_thread_pass_(__threaderr, __expr, __file, __line) do { \
+#define cl_git_thread_pass_(__threaderr, __expr, __file, __func, __line) do { \
 	git_error_clear(); \
 	if ((((cl_git_thread_err *)__threaderr)->error = (__expr)) != 0) { \
 		const git_error *_last = git_error_last(); \
 		((cl_git_thread_err *)__threaderr)->file = __file; \
+		((cl_git_thread_err *)__threaderr)->func = __func; \
 		((cl_git_thread_err *)__threaderr)->line = __line; \
 		((cl_git_thread_err *)__threaderr)->expr = "Function call failed: " #__expr; \
 		p_snprintf(((cl_git_thread_err *)__threaderr)->error_msg, 4096, "thread 0x%" PRIxZ " - error %d - %s", \
@@ -87,38 +89,39 @@ GIT_INLINE(void) cl_git_thread_check(void *data)
 {
 	cl_git_thread_err *threaderr = (cl_git_thread_err *)data;
 	if (threaderr->error != 0)
-		clar__assert(0, threaderr->file, threaderr->line, threaderr->expr, threaderr->error_msg, 1);
+		clar__assert(0, threaderr->file, threaderr->func, threaderr->line, threaderr->expr, threaderr->error_msg, 1);
 }
 
-void cl_git_report_failure(int, int, const char *, int, const char *);
+void cl_git_report_failure(int, int, const char *, const char *, int, const char *);
 
-#define cl_assert_at_line(expr,file,line) \
-	clar__assert((expr) != 0, file, line, "Expression is not true: " #expr, NULL, 1)
+#define cl_assert_at_line(expr,file,func,line) \
+	clar__assert((expr) != 0, file, func, line, "Expression is not true: " #expr, NULL, 1)
 
 GIT_INLINE(void) clar__assert_in_range(
 	int lo, int val, int hi,
-	const char *file, int line, const char *err, int should_abort)
+	const char *file, const char *func, int line,
+	const char *err, int should_abort)
 {
 	if (lo > val || hi < val) {
 		char buf[128];
 		p_snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi);
-		clar__fail(file, line, err, buf, should_abort);
+		clar__fail(file, func, line, err, buf, should_abort);
 	}
 }
 
 #define cl_assert_equal_sz(sz1,sz2) do { \
 	size_t __sz1 = (size_t)(sz1), __sz2 = (size_t)(sz2); \
-	clar__assert_equal(__FILE__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \
+	clar__assert_equal(__FILE__,__func__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \
 } while (0)
 
 #define cl_assert_in_range(L,V,H) \
-	clar__assert_in_range((L),(V),(H),__FILE__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1)
+	clar__assert_in_range((L),(V),(H),__FILE__,__func__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1)
 
 #define cl_assert_equal_file(DATA,SIZE,PATH) \
-	clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,(int)__LINE__)
+	clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,__func__,(int)__LINE__)
 
 #define cl_assert_equal_file_ignore_cr(DATA,SIZE,PATH) \
-	clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,(int)__LINE__)
+	clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,__func__,(int)__LINE__)
 
 void clar__assert_equal_file(
 	const char *expected_data,
@@ -126,10 +129,11 @@ void clar__assert_equal_file(
 	int ignore_cr,
 	const char *path,
 	const char *file,
+	const char *func,
 	int line);
 
 GIT_INLINE(void) clar__assert_equal_oid(
-	const char *file, int line, const char *desc,
+	const char *file, const char *func, int line, const char *desc,
 	const git_oid *one, const git_oid *two)
 {
 	if (git_oid_cmp(one, two)) {
@@ -138,12 +142,12 @@ GIT_INLINE(void) clar__assert_equal_oid(
 		git_oid_fmt(&err[1], one);
 		git_oid_fmt(&err[47], two);
 
-		clar__fail(file, line, desc, err, 1);
+		clar__fail(file, func, line, desc, err, 1);
 	}
 }
 
 #define cl_assert_equal_oid(one, two) \
-	clar__assert_equal_oid(__FILE__, __LINE__, \
+	clar__assert_equal_oid(__FILE__, __func__, __LINE__, \
 		"OID mismatch: " #one " != " #two, (one), (two))
 
 /*
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index ce11953..3f04c2a 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -150,10 +150,11 @@ static void cleanup_chmod_root(void *ref)
 	git_futils_rmdir_r("r", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
 }
 
-#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __LINE__)
+#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __func__, __LINE__)
 
 static void check_mode_at_line(
-	mode_t expected, mode_t actual, const char *file, int line)
+	mode_t expected, mode_t actual,
+	const char *file, const char *func, int line)
 {
 	/* FAT filesystems don't support exec bit, nor group/world bits */
 	if (!cl_is_chmod_supported()) {
@@ -162,7 +163,7 @@ static void check_mode_at_line(
 	}
 
 	clar__assert_equal(
-		file, line, "expected_mode != actual_mode", 1,
+		file, func, line, "expected_mode != actual_mode", 1,
 		"%07o", (int)expected, (int)(actual & 0777));
 }
 
diff --git a/tests/core/structinit.c b/tests/core/structinit.c
index f9da823..192096b 100644
--- a/tests/core/structinit.c
+++ b/tests/core/structinit.c
@@ -48,7 +48,7 @@ static void options_cmp(void *one, void *two, size_t size, const char *name)
 
 			p_snprintf(desc, 1024, "Difference in %s at byte %" PRIuZ ": macro=%u / func=%u",
 				name, i, ((char *)one)[i], ((char *)two)[i]);
-			clar__fail(__FILE__, __LINE__,
+			clar__fail(__FILE__, __func__, __LINE__,
 				"Difference between macro and function options initializer",
 				desc, 0);
 			return;
diff --git a/tests/core/wildmatch.c b/tests/core/wildmatch.c
index e7897c6..7c56ee7 100644
--- a/tests/core/wildmatch.c
+++ b/tests/core/wildmatch.c
@@ -3,21 +3,21 @@
 #include "wildmatch.h"
 
 #define assert_matches(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch) \
-	assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __LINE__)
+	assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __func__, __LINE__)
 
 static void assert_matches_(const char *string, const char *pattern,
 		char expected_wildmatch, char expected_iwildmatch,
 		char expected_pathmatch, char expected_ipathmatch,
-		const char *file, size_t line)
+		const char *file, const char *func, size_t line)
 {
 	if (wildmatch(pattern, string, WM_PATHNAME) == expected_wildmatch)
-		clar__fail(file, line, "Test failed (wildmatch).", string, 1);
+		clar__fail(file, func, line, "Test failed (wildmatch).", string, 1);
 	if (wildmatch(pattern, string, WM_PATHNAME|WM_CASEFOLD) == expected_iwildmatch)
-		clar__fail(file, line, "Test failed (iwildmatch).", string, 1);
+		clar__fail(file, func, line, "Test failed (iwildmatch).", string, 1);
 	if (wildmatch(pattern, string, 0) == expected_pathmatch)
-		clar__fail(file, line, "Test failed (pathmatch).", string, 1);
+		clar__fail(file, func, line, "Test failed (pathmatch).", string, 1);
 	if (wildmatch(pattern, string, WM_CASEFOLD) == expected_ipathmatch)
-		clar__fail(file, line, "Test failed (ipathmatch).", string, 1);
+		clar__fail(file, func, line, "Test failed (ipathmatch).", string, 1);
 }
 
 /*
diff --git a/tests/core/zstream.c b/tests/core/zstream.c
index bcbb45f..3cbcea1 100644
--- a/tests/core/zstream.c
+++ b/tests/core/zstream.c
@@ -9,7 +9,7 @@ static const char *data = "This is a test test test of This is a test";
 static void assert_zlib_equal_(
 	const void *expected, size_t e_len,
 	const void *compressed, size_t c_len,
-	const char *msg, const char *file, int line)
+	const char *msg, const char *file, const char *func, int line)
 {
 	z_stream stream;
 	char *expanded = git__calloc(1, e_len + INFLATE_EXTRA);
@@ -26,21 +26,21 @@ static void assert_zlib_equal_(
 	inflateEnd(&stream);
 
 	clar__assert_equal(
-		file, line, msg, 1,
+		file, func, line, msg, 1,
 		"%d", (int)stream.total_out, (int)e_len);
 	clar__assert_equal(
-		file, line, "Buffer len was not exact match", 1,
+		file, func, line, "Buffer len was not exact match", 1,
 		"%d", (int)stream.avail_out, (int)INFLATE_EXTRA);
 
 	clar__assert(
 		memcmp(expanded, expected, e_len) == 0,
-		file, line, "uncompressed data did not match", NULL, 1);
+		file, func, line, "uncompressed data did not match", NULL, 1);
 
 	git__free(expanded);
 }
 
 #define assert_zlib_equal(E,EL,C,CL) \
-	assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, (int)__LINE__)
+	assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, __func__, (int)__LINE__)
 
 void test_core_zstream__basic(void)
 {
diff --git a/tests/diff/parse.c b/tests/diff/parse.c
index b004d1e..8bb95c4 100644
--- a/tests/diff/parse.c
+++ b/tests/diff/parse.c
@@ -319,20 +319,20 @@ void test_diff_parse__patch_roundtrip_succeeds(void)
 	git_buf_dispose(&diffbuf);
 }
 
-#define cl_assert_equal_i_src(i1,i2,file,line) clar__assert_equal(file,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
+#define cl_assert_equal_i_src(i1,i2,file,func,line) clar__assert_equal(file,func,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
 
-static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, int lineno)
+static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, const char *func, int lineno)
 {
 	const git_diff_line *line;
 
-	cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, lineno);
-	cl_assert_equal_i_src(old_lineno, line->old_lineno, file, lineno);
-	cl_assert_equal_i_src(new_lineno, line->new_lineno, file, lineno);
-	cl_assert_equal_i_src(num_lines, line->num_lines, file, lineno);
+	cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, func, lineno);
+	cl_assert_equal_i_src(old_lineno, line->old_lineno, file, func, lineno);
+	cl_assert_equal_i_src(new_lineno, line->new_lineno, file, func, lineno);
+	cl_assert_equal_i_src(num_lines, line->num_lines, file, func, lineno);
 }
 
 #define cl_git_assert_lineinfo(old, new, num, p, h, l) \
-	cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__LINE__)
+	cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__func__,__LINE__)
 
 
 void test_diff_parse__issue4672(void)
diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c
index 8899d3f..93223ef 100644
--- a/tests/diff/submodules.c
+++ b/tests/diff/submodules.c
@@ -18,7 +18,8 @@ void test_diff_submodules__cleanup(void)
 #define get_buf_ptr(buf) ((buf)->asize ? (buf)->ptr : NULL)
 
 static void check_diff_patches_at_line(
-	git_diff *diff, const char **expected, const char *file, int line)
+	git_diff *diff, const char **expected,
+	const char *file, const char *func, int line)
 {
 	const git_diff_delta *delta;
 	git_patch *patch = NULL;
@@ -30,34 +31,34 @@ static void check_diff_patches_at_line(
 		cl_assert((delta = git_patch_get_delta(patch)) != NULL);
 
 		if (delta->status == GIT_DELTA_UNMODIFIED) {
-			cl_assert_at_line(expected[d] == NULL, file, line);
+			cl_assert_at_line(expected[d] == NULL, file, func, line);
 			continue;
 		}
 
 		if (expected[d] && !strcmp(expected[d], "<SKIP>"))
 			continue;
 		if (expected[d] && !strcmp(expected[d], "<UNTRACKED>")) {
-			cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, line);
+			cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, func, line);
 			continue;
 		}
 		if (expected[d] && !strcmp(expected[d], "<END>")) {
 			cl_git_pass(git_patch_to_buf(&buf, patch));
-			cl_assert_at_line(!strcmp(expected[d], "<END>"), file, line);
+			cl_assert_at_line(!strcmp(expected[d], "<END>"), file, func, line);
 		}
 
 		cl_git_pass(git_patch_to_buf(&buf, patch));
 
 		clar__assert_equal(
-			file, line, "expected diff did not match actual diff", 1,
+			file, func, line, "expected diff did not match actual diff", 1,
 			"%s", expected[d], get_buf_ptr(&buf));
 		git_buf_dispose(&buf);
 	}
 
-	cl_assert_at_line(expected[d] && !strcmp(expected[d], "<END>"), file, line);
+	cl_assert_at_line(expected[d] && !strcmp(expected[d], "<END>"), file, func, line);
 }
 
 #define check_diff_patches(diff, exp) \
-	check_diff_patches_at_line(diff, exp, __FILE__, __LINE__)
+	check_diff_patches_at_line(diff, exp, __FILE__, __func__, __LINE__)
 
 void test_diff_submodules__unmodified_submodule(void)
 {
diff --git a/tests/ignore/path.c b/tests/ignore/path.c
index e23ac77..5d53c9d 100644
--- a/tests/ignore/path.c
+++ b/tests/ignore/path.c
@@ -17,19 +17,20 @@ void test_ignore_path__cleanup(void)
 }
 
 static void assert_is_ignored_(
-	bool expected, const char *filepath, const char *file, int line)
+	bool expected, const char *filepath,
+	const char *file, const char *func, int line)
 {
 	int is_ignored = 0;
 
 	cl_git_expect(
-		git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, line);
+		git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, func, line);
 
 	clar__assert_equal(
-		file, line, "expected != is_ignored", 1, "%d",
+		file, func, line, "expected != is_ignored", 1, "%d",
 		(int)(expected != 0), (int)(is_ignored != 0));
 }
 #define assert_is_ignored(expected, filepath) \
-	assert_is_ignored_(expected, filepath, __FILE__, __LINE__)
+	assert_is_ignored_(expected, filepath, __FILE__, __func__, __LINE__)
 
 void test_ignore_path__honor_temporary_rules(void)
 {
diff --git a/tests/ignore/status.c b/tests/ignore/status.c
index 5e67c12..188fbe4 100644
--- a/tests/ignore/status.c
+++ b/tests/ignore/status.c
@@ -17,21 +17,22 @@ void test_ignore_status__cleanup(void)
 }
 
 static void assert_ignored_(
-	bool expected, const char *filepath, const char *file, int line)
+	bool expected, const char *filepath,
+	const char *file, const char *func, int line)
 {
 	int is_ignored = 0;
 	cl_git_expect(
-		git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, line);
+		git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, func, line);
 	clar__assert(
 		(expected != 0) == (is_ignored != 0),
-		file, line, "expected != is_ignored", filepath, 1);
+		file, func, line, "expected != is_ignored", filepath, 1);
 }
 #define assert_ignored(expected, filepath) \
-	assert_ignored_(expected, filepath, __FILE__, __LINE__)
+	assert_ignored_(expected, filepath, __FILE__, __func__, __LINE__)
 #define assert_is_ignored(filepath) \
-	assert_ignored_(true, filepath, __FILE__, __LINE__)
+	assert_ignored_(true, filepath, __FILE__, __func__, __LINE__)
 #define refute_is_ignored(filepath) \
-	assert_ignored_(false, filepath, __FILE__, __LINE__)
+	assert_ignored_(false, filepath, __FILE__, __func__, __LINE__)
 
 void test_ignore_status__0(void)
 {
diff --git a/tests/index/addall.c b/tests/index/addall.c
index c62c3cf..d1ef31d 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -75,7 +75,7 @@ static void check_status_at_line(
 	git_repository *repo,
 	size_t index_adds, size_t index_dels, size_t index_mods,
 	size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores,
-	size_t conflicts, const char *file, int line)
+	size_t conflicts, const char *file, const char *func, int line)
 {
 	index_status_counts vals;
 
@@ -84,25 +84,25 @@ static void check_status_at_line(
 	cl_git_pass(git_status_foreach(repo, index_status_cb, &vals));
 
 	clar__assert_equal(
-		file,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds);
+		file,func,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds);
 	clar__assert_equal(
-		file,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels);
+		file,func,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels);
 	clar__assert_equal(
-		file,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods);
+		file,func,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods);
 	clar__assert_equal(
-		file,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds);
+		file,func,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds);
 	clar__assert_equal(
-		file,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels);
+		file,func,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels);
 	clar__assert_equal(
-		file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
+		file,func,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
 	clar__assert_equal(
-		file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
+		file,func,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
 	clar__assert_equal(
-		file,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts);
+		file,func,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts);
 }
 
 #define check_status(R,IA,ID,IM,WA,WD,WM,IG,C) \
-	check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__LINE__)
+	check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__func__,__LINE__)
 
 static void check_stat_data(git_index *index, const char *path, bool match)
 {
diff --git a/tests/index/crlf.c b/tests/index/crlf.c
index 7aa6be4..26c19d7 100644
--- a/tests/index/crlf.c
+++ b/tests/index/crlf.c
@@ -96,7 +96,7 @@ done:
 		git_buf details = GIT_BUF_INIT;
 		git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, safecrlf=%s, attrs={%s}",
 			basename, cd->systype, cd->autocrlf, cd->safecrlf, cd->attrs);
-		clar__fail(__FILE__, __LINE__,
+		clar__fail(__FILE__, __func__, __LINE__,
 			"index contents did not match expected", details.ptr, 0);
 		git_buf_dispose(&details);
 	}
diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c
index af1f803..3d2bb4a 100644
--- a/tests/index/filemodes.c
+++ b/tests/index/filemodes.c
@@ -51,11 +51,11 @@ static void replace_file_with_mode(
 	git_buf_dispose(&content);
 }
 
-#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__LINE__)
+#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__func__,__LINE__)
 
 static void add_and_check_mode_(
 	git_index *index, const char *filename, unsigned int expect_mode,
-	const char *file, int line)
+	const char *file, const char *func, int line)
 {
 	size_t pos;
 	const git_index_entry *entry;
@@ -63,11 +63,11 @@ static void add_and_check_mode_(
 	cl_git_pass(git_index_add_bypath(index, filename));
 
 	clar__assert(!git_index_find(&pos, index, filename),
-		file, line, "Cannot find index entry", NULL, 1);
+		file, func, line, "Cannot find index entry", NULL, 1);
 
 	entry = git_index_get_byindex(index, pos);
 
-	clar__assert_equal(file, line, "Expected mode does not match index",
+	clar__assert_equal(file, func, line, "Expected mode does not match index",
 		1, "%07o", (unsigned int)entry->mode, (unsigned int)expect_mode);
 }
 
@@ -153,11 +153,11 @@ void test_index_filemodes__trusted(void)
 	git_index_free(index);
 }
 
-#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__LINE__)
+#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__func__,__LINE__)
 
 static void add_entry_and_check_mode_(
 	git_index *index, bool from_file, git_filemode_t mode,
-	const char *file, int line)
+	const char *file, const char *func, int line)
 {
 	size_t pos;
 	const git_index_entry* entry;
@@ -169,7 +169,7 @@ static void add_entry_and_check_mode_(
 	if (from_file)
 	{
 		clar__assert(!git_index_find(&pos, index, "exec_off"),
-			file, line, "Cannot find original index entry", NULL, 1);
+			file, func, line, "Cannot find original index entry", NULL, 1);
 
 		entry = git_index_get_byindex(index, pos);
 
@@ -184,21 +184,21 @@ static void add_entry_and_check_mode_(
 	if (from_file)
 	{
 		clar__assert(!git_index_add(index, &new_entry),
-			file, line, "Cannot add index entry", NULL, 1);
+			file, func, line, "Cannot add index entry", NULL, 1);
 	}
 	else
 	{
 		const char *content = "hey there\n";
 		clar__assert(!git_index_add_from_buffer(index, &new_entry, content, strlen(content)),
-			file, line, "Cannot add index entry from buffer", NULL, 1);
+			file, func, line, "Cannot add index entry from buffer", NULL, 1);
 	}
 
 	clar__assert(!git_index_find(&pos, index, "filemodes/explicit_test"),
-		file, line, "Cannot find new index entry", NULL, 1);
+		file, func, line, "Cannot find new index entry", NULL, 1);
 
 	entry = git_index_get_byindex(index, pos);
 
-	clar__assert_equal(file, line, "Expected mode does not match index",
+	clar__assert_equal(file, func, line, "Expected mode does not match index",
 		1, "%07o", (unsigned int)entry->mode, (unsigned int)mode);
 }
 
diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c
index 63ecfee..f7ff05c 100644
--- a/tests/object/commit/commitstagedfile.c
+++ b/tests/object/commit/commitstagedfile.c
@@ -49,9 +49,9 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
 	 * tree 2b297e643c551e76cfa1f93810c50811382f9117
 	 * author nulltoken <emeric.fermas@gmail.com> 1323847743 +0100
 	 * committer nulltoken <emeric.fermas@gmail.com> 1323847743 +0100
-	 * 
+	 *
 	 *     Initial commit
-	 * 
+	 *
 	 * diff --git a/test.txt b/test.txt
 	 * new file mode 100644
 	 * index 0000000..9daeafb
@@ -141,14 +141,14 @@ static void assert_commit_tree_has_n_entries(git_commit *c, int count)
 	git_tree_free(tree);
 }
 
-static void assert_commit_is_head_(git_commit *c, const char *file, int line)
+static void assert_commit_is_head_(git_commit *c, const char *file, const char *func, int line)
 {
 	git_commit *head;
 	cl_git_pass(git_revparse_single((git_object **)&head, repo, "HEAD"));
-	clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, line, "Commit is not the HEAD", NULL, 1);
+	clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, func, line, "Commit is not the HEAD", NULL, 1);
 	git_commit_free(head);
 }
-#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__LINE__)
+#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__func__,__LINE__)
 
 void test_object_commit_commitstagedfile__amend_commit(void)
 {
diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c
index 7b0b8ca..1bc5a50 100644
--- a/tests/object/tree/write.c
+++ b/tests/object/tree/write.c
@@ -453,7 +453,8 @@ static void test_invalid_objects(bool should_allow_invalid)
 	git_oid valid_blob_id, invalid_blob_id, valid_tree_id, invalid_tree_id;
 
 #define assert_allowed(expr) \
-	clar__assert(!(expr) == should_allow_invalid, __FILE__, __LINE__, \
+	clar__assert(!(expr) == should_allow_invalid, \
+		__FILE__, __func__, __LINE__, \
 		(should_allow_invalid ? \
 		 "Expected function call to succeed: " #expr : \
 		 "Expected function call to fail: " #expr), \
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c
index 6eba8ec..aecb78b 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/refs/reflog/reflog_helpers.c
@@ -29,7 +29,8 @@ size_t reflog_entrycount(git_repository *repo, const char *name)
 
 void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx,
 	const char *old_spec, const char *new_spec,
-	const char *email, const char *message, const char *file, int line)
+	const char *email, const char *message,
+	const char *file, const char *func, int line)
 {
 	git_reflog *log;
 	const git_reflog_entry *entry;
@@ -38,7 +39,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
 	cl_git_pass(git_reflog_read(&log, repo, reflog));
 	entry = git_reflog_entry_byindex(log, idx);
 	if (entry == NULL)
-		clar__fail(file, line, "Reflog has no such entry", NULL, 1);
+		clar__fail(file, func, line, "Reflog has no such entry", NULL, 1);
 
 	if (old_spec) {
 		git_object *obj = NULL;
@@ -92,7 +93,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
 			git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
 	}
 	if (git_buf_len(&result) != 0)
-		clar__fail(file, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
+		clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
 
 	git_buf_dispose(&result);
 	git_reflog_free(log);
diff --git a/tests/repo/env.c b/tests/repo/env.c
index 0246616..43defc1 100644
--- a/tests/repo/env.c
+++ b/tests/repo/env.c
@@ -53,44 +53,44 @@ static int GIT_FORMAT_PRINTF(2, 3) cl_setenv_printf(const char *name, const char
  * from the caller rather than those of the helper. The expression strings
  * distinguish between the possible failures within the helper. */
 
-static void env_pass_(const char *path, const char *file, int line)
+static void env_pass_(const char *path, const char *file, const char *func, int line)
 {
 	git_repository *repo;
-	cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
-	cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
-	cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, line);
-	cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, line);
-	cl_assert_at_line(!git_repository_is_bare(repo), file, line);
+	cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
+	cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
+	cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, func, line);
+	cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, func, line);
+	cl_assert_at_line(!git_repository_is_bare(repo), file, func, line);
 	git_repository_free(repo);
 }
-#define env_pass(path) env_pass_((path), __FILE__, __LINE__)
+#define env_pass(path) env_pass_((path), __FILE__, __func__, __LINE__)
 
-#define cl_git_fail_at_line(expr, file, line) clar__assert((expr) < 0, file, line, "Expected function call to fail: " #expr, NULL, 1)
+#define cl_git_fail_at_line(expr, file, func, line) clar__assert((expr) < 0, file, func, line, "Expected function call to fail: " #expr, NULL, 1)
 
-static void env_fail_(const char *path, const char *file, int line)
+static void env_fail_(const char *path, const char *file, const char *func, int line)
 {
 	git_repository *repo;
-	cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line);
-	cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line);
+	cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line);
+	cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line);
 }
-#define env_fail(path) env_fail_((path), __FILE__, __LINE__)
+#define env_fail(path) env_fail_((path), __FILE__, __func__, __LINE__)
 
 static void env_cd_(
 	const char *path,
-	void (*passfail_)(const char *, const char *, int),
-	const char *file, int line)
+	void (*passfail_)(const char *, const char *, const char *, int),
+	const char *file, const char *func, int line)
 {
 	git_buf cwd_buf = GIT_BUF_INIT;
 	cl_git_pass(git_path_prettify_dir(&cwd_buf, ".", NULL));
 	cl_must_pass(p_chdir(path));
-	passfail_(NULL, file, line);
+	passfail_(NULL, file, func, line);
 	cl_must_pass(p_chdir(git_buf_cstr(&cwd_buf)));
 	git_buf_dispose(&cwd_buf);
 }
-#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __LINE__)
-#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __LINE__)
+#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __func__, __LINE__)
+#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __func__, __LINE__)
 
-static void env_check_objects_(bool a, bool t, bool p, const char *file, int line)
+static void env_check_objects_(bool a, bool t, bool p, const char *file, const char *func, int line)
 {
 	git_repository *repo;
 	git_oid oid_a, oid_t, oid_p;
@@ -98,32 +98,32 @@ static void env_check_objects_(bool a, bool t, bool p, const char *file, int lin
 	cl_git_pass(git_oid_fromstr(&oid_a, "45141a79a77842c59a63229403220a4e4be74e3d"));
 	cl_git_pass(git_oid_fromstr(&oid_t, "1385f264afb75a56a5bec74243be9b367ba4ca08"));
 	cl_git_pass(git_oid_fromstr(&oid_p, "0df1a5865c8abfc09f1f2182e6a31be550e99f07"));
-	cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
+	cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
 
 	if (a) {
-		cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, line);
+		cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, func, line);
 		git_object_free(object);
 	} else {
-		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, line);
+		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, func, line);
 	}
 
 	if (t) {
-		cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, line);
+		cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, func, line);
 		git_object_free(object);
 	} else {
-		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, line);
+		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, func, line);
 	}
 
 	if (p) {
-		cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, line);
+		cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, func, line);
 		git_object_free(object);
 	} else {
-		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, line);
+		cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, func, line);
 	}
 
 	git_repository_free(repo);
 }
-#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __LINE__)
+#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __func__, __LINE__)
 
 void test_repo_env__open(void)
 {
diff --git a/tests/status/status_helpers.h b/tests/status/status_helpers.h
index 242076c..464266a 100644
--- a/tests/status/status_helpers.h
+++ b/tests/status/status_helpers.h
@@ -9,6 +9,7 @@ typedef struct {
 	const char** expected_paths;
 	int expected_entry_count;
 	const char *file;
+	const char *func;
 	int line;
 	bool debug;
 } status_entry_counts;
@@ -18,6 +19,7 @@ typedef struct {
 	(counts).expected_statuses = (statuses); \
 	(counts).expected_paths = (paths); \
 	(counts).file = __FILE__; \
+	(counts).func = __func__; \
 	(counts).line = __LINE__; \
 	} while (0)
 
diff --git a/tests/status/submodules.c b/tests/status/submodules.c
index 12edce2..38a3947 100644
--- a/tests/status/submodules.c
+++ b/tests/status/submodules.c
@@ -71,12 +71,12 @@ static int cb_status__match(const char *p, unsigned int s, void *payload)
 	int idx = counts->entry_count++;
 
 	clar__assert_equal(
-		counts->file, counts->line,
+		counts->file, counts->func, counts->line,
 		"Status path mismatch", 1,
 		"%s", counts->expected_paths[idx], p);
 
 	clar__assert_equal(
-		counts->file, counts->line,
+		counts->file, counts->func, counts->line,
 		"Status code mismatch", 1,
 		"%o", counts->expected_statuses[idx], s);
 
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 4bb0648..1d47596 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -199,22 +199,22 @@ git_repository *setup_fixture_submodule_with_path(void)
 
 void assert__submodule_exists(
 	git_repository *repo, const char *name,
-	const char *msg, const char *file, int line)
+	const char *msg, const char *file, const char *func, int line)
 {
 	git_submodule *sm;
 	int error = git_submodule_lookup(&sm, repo, name);
 	if (error)
-		cl_git_report_failure(error, 0, file, line, msg);
-	cl_assert_at_line(sm != NULL, file, line);
+		cl_git_report_failure(error, 0, file, func, line, msg);
+	cl_assert_at_line(sm != NULL, file, func, line);
 	git_submodule_free(sm);
 }
 
 void refute__submodule_exists(
 	git_repository *repo, const char *name, int expected_error,
-	const char *msg, const char *file, int line)
+	const char *msg, const char *file, const char *func, int line)
 {
 	clar__assert_equal(
-		file, line, msg, 1, "%i",
+		file, func, line, msg, 1, "%i",
 		expected_error, (int)(git_submodule_lookup(NULL, repo, name)));
 }
 
diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h
index d112b0c..3c3f062 100644
--- a/tests/submodule/submodule_helpers.h
+++ b/tests/submodule/submodule_helpers.h
@@ -10,16 +10,16 @@ extern git_repository *setup_fixture_submodule_with_path(void);
 
 extern unsigned int get_submodule_status(git_repository *, const char *);
 
-extern void assert__submodule_exists(
-	git_repository *, const char *, const char *, const char *, int);
+extern void assert__submodule_exists(git_repository *, const char *,
+	const char *, const char *, const char *, int);
 
 #define assert_submodule_exists(repo,name)								\
-	assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __LINE__)
+	assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __func__, __LINE__)
 
-extern void refute__submodule_exists(
-	git_repository *, const char *, int err, const char *, const char *, int);
+extern void refute__submodule_exists(git_repository *, const char *,
+	int err, const char *, const char *, const char *, int);
 
 #define refute_submodule_exists(repo,name,code) \
-	refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __LINE__)
+	refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __func__, __LINE__)
 
 extern void dump_submodules(git_repository *repo);