1'use strict'; 2const Path = require('path'); 3 4const { test } = require('tap'); 5 6const startCLI = require('./start-cli'); 7 8test('run after quit / restart', (t) => { 9 const script = Path.join('examples', 'three-lines.js'); 10 const cli = startCLI([script]); 11 12 function onFatal(error) { 13 cli.quit(); 14 throw error; 15 } 16 17 return cli.waitForInitialBreak() 18 .then(() => cli.waitForPrompt()) 19 .then(() => cli.command('breakpoints')) 20 .then(() => { 21 t.match(cli.output, 'No breakpoints yet'); 22 }) 23 .then(() => cli.command('sb(2)')) 24 .then(() => cli.command('sb(3)')) 25 .then(() => cli.command('breakpoints')) 26 .then(() => { 27 t.match(cli.output, `#0 ${script}:2`); 28 t.match(cli.output, `#1 ${script}:3`); 29 }) 30 .then(() => cli.stepCommand('c')) // hit line 2 31 .then(() => cli.stepCommand('c')) // hit line 3 32 .then(() => { 33 t.match(cli.breakInfo, { filename: script, line: 3 }); 34 }) 35 .then(() => cli.command('restart')) 36 .then(() => cli.waitForInitialBreak()) 37 .then(() => { 38 t.match(cli.breakInfo, { filename: script, line: 1 }); 39 }) 40 .then(() => cli.stepCommand('c')) 41 .then(() => { 42 t.match(cli.breakInfo, { filename: script, line: 2 }); 43 }) 44 .then(() => cli.stepCommand('c')) 45 .then(() => { 46 t.match(cli.breakInfo, { filename: script, line: 3 }); 47 }) 48 .then(() => cli.command('breakpoints')) 49 .then(() => { 50 if (process.platform === 'aix') { 51 // TODO: There is a known issue on AIX where the breakpoints aren't 52 // properly resolved yet when we reach this point. 53 // Eventually that should be figured out but for now we don't want 54 // to fail builds because of it. 55 t.match(cli.output, /#0 [^\n]+three-lines\.js\$?:2/); 56 t.match(cli.output, /#1 [^\n]+three-lines\.js\$?:3/); 57 } else { 58 t.match(cli.output, `#0 ${script}:2`); 59 t.match(cli.output, `#1 ${script}:3`); 60 } 61 }) 62 .then(() => cli.quit()) 63 .then(null, onFatal); 64}); 65