@@ -31,44 +31,48 @@ const proc = child_process.spawnSync(
31
31
if ( proc . status !== 0 ) console . log ( proc ) ;
32
32
assert . strictEqual ( proc . status , 0 ) ;
33
33
34
- const expectedLines = [
35
- { threadId : 0 , offset : 0 , value : 1 , timeout : 'inf' ,
36
- message : 'started' } ,
37
- { threadId : 0 , offset : 0 , value : 1 , timeout : 'inf' ,
38
- message : 'did not wait because the values mismatched' } ,
39
- { threadId : 0 , offset : 0 , value : 0 , timeout : '10' ,
40
- message : 'started' } ,
41
- { threadId : 0 , offset : 0 , value : 0 , timeout : '10' ,
42
- message : 'timed out' } ,
43
- { threadId : 0 , offset : 4 , value : 0 , timeout : 'inf' ,
44
- message : 'started' } ,
45
- { threadId : 1 , offset : 4 , value : - 1 , timeout : 'inf' ,
46
- message : 'started' } ,
47
- { threadId : 0 , offset : 4 , value : 0 , timeout : 'inf' ,
48
- message : 'was woken up by another thread' } ,
49
- { threadId : 1 , offset : 4 , value : - 1 , timeout : 'inf' ,
50
- message : 'was woken up by another thread' }
51
- ] ;
34
+ const SABAddress = proc . stderr . match ( / A t o m i c s \. w a i t \( (?< SAB > .+ ) \+ / ) . groups . SAB ;
35
+ const actualTimeline = proc . stderr
36
+ . replace ( new RegExp ( SABAddress , 'g' ) , '<address>' )
37
+ . replace ( / i n f i n i t y / g, 'inf' )
38
+ . replace ( / \r / g, '' )
39
+ . trim ( ) ;
40
+ console . log ( '+++ normalized stdout +++' ) ;
41
+ console . log ( actualTimeline ) ;
42
+ console . log ( '--- normalized stdout ---' ) ;
52
43
53
- let SABAddress ;
54
- const re = / ^ \[ T h r e a d (?< threadId > \d + ) \] A t o m i c s \. w a i t \( (?< SAB > (?: 0 x ) ? [ 0 - 9 a - f ] + ) \+ (?< offset > \d + ) , (?< value > - ? \d + ) , (?< timeout > i n f | i n f i n i t y | [ 0 - 9 . ] + ) \) (?< message > .+ ) $ / ;
55
- for ( const line of proc . stderr . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ) {
56
- if ( ! line ) continue ;
57
- console . log ( 'Matching' , { line } ) ;
58
- const actual = line . match ( re ) . groups ;
59
- const expected = expectedLines . shift ( ) ;
44
+ const begin =
45
+ `[Thread 0] Atomics.wait(<address> + 0, 1, inf) started
46
+ [Thread 0] Atomics.wait(<address> + 0, 1, inf) did not wait because the \
47
+ values mismatched
48
+ [Thread 0] Atomics.wait(<address> + 0, 0, 10) started
49
+ [Thread 0] Atomics.wait(<address> + 0, 0, 10) timed out` ;
60
50
61
- if ( SABAddress === undefined )
62
- SABAddress = actual . SAB ;
63
- else
64
- assert . strictEqual ( actual . SAB , SABAddress ) ;
51
+ const expectedTimelines = [
52
+ `${ begin }
53
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) started
54
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) started
55
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) was woken up by another thread
56
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) was woken up by another thread` ,
57
+ `${ begin }
58
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) started
59
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) was woken up by another thread
60
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) started
61
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) did not wait because the \
62
+ values mismatched` ,
63
+ `${ begin }
64
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) started
65
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) started
66
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) was woken up by another thread
67
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) did not wait because the \
68
+ values mismatched` ,
69
+ `${ begin }
70
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) started
71
+ [Thread 0] Atomics.wait(<address> + 4, 0, inf) did not wait because the \
72
+ values mismatched
73
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) started
74
+ [Thread 1] Atomics.wait(<address> + 4, -1, inf) did not wait because the \
75
+ values mismatched`
76
+ ] ;
65
77
66
- assert . strictEqual ( + actual . threadId , expected . threadId ) ;
67
- assert . strictEqual ( + actual . offset , expected . offset ) ;
68
- assert . strictEqual ( + actual . value , expected . value ) ;
69
- assert . strictEqual ( actual . message , expected . message ) ;
70
- if ( expected . timeout === 'inf' )
71
- assert . match ( actual . timeout , / i n f ( i n i t y ) ? / ) ;
72
- else
73
- assert . strictEqual ( actual . timeout , expected . timeout ) ;
74
- }
78
+ assert ( expectedTimelines . includes ( actualTimeline ) ) ;
0 commit comments