11'use strict' ;
2+ const Path = require ( 'path' ) ;
3+
24const { test } = require ( 'tap' ) ;
35
46const startCLI = require ( './start-cli' ) ;
57
68test ( 'stepping through breakpoints' , ( t ) => {
7- const cli = startCLI ( [ 'examples/break.js' ] ) ;
9+ const script = Path . join ( 'examples' , 'break.js' ) ;
10+ const cli = startCLI ( [ script ] ) ;
811
912 function onFatal ( error ) {
1013 cli . quit ( ) ;
@@ -16,7 +19,7 @@ test('stepping through breakpoints', (t) => {
1619 . then ( ( ) => {
1720 t . match (
1821 cli . output ,
19- ' break in examples/break.js:1' ,
22+ ` break in ${ script } :1` ,
2023 'pauses in the first line of the script' ) ;
2124 t . match (
2225 cli . output ,
@@ -27,7 +30,7 @@ test('stepping through breakpoints', (t) => {
2730 . then ( ( ) => {
2831 t . match (
2932 cli . output ,
30- ' break in examples/break.js:2' ,
33+ ` break in ${ script } :2` ,
3134 'pauses in next line of the script' ) ;
3235 t . match (
3336 cli . output ,
@@ -38,7 +41,7 @@ test('stepping through breakpoints', (t) => {
3841 . then ( ( ) => {
3942 t . match (
4043 cli . output ,
41- ' break in examples/break.js:3' ,
44+ ` break in ${ script } :3` ,
4245 'pauses in next line of the script' ) ;
4346 t . match (
4447 cli . output ,
@@ -49,7 +52,7 @@ test('stepping through breakpoints', (t) => {
4952 . then ( ( ) => {
5053 t . match (
5154 cli . output ,
52- ' break in examples/break.js :10' ,
55+ ` break in ${ script } :10` ,
5356 'pauses on the next breakpoint' ) ;
5457 t . match (
5558 cli . output ,
@@ -65,8 +68,8 @@ test('stepping through breakpoints', (t) => {
6568 . then ( ( ) => t . notMatch ( cli . output , 'Could not resolve breakpoint' ) )
6669 . then ( ( ) => cli . command ( 'breakpoints' ) )
6770 . then ( ( ) => {
68- t . match ( cli . output , ' #0 examples/break.js:6' ) ;
69- t . match ( cli . output , ' #1 examples/break.js :16' ) ;
71+ t . match ( cli . output , ` #0 ${ script } :6` ) ;
72+ t . match ( cli . output , ` #1 ${ script } :16` ) ;
7073 } )
7174
7275 . then ( ( ) => cli . command ( 'list()' ) )
@@ -98,29 +101,31 @@ test('stepping through breakpoints', (t) => {
98101 . then ( ( ) => {
99102 t . match (
100103 cli . output ,
101- ' break in examples/break.js :16' ,
104+ ` break in ${ script } :16` ,
102105 'found breakpoint we set above w/ line number only' ) ;
103106 } )
104107 . then ( ( ) => cli . stepCommand ( 'cont' ) )
105108 . then ( ( ) => {
106109 t . match (
107110 cli . output ,
108- ' break in examples/break.js:6' ,
111+ ` break in ${ script } :6` ,
109112 'found breakpoint we set above w/ line number & script' ) ;
110113 } )
111114 . then ( ( ) => cli . stepCommand ( '' ) )
112115 . then ( ( ) => {
113116 t . match (
114117 cli . output ,
115- ' debugCommand in examples/break.js :14' ,
118+ ` debugCommand in ${ script } :14` ,
116119 'found function breakpoint we set above' ) ;
117120 } )
118121 . then ( ( ) => cli . quit ( ) )
119122 . then ( null , onFatal ) ;
120123} ) ;
121124
122125test ( 'sb before loading file' , ( t ) => {
123- const cli = startCLI ( [ 'examples/cjs/index.js' ] ) ;
126+ const script = Path . join ( 'examples' , 'cjs' , 'index.js' ) ;
127+ const otherScript = Path . join ( 'examples' , 'cjs' , 'other.js' ) ;
128+ const cli = startCLI ( [ script ] ) ;
124129
125130 function onFatal ( error ) {
126131 cli . quit ( ) ;
@@ -140,15 +145,16 @@ test('sb before loading file', (t) => {
140145 . then ( ( ) => {
141146 t . match (
142147 cli . output ,
143- ' break in examples/cjs/other.js:3' ,
148+ ` break in ${ otherScript } :3` ,
144149 'found breakpoint in file that was not loaded yet' ) ;
145150 } )
146151 . then ( ( ) => cli . quit ( ) )
147152 . then ( null , onFatal ) ;
148153} ) ;
149154
150155test ( 'clearBreakpoint' , ( t ) => {
151- const cli = startCLI ( [ 'examples/break.js' ] ) ;
156+ const script = Path . join ( 'examples' , 'break.js' ) ;
157+ const cli = startCLI ( [ script ] ) ;
152158
153159 function onFatal ( error ) {
154160 cli . quit ( ) ;
@@ -161,8 +167,8 @@ test('clearBreakpoint', (t) => {
161167 . then ( ( ) => cli . command ( 'sb("break.js", 9)' ) )
162168 . then ( ( ) => cli . command ( 'breakpoints' ) )
163169 . then ( ( ) => {
164- t . match ( cli . output , ' #0 examples/break.js:3' ) ;
165- t . match ( cli . output , ' #1 examples/break.js:9' ) ;
170+ t . match ( cli . output , ` #0 ${ script } :3` ) ;
171+ t . match ( cli . output , ` #1 ${ script } :9` ) ;
166172 } )
167173 . then ( ( ) => cli . command ( 'clearBreakpoint("break.js", 4)' ) )
168174 . then ( ( ) => {
@@ -175,13 +181,13 @@ test('clearBreakpoint', (t) => {
175181 . then ( ( ) => cli . command ( 'clearBreakpoint("break.js", 3)' ) )
176182 . then ( ( ) => cli . command ( 'breakpoints' ) )
177183 . then ( ( ) => {
178- t . match ( cli . output , ' #0 examples/break.js:9' ) ;
184+ t . match ( cli . output , ` #0 ${ script } :9` ) ;
179185 } )
180186 . then ( ( ) => cli . stepCommand ( 'cont' ) )
181187 . then ( ( ) => {
182188 t . match (
183189 cli . output ,
184- ' break in examples/break.js:9' ,
190+ ` break in ${ script } :9` ,
185191 'hits the 2nd breakpoint because the 1st was cleared' ) ;
186192 } )
187193 . then ( ( ) => cli . quit ( ) )
0 commit comments