@@ -403,9 +403,11 @@ analyze(_Props, CoverOpts, [CoverNode|_] = Nodes) ->
403
403
report_time (" Export merged cover data" , fun () ->
404
404
cover_export (CoverNode , " /tmp/mongoose_combined.coverdata" )
405
405
end ),
406
- case os :getenv (" GITHUB_RUN_ID" ) of
407
- false ->
408
- make_html (CoverNode , modules_to_analyze (CoverNode , CoverOpts ));
406
+ case {os :getenv (" GITHUB_RUN_ID" ), os :getenv (" CIRCLECI" )} of
407
+ {false , false } ->
408
+ Mods = modules_to_analyze (CoverNode , CoverOpts ),
409
+ Txt = " Export HTML report for " ++ integer_to_list (length (Mods )) ++ " modules" ,
410
+ report_time (Txt , fun () -> make_html (CoverNode , Mods ) end );
409
411
_ ->
410
412
ok
411
413
end ,
@@ -434,25 +436,35 @@ make_html(CoverNode, Modules) ->
434
436
file :make_dir (CoverageDir ),
435
437
{ok , File } = file :open (FilePath , [write ]),
436
438
file :write (File , get_cover_header ()),
437
- Fun = fun (Module , {CAcc , NCAcc }) ->
439
+ Fun = fun (Module , {CAcc , NCAcc , Skipped , Failed , OK }) ->
438
440
FileName = lists :flatten (io_lib :format (" ~s .COVER.html" ,[Module ])),
439
441
440
442
% % We assume that import_code_paths/1 was called earlier
441
443
case cover_analyse (CoverNode , Module ) of
442
444
{ok , {Module , {C , NC }}} ->
443
- file :write (File , row (atom_to_list (Module ), C , NC , percent (C ,NC )," coverage/" ++ FileName )),
444
- FilePathC = filename :join ([CoverageDir , FileName ]),
445
- cover_analyse_to_html_file (CoverNode , Module , FilePathC ),
446
- {CAcc + C , NCAcc + NC };
445
+ FilePathC = filename :join ([Root , CoverageDir , FileName ]),
446
+ case cover_analyse_to_html_file (CoverNode , Module , FilePathC ) of
447
+ {ok , _ } ->
448
+ file :write (File , row (atom_to_list (Module ), C , NC , percent (C ,NC )," coverage/" ++ FileName )),
449
+ {CAcc + C , NCAcc + NC , Skipped , Failed , OK + 1 };
450
+ Other ->
451
+ % % Do not report link, if the destination file is not written
452
+ file :write (File , row_no_link (atom_to_list (Module ), C , NC , percent (C ,NC ))),
453
+ error_logger :error_msg (" issue=cover_analyse_to_html_file_failed module=~p reason=~p " ,
454
+ [Module , Other ]),
455
+ {CAcc + C , NCAcc + NC , Skipped , Failed + 1 , OK }
456
+ end ;
447
457
Reason ->
448
458
error_logger :error_msg (" issue=cover_analyse_failed module=~p reason=~p " ,
449
459
[Module , Reason ]),
450
- {CAcc , NCAcc }
460
+ {CAcc , NCAcc , Skipped + 1 , Failed , OK }
451
461
end
452
462
end ,
453
- {CSum , NCSum } = lists :foldl (Fun , {0 , 0 }, Modules ),
463
+ {CSum , NCSum , Skipped2 , Failed2 , OK2 } = lists :foldl (Fun , {0 , 0 , 0 , 0 , 0 }, Modules ),
454
464
file :write (File , row (" Summary" , CSum , NCSum , percent (CSum , NCSum ), " #" )),
455
- file :close (File ).
465
+ file :close (File ),
466
+ report_progress (" make_html: ok - ~p , skipped - ~p , failed - ~p~n " , [OK2 , Skipped2 , Failed2 ]),
467
+ ok .
456
468
457
469
get_hosts_to_enable_preset (Props ) ->
458
470
[Host || Host <- get_all_hosts (Props ), should_enable_preset (host_cluster (Host ))].
@@ -483,6 +495,17 @@ row(Row, C, NC, Percent, Path) ->
483
495
" </tr>\n "
484
496
].
485
497
498
+ row_no_link (Row , C , NC , Percent ) ->
499
+ [
500
+ " <tr>" ,
501
+ " <td>" , Row , " </td>" ,
502
+ " <td>" , integer_to_list (Percent ), " %</td>" ,
503
+ " <td>" , integer_to_list (C ), " </td>" ,
504
+ " <td>" , integer_to_list (NC ), " </td>" ,
505
+ " <td>" , integer_to_list (C + NC ), " </td>" ,
506
+ " </tr>\n "
507
+ ].
508
+
486
509
get_cover_header () ->
487
510
" <html>\n <head></head>\n <body bgcolor=\" white\" text=\" black\" link=\" blue\" vlink=\" purple\" alink=\" red\" >\n "
488
511
" <head><script src='sorttable.js'></script></head>"
0 commit comments