1414 */
1515/* eslint-disable no-var */
1616
17+ import {
18+ colorBrowser ,
19+ TEST_PASSED ,
20+ TEST_UNEXPECTED_FAIL ,
21+ } from "./color_utils.mjs" ;
1722import { copySubtreeSync , ensureDirSync } from "./testutils.mjs" ;
1823import {
1924 COVERAGE_FORMAT_TO_REPORTER ,
@@ -423,7 +428,7 @@ function handleSessionTimeout(session) {
423428 return ;
424429 }
425430 console . log (
426- `TEST-UNEXPECTED-FAIL | test failed ${ session . name } has not responded in ${ browserTimeout } s`
431+ `${ TEST_UNEXPECTED_FAIL } | test failed ${ session . name } has not responded in ${ browserTimeout } s`
427432 ) ;
428433 session . numErrors += session . remaining ;
429434 session . remaining = 0 ;
@@ -558,7 +563,7 @@ async function checkEq(task, results, session, masterMode) {
558563 ) === 0 ;
559564 if ( ! eq ) {
560565 console . log (
561- `TEST-UNEXPECTED-FAIL | ${ taskType } ${ taskId } | in ${ session . name } | rendering of page ${ page + 1 } != reference rendering`
566+ `${ TEST_UNEXPECTED_FAIL } | ${ taskType } ${ taskId } | in ${ colorBrowser ( session . name ) } | rendering of page ${ page + 1 } != reference rendering`
562567 ) ;
563568
564569 if ( ! testDirCreated ) {
@@ -605,7 +610,9 @@ async function checkEq(task, results, session, masterMode) {
605610 if ( numEqFailures > 0 ) {
606611 session . numEqFailures += numEqFailures ;
607612 } else {
608- console . log ( `TEST-PASS | ${ taskType } test ${ taskId } | in ${ session . name } ` ) ;
613+ console . log (
614+ `${ TEST_PASSED } | ${ taskType } test ${ taskId } | in ${ colorBrowser ( session . name ) } `
615+ ) ;
609616 }
610617}
611618
@@ -633,13 +640,13 @@ function checkFBF(task, results, session, masterMode) {
633640 // https://github.com/mozilla/pdf.js/issues/12371
634641 if ( masterMode ) {
635642 console . log (
636- `TEST-SKIPPED | forward-back-forward test ${ task . id } | in ${ session . name } | page${ page + 1 } `
643+ `TEST-SKIPPED | forward-back-forward test ${ task . id } | in ${ colorBrowser ( session . name ) } | page${ page + 1 } `
637644 ) ;
638645 continue ;
639646 }
640647
641648 console . log (
642- `TEST-UNEXPECTED-FAIL | forward-back-forward test ${ task . id } | in ${ session . name } | first rendering of page ${ page + 1 } != second`
649+ `${ TEST_UNEXPECTED_FAIL } | forward-back-forward test ${ task . id } | in ${ colorBrowser ( session . name ) } | first rendering of page ${ page + 1 } != second`
643650 ) ;
644651 numFBFFailures ++ ;
645652 }
@@ -649,15 +656,17 @@ function checkFBF(task, results, session, masterMode) {
649656 session . numFBFFailures += numFBFFailures ;
650657 } else {
651658 console . log (
652- `TEST-PASS | forward-back-forward test ${ task . id } | in ${ session . name } `
659+ `${ TEST_PASSED } | forward-back-forward test ${ task . id } | in ${ colorBrowser ( session . name ) } `
653660 ) ;
654661 }
655662}
656663
657664function checkLoad ( task , results , browser ) {
658665 // Load just checks for absence of failure, so if we got here the
659666 // test has passed
660- console . log ( `TEST-PASS | load test ${ task . id } | in ${ browser } ` ) ;
667+ console . log (
668+ `${ TEST_PASSED } | load test ${ task . id } | in ${ colorBrowser ( browser ) } `
669+ ) ;
661670}
662671
663672async function checkRefTestResults ( browser , id , results ) {
@@ -685,7 +694,7 @@ async function checkRefTestResults(browser, id, results) {
685694 "TEST-SKIPPED | PDF was not downloaded " +
686695 id +
687696 " | in " +
688- browser +
697+ colorBrowser ( browser ) +
689698 " | page" +
690699 ( page + 1 ) +
691700 " round " +
@@ -698,16 +707,7 @@ async function checkRefTestResults(browser, id, results) {
698707 session . numErrors ++ ;
699708 }
700709 console . log (
701- "TEST-UNEXPECTED-FAIL | test failed " +
702- id +
703- " | in " +
704- browser +
705- " | page" +
706- ( page + 1 ) +
707- " round " +
708- ( round + 1 ) +
709- " | " +
710- pageResult . failure
710+ `${ TEST_UNEXPECTED_FAIL } | test failed ${ id } | in ${ colorBrowser ( browser ) } | page${ page + 1 } round ${ round + 1 } | ${ pageResult . failure } `
711711 ) ;
712712 }
713713 }
@@ -835,6 +835,16 @@ function onAllSessionsClosedAfterTests(name) {
835835 } else if ( numErrors > 0 ) {
836836 console . log ( "OHNOES! Some " + name + " tests failed!" ) ;
837837 console . log ( " " + numErrors + " of " + numRuns + " failed" ) ;
838+ console . log ( "Here are the failing tests:" ) ;
839+ for ( const session of sessions ) {
840+ for ( const { description, error } of session . failures ?? [ ] ) {
841+ let line = ` - in ${ colorBrowser ( session . name ) } | ${ description } ` ;
842+ if ( error ) {
843+ line += ` | ${ error . replaceAll ( / \s + / g, " " ) . trim ( ) } ` ;
844+ }
845+ console . log ( line ) ;
846+ }
847+ }
838848 } else {
839849 console . log ( "All " + name + " tests passed." ) ;
840850 }
@@ -854,6 +864,7 @@ async function startUnitTest(testUrl, name) {
854864 initializeSession : session => {
855865 session . numRuns = 0 ;
856866 session . numErrors = 0 ;
867+ session . failures = [ ] ;
857868 } ,
858869 } ) ;
859870}
@@ -868,15 +879,17 @@ async function startIntegrationTest() {
868879 initializeSession : session => {
869880 session . numRuns = 0 ;
870881 session . numErrors = 0 ;
882+ session . failures = [ ] ;
871883 } ,
872884 } ) ;
873885 global . integrationBaseUrl = `http://${ host } :${ server . port } /build/generic/web/viewer.html` ;
874886 global . integrationSessions = sessions ;
875887
876- const results = { runs : 0 , failures : 0 } ;
888+ const results = { runs : 0 , failures : 0 , failureList : [ ] } ;
877889 await runTests ( results ) ;
878890 sessions [ 0 ] . numRuns = results . runs ;
879891 sessions [ 0 ] . numErrors = results . failures ;
892+ sessions [ 0 ] . failures = results . failureList ;
880893 await Promise . all ( sessions . map ( session => closeSession ( session . name ) ) ) ;
881894}
882895
@@ -920,10 +933,20 @@ function unitTestPostHandler(parsedUrl, req, res) {
920933 }
921934 var session = getSession ( data . browser ) ;
922935 session . numRuns ++ ;
936+ let status = data . status ;
937+ if ( status === "TEST-UNEXPECTED-FAIL" ) {
938+ status = TEST_UNEXPECTED_FAIL ;
939+ } else if ( status === "TEST-PASS" ) {
940+ status = TEST_PASSED ;
941+ }
923942 var message =
924- data . status + " | " + data . description + " | in " + session . name ;
943+ status + " | " + data . description + " | in " + colorBrowser ( session . name ) ;
925944 if ( data . status === "TEST-UNEXPECTED-FAIL" ) {
926945 session . numErrors ++ ;
946+ session . failures . push ( {
947+ description : data . description ,
948+ error : data . error ,
949+ } ) ;
927950 }
928951 if ( data . error ) {
929952 message += " | " + data . error ;
0 commit comments