| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0013af6 commit 2a59e4e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,22 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var path = require('path'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var spawn = require('child_process').spawn; | ||
| 5 | - var common = require('../common'); | ||
| 6 | - var debug = require('_debugger'); | ||
| 2 | + const path = require('path'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const spawn = require('child_process').spawn; | ||
| 5 | + const common = require('../common'); | ||
| 6 | + const debug = require('_debugger'); | ||
| 7 | 7 | ||
| 8 | - addScenario('global.js', null, 2); | ||
| 9 | - addScenario('timeout.js', null, 2); | ||
| 8 | + var scenarios = []; | ||
| 9 | + | ||
| 10 | + addScenario('global.js', 2); | ||
| 11 | + addScenario('timeout.js', 2); | ||
| 10 | 12 | ||
| 11 | 13 | run(); | |
| 12 | 14 | ||
| 13 | 15 | /***************** IMPLEMENTATION *****************/ | |
| 14 | 16 | ||
| 15 | - var scenarios; | ||
| 16 | - function addScenario(scriptName, throwsInFile, throwsOnLine) { | ||
| 17 | - if (!scenarios) scenarios = []; | ||
| 17 | + function addScenario(scriptName, throwsOnLine) { | ||
| 18 | 18 | scenarios.push( | |
| 19 | - runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run) | ||
| 19 | + runScenario.bind(null, scriptName, throwsOnLine, run) | ||
| 20 | 20 | ); | |
| 21 | 21 | } | |
| 22 | 22 | ||
@@ -25,10 +25,10 @@ function run() { | |||
| 25 | 25 | if (next) next(); | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | - function runScenario(scriptName, throwsInFile, throwsOnLine, next) { | ||
| 28 | + function runScenario(scriptName, throwsOnLine, next) { | ||
| 29 | 29 | console.log('**[ %s ]**', scriptName); | |
| 30 | 30 | var asserted = false; | |
| 31 | - var port = common.PORT + 1337; | ||
| 31 | + var port = common.PORT; | ||
| 32 | 32 | ||
| 33 | 33 | var testScript = path.join( | |
| 34 | 34 | common.fixturesDir, | |
@@ -44,7 +44,18 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { | |||
| 44 | 44 | ||
| 45 | 45 | var exceptions = []; | |
| 46 | 46 | ||
| 47 | - setTimeout(setupClient.bind(null, runTest), 200); | ||
| 47 | + var stderr = ''; | ||
| 48 | + | ||
| 49 | + function stderrListener(data) { | ||
| 50 | + stderr += data; | ||
| 51 | + if (stderr.includes('Debugger listening on port')) { | ||
| 52 | + setTimeout(setupClient.bind(null, runTest), 200); | ||
| 53 | + child.stderr.removeListener('data', stderrListener); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + child.stderr.setEncoding('utf8'); | ||
| 58 | + child.stderr.on('data', stderrListener); | ||
| 48 | 59 | ||
| 49 | 60 | function setupClient(callback) { | |
| 50 | 61 | var client = new debug.Client(); | |
@@ -88,11 +99,11 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { | |||
| 88 | 99 | } | |
| 89 | 100 | ||
| 90 | 101 | function assertHasPaused(client) { | |
| 102 | + assert(exceptions.length, 'no exceptions thrown, race condition in test?'); | ||
| 91 | 103 | assert.equal(exceptions.length, 1, 'debugger did not pause on exception'); | |
| 92 | 104 | assert.equal(exceptions[0].uncaught, true); | |
| 93 | - assert.equal(exceptions[0].script.name, throwsInFile || testScript); | ||
| 94 | - if (throwsOnLine != null) | ||
| 95 | - assert.equal(exceptions[0].sourceLine + 1, throwsOnLine); | ||
| 105 | + assert.equal(exceptions[0].script.name, testScript); | ||
| 106 | + assert.equal(exceptions[0].sourceLine + 1, throwsOnLine); | ||
| 96 | 107 | asserted = true; | |
| 97 | 108 | client.reqContinue(assert.ifError); | |
| 98 | 109 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments