@@ -12,6 +12,7 @@ import stopProcess = require('./stop-process');
12
12
interface IHostConfiguration {
13
13
port : number ;
14
14
ips : string [ ] ;
15
+ debug : boolean ;
15
16
}
16
17
17
18
interface INetworkConfiguration extends IHostConfiguration {
@@ -28,13 +29,15 @@ interface IScriptInfo {
28
29
contents ?: string ;
29
30
}
30
31
31
- //function enableSocketIoDebugging() {
32
- // global.localStorage = {
33
- // debug: "*"
34
- // };
32
+ function enableSocketIoDebugging ( ) {
33
+ console . log ( 'enabling socket.io debugging' ) ;
35
34
36
- // global.window = global;
37
- //}
35
+ global . localStorage = {
36
+ debug : "*"
37
+ } ;
38
+
39
+ global . window = global ;
40
+ }
38
41
39
42
var config : INetworkConfiguration = require ( './config' ) ;
40
43
@@ -65,7 +68,9 @@ export class TestBrokerViewModel extends observable.Observable {
65
68
66
69
global . __karma__ = this ;
67
70
68
- //enableSocketIoDebugging();
71
+ if ( config . debug ) {
72
+ enableSocketIoDebugging ( ) ;
73
+ }
69
74
//debugger;
70
75
71
76
this . testResults = new observableArray . ObservableArray ( ) ;
@@ -240,29 +245,33 @@ export class TestBrokerViewModel extends observable.Observable {
240
245
testScripts
241
246
. filter ( script => this . isTestScript ( script . url ) )
242
247
. forEach ( script => {
243
- if ( script . localPath ) {
244
- console . log ( 'NSUTR: require script ' + script . url + ' from ' + script . localPath ) ;
245
- require ( script . localPath ) ;
246
- } else {
247
- console . log ( 'NSUTR: eval script ' + script . url ) ;
248
- this . loadShim ( script . url ) ;
249
- //call eval indirectly to execute the scripts in the global scope
250
- var geval = eval ;
251
- geval ( script . contents ) ;
252
- this . completeLoading ( script . url ) ;
253
- }
254
- } ) ;
255
-
256
- console . log ( 'beginning test run' ) ;
257
- this . start ( this . config ) ;
248
+ try {
249
+ if ( script . localPath ) {
250
+ console . log ( 'NSUTR: require script ' + script . url + ' from ' + script . localPath ) ;
251
+ require ( script . localPath ) ;
252
+ } else {
253
+ console . log ( 'NSUTR: eval script ' + script . url ) ;
254
+ this . loadShim ( script . url ) ;
255
+ //call eval indirectly to execute the scripts in the global scope
256
+ var geval = eval ;
257
+ geval ( script . contents ) ;
258
+ this . completeLoading ( script . url ) ;
259
+ }
260
+ } catch ( err ) {
261
+ this . error ( err . toString ( ) , script . localPath || script . url , err . lineNumber || 0 ) ;
262
+ }
263
+ } ) ;
264
+ if ( ! this . hasError ) {
265
+ console . log ( 'NSUTR: beginning test run' ) ;
266
+ this . start ( this . config ) ;
267
+ }
258
268
}
259
269
260
270
private isTestScript ( url : string ) : boolean {
261
271
return url . startsWith ( '/base/app/tests/' ) || ! url . startsWith ( '/base/app/' ) ;
262
272
}
263
273
264
274
public updateBrowsersInfo ( browsers ) {
265
- //console.dir(browsers);
266
275
}
267
276
268
277
public start ( cfg : any ) {
@@ -316,7 +325,14 @@ export class TestBrokerViewModel extends observable.Observable {
316
325
this . hasError = true ;
317
326
var fullMsg = url ? msg + '\nat ' + url + ( line ? ':' + line : '' ) : msg ;
318
327
console . log ( "NSUTR: this.error: " + fullMsg ) ;
319
- this . socketEmit ( 'error' , fullMsg ) ;
328
+ this . result ( {
329
+ id : url ,
330
+ description : `${ url } at line ${ line } ` || "" ,
331
+ log : [ msg ] ,
332
+ time : 0 ,
333
+ success : false ,
334
+ suite : [ ] ,
335
+ } )
320
336
this . complete ( ) ;
321
337
return false ;
322
338
}
@@ -363,6 +379,6 @@ export class TestBrokerViewModel extends observable.Observable {
363
379
export var mainViewModel = new TestBrokerViewModel ( ) ;
364
380
365
381
require ( 'application' ) . onUncaughtError = error => {
366
- console . log ( "!!!!!!!!!!!!!!!!!!!!!!! error!!!!!!!!!!!!!!!!!!!!!!!!!!! " ) ;
382
+ console . log ( "NSUTR: uncaught error" ) ;
367
383
mainViewModel . error ( error . message ) ;
368
384
}
0 commit comments