@@ -9,54 +9,39 @@ const startCLI = require('../common/debugger');
9
9
const assert = require ( 'assert' ) ;
10
10
const path = require ( 'path' ) ;
11
11
12
+ const scriptFullPath = fixtures . path ( 'debugger' , 'three-lines.js' ) ;
13
+ const script = path . relative ( process . cwd ( ) , scriptFullPath ) ;
14
+
12
15
// Run after quit.
13
- {
14
- const scriptFullPath = fixtures . path ( 'debugger' , 'three-lines.js' ) ;
15
- const script = path . relative ( process . cwd ( ) , scriptFullPath ) ;
16
+ const runTest = async ( ) => {
16
17
const cli = startCLI ( [ script ] ) ;
17
-
18
- function onFatal ( error ) {
19
- cli . quit ( ) ;
20
- throw error ;
18
+ try {
19
+ await cli . waitForInitialBreak ( ) ;
20
+ await cli . waitForPrompt ( ) ;
21
+ await cli . command ( 'breakpoints' ) ;
22
+ assert . match ( cli . output , / N o b r e a k p o i n t s y e t / ) ;
23
+ await cli . command ( 'sb(2)' ) ;
24
+ await cli . command ( 'sb(3)' ) ;
25
+ await cli . command ( 'breakpoints' ) ;
26
+ assert . ok ( cli . output . includes ( `#0 ${ script } :2` ) ) ;
27
+ assert . ok ( cli . output . includes ( `#1 ${ script } :3` ) ) ;
28
+ await cli . stepCommand ( 'c' ) ; // hit line 2
29
+ await cli . stepCommand ( 'c' ) ; // hit line 3
30
+ assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 3 } ) ;
31
+ await cli . command ( 'restart' ) ;
32
+ await cli . waitForInitialBreak ( ) ;
33
+ assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
34
+ await cli . stepCommand ( 'c' ) ;
35
+ assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 2 } ) ;
36
+ await cli . stepCommand ( 'c' ) ;
37
+ assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 3 } ) ;
38
+ await cli . command ( 'breakpoints' ) ;
39
+ const msg = `SCRIPT: ${ script } , OUTPUT: ${ cli . output } ` ;
40
+ assert . ok ( cli . output . includes ( `#0 ${ script } :2` ) , msg ) ;
41
+ assert . ok ( cli . output . includes ( `#1 ${ script } :3` ) , msg ) ;
42
+ } finally {
43
+ await cli . quit ( ) ;
21
44
}
45
+ } ;
22
46
23
- return cli . waitForInitialBreak ( )
24
- . then ( ( ) => cli . waitForPrompt ( ) )
25
- . then ( ( ) => cli . command ( 'breakpoints' ) )
26
- . then ( ( ) => {
27
- assert . match ( cli . output , / N o b r e a k p o i n t s y e t / ) ;
28
- } )
29
- . then ( ( ) => cli . command ( 'sb(2)' ) )
30
- . then ( ( ) => cli . command ( 'sb(3)' ) )
31
- . then ( ( ) => cli . command ( 'breakpoints' ) )
32
- . then ( ( ) => {
33
- assert . ok ( cli . output . includes ( `#0 ${ script } :2` ) ) ;
34
- assert . ok ( cli . output . includes ( `#1 ${ script } :3` ) ) ;
35
- } )
36
- . then ( ( ) => cli . stepCommand ( 'c' ) ) // hit line 2
37
- . then ( ( ) => cli . stepCommand ( 'c' ) ) // hit line 3
38
- . then ( ( ) => {
39
- assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 3 } ) ;
40
- } )
41
- . then ( ( ) => cli . command ( 'restart' ) )
42
- . then ( ( ) => cli . waitForInitialBreak ( ) )
43
- . then ( ( ) => {
44
- assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
45
- } )
46
- . then ( ( ) => cli . stepCommand ( 'c' ) )
47
- . then ( ( ) => {
48
- assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 2 } ) ;
49
- } )
50
- . then ( ( ) => cli . stepCommand ( 'c' ) )
51
- . then ( ( ) => {
52
- assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 3 } ) ;
53
- } )
54
- . then ( ( ) => cli . command ( 'breakpoints' ) )
55
- . then ( ( ) => {
56
- const msg = `SCRIPT: ${ script } , OUTPUT: ${ cli . output } ` ;
57
- assert . ok ( cli . output . includes ( `#0 ${ script } :2` ) , msg ) ;
58
- assert . ok ( cli . output . includes ( `#1 ${ script } :3` ) , msg ) ;
59
- } )
60
- . then ( ( ) => cli . quit ( ) )
61
- . then ( null , onFatal ) ;
62
- }
47
+ runTest ( ) ;
0 commit comments