@@ -25,27 +25,46 @@ function runTests(mod, results) {
2525 try {
2626 test . get ( Symbol . for ( 'test' ) ) ( context ) ;
2727 results . success ++ ;
28+ process . stdout . write ( '.' ) ;
2829 } catch ( e ) {
29- handleError ( e ) ;
3030 results . failed ++ ;
31+ handleError ( e , test , results , mod ) ;
3132 }
3233 }
3334 }
3435}
3536
36- function handleError ( e ) {
37+ function handleError ( e , test , results , mod ) {
3738 if ( e . __reason ) {
3839 if ( e . __reason instanceof Map && e . __reason . get ( Symbol . for ( 'message' ) ) ) {
39- console . error ( e . __reason . get ( Symbol . for ( 'message' ) ) ) ;
40- console . error ( e . __reason . get ( Symbol . for ( 'expr' ) ) . toString ( ) ) ;
41- console . error ( e . __reason . get ( Symbol . for ( 'left' ) ) . toString ( ) ) ;
42- console . error ( e . __reason . get ( Symbol . for ( 'right' ) ) . toString ( ) ) ;
40+ const errorMessage = e . __reason . get ( Symbol . for ( 'message' ) ) ;
41+ const expr = e . __reason . get ( Symbol . for ( 'expr' ) ) ;
42+ const left = e . __reason . get ( Symbol . for ( 'left' ) ) ;
43+ const right = e . __reason . get ( Symbol . for ( 'right' ) ) ;
44+ const moduleName = Symbol . keyFor ( mod . default . __MODULE__ ) . replace ( 'Elixir.' , '' ) ;
45+ let testMessage = test . get ( Symbol . for ( 'message' ) ) ;
46+ testMessage = `${ results . failed } ) ${ testMessage } (${ moduleName } )` ;
47+
48+ printErrorLine ( testMessage ) ;
49+ printErrorLine ( errorMessage ) ;
50+ printErrorLine ( left , 'left' ) ;
51+ printErrorLine ( right , 'right' ) ;
4352 }
4453 } else {
4554 console . error ( e . message ) ;
4655 }
4756}
4857
58+ function printErrorLine ( value , label = null ) {
59+ if ( value !== Symbol . for ( 'ex_unit_no_meaningful_value' ) ) {
60+ if ( label ) {
61+ console . error ( `${ label } : ${ value } ` ) ;
62+ } else {
63+ console . error ( `${ value } ` ) ;
64+ }
65+ }
66+ }
67+
4968export default {
5069 start,
5170} ;
0 commit comments