@@ -226,7 +226,7 @@ helpers._actual = {
226226 . replace ( / $ / , '' ) ;
227227 } ;
228228
229- var promisedJoin = util . promised ( join ) ;
229+ var promisedJoin = Promise . promised ( join ) ;
230230 return promisedJoin ( templateData . directTabText ,
231231 templateData . emptyParameters ,
232232 templateData . arrowTabText ) ;
@@ -314,12 +314,12 @@ helpers._createDebugCheck = function(options) {
314314 var hintsPromise = helpers . _actual . hints ( options ) ;
315315 var predictionsPromise = helpers . _actual . predictions ( options ) ;
316316
317- return util . all ( hintsPromise , predictionsPromise ) . then ( function ( values ) {
317+ return Promise . all ( hintsPromise , predictionsPromise ) . then ( function ( values ) {
318318 var hints = values [ 0 ] ;
319319 var predictions = values [ 1 ] ;
320320 var output = '' ;
321321
322- output += 'helpers.audit(options, [\n' ;
322+ output += 'return helpers.audit(options, [\n' ;
323323 output += ' {\n' ;
324324
325325 if ( cursor === input . length ) {
@@ -627,13 +627,14 @@ helpers._check = function(options, name, checks) {
627627 Object . keys ( checks . args ) . forEach ( function ( paramName ) {
628628 var check = checks . args [ paramName ] ;
629629
630- var assignment ;
631- if ( paramName === 'command' ) {
630+ // We allow an 'argument' called 'command' to be the command itself, but
631+ // what if the command has a parameter called 'command' (for example, an
632+ // 'exec' command)? We default to using the parameter because checking
633+ // the command value is less useful
634+ var assignment = requisition . getAssignment ( paramName ) ;
635+ if ( assignment == null && paramName === 'command' ) {
632636 assignment = requisition . commandAssignment ;
633637 }
634- else {
635- assignment = requisition . getAssignment ( paramName ) ;
636- }
637638
638639 if ( assignment == null ) {
639640 assert . ok ( false , 'Unknown arg: ' + paramName + suffix ) ;
@@ -699,7 +700,7 @@ helpers._check = function(options, name, checks) {
699700 } ) ;
700701 }
701702
702- return util . all ( outstanding ) . then ( function ( ) {
703+ return Promise . all ( outstanding ) . then ( function ( ) {
703704 // Ensure the promise resolves to nothing
704705 return undefined ;
705706 } ) ;
@@ -717,7 +718,16 @@ helpers._exec = function(options, name, expected) {
717718 return Promise . resolve ( { } ) ;
718719 }
719720
720- var output = options . display . requisition . exec ( { hidden : true } ) ;
721+ var output ;
722+ try {
723+ output = options . display . requisition . exec ( { hidden : true } ) ;
724+ }
725+ catch ( ex ) {
726+ assert . ok ( false , 'Failure executing \'' + name + '\': ' + ex ) ;
727+ util . errorHandler ( ex ) ;
728+
729+ return Promise . resolve ( { } ) ;
730+ }
721731
722732 if ( 'completed' in expected ) {
723733 assert . is ( output . completed ,
@@ -735,9 +745,6 @@ helpers._exec = function(options, name, expected) {
735745 }
736746
737747 var checkOutput = function ( ) {
738- var div = options . window . document . createElement ( 'div' ) ;
739- var conversionContext = options . display . requisition . conversionContext ;
740-
741748 if ( 'type' in expected ) {
742749 assert . is ( output . type ,
743750 expected . type ,
@@ -750,20 +757,20 @@ helpers._exec = function(options, name, expected) {
750757 'output.error for: ' + name ) ;
751758 }
752759
760+ var conversionContext = options . display . requisition . conversionContext ;
753761 var convertPromise = converters . convert ( output . data , output . type , 'dom' ,
754762 conversionContext ) ;
755763 return convertPromise . then ( function ( node ) {
756- div . appendChild ( node ) ;
757- var actualOutput = div . textContent . trim ( ) ;
764+ var actualOutput = node . textContent . trim ( ) ;
758765
759766 var doTest = function ( match , against ) {
760767 if ( match . test ( against ) ) {
761- assert . ok ( true , 'html output for ' + name + ' should match ' +
762- match . source ) ;
768+ assert . ok ( true , 'html output for ' + name + ' should match / ' +
769+ match . source + '/' ) ;
763770 } else {
764- assert . ok ( false , 'html output for ' + name + ' should match ' +
771+ assert . ok ( false , 'html output for ' + name + ' should match / ' +
765772 match . source +
766- '. Actual textContent: "' + against + '"' ) ;
773+ '/ . Actual textContent: "' + against + '"' ) ;
767774 }
768775 } ;
769776
@@ -820,11 +827,13 @@ var totalResponseTime = 0;
820827var averageOver = 0 ;
821828var maxResponseTime = 0 ;
822829var maxResponseCulprit = undefined ;
830+ var start = undefined ;
823831
824832/**
825833 * Restart the stats collection process
826834 */
827835helpers . resetResponseTimes = function ( ) {
836+ start = new Date ( ) . getTime ( ) ;
828837 totalResponseTime = 0 ;
829838 averageOver = 0 ;
830839 maxResponseTime = 0 ;
@@ -859,6 +868,20 @@ Object.defineProperty(helpers, 'maxResponseCulprit', {
859868 enumerable : true
860869} ) ;
861870
871+ /**
872+ * Quick summary of the times
873+ */
874+ Object . defineProperty ( helpers , 'timingSummary' , {
875+ get : function ( ) {
876+ var elapsed = ( new Date ( ) . getTime ( ) - start ) / 1000 ;
877+ return 'Total ' + elapsed + 's, ' +
878+ 'ave response ' + helpers . averageResponseTime + 'ms, ' +
879+ 'max response ' + helpers . maxResponseTime + 'ms ' +
880+ 'from \'' + helpers . maxResponseCulprit + '\'' ;
881+ } ,
882+ enumerable : true
883+ } ) ;
884+
862885/**
863886 * A way of turning a set of tests into something more declarative, this helps
864887 * to allow tests to be asynchronous.
0 commit comments