File tree Expand file tree Collapse file tree 3 files changed +38
-22
lines changed Expand file tree Collapse file tree 3 files changed +38
-22
lines changed Original file line number Diff line number Diff line change @@ -190,13 +190,13 @@ is provided below for reference.
190190 "details" : " "
191191 },
192192 {
193- "repeat" : 0 ,
194- "firesInMsFromNow" : 94403548320796 ,
195- "expired" : true ,
196193 "type" : " timer" ,
197194 "is_active" : false ,
198195 "is_referenced" : false ,
199- "address" : " 0x00007fff5fbfeab0"
196+ "address" : " 0x00007fff5fbfeab0" ,
197+ "repeat" : 0 ,
198+ "firesInMsFromNow" : 94403548320796 ,
199+ "expired" : true
200200 },
201201 {
202202 "type" : " check" ,
@@ -229,36 +229,36 @@ is provided below for reference.
229229 "address" : " 0x000000010188f2e0"
230230 },
231231 {
232+ "type" : " tty" ,
233+ "is_active" : false ,
234+ "is_referenced" : true ,
235+ "address" : " 0x000055b581db0e18" ,
232236 "width" : 204 ,
233237 "height" : 55 ,
234238 "fd" : 17 ,
235239 "writeQueueSize" : 0 ,
236240 "readable" : true ,
237- "writable" : true ,
238- "type" : " tty" ,
239- "is_active" : false ,
240- "is_referenced" : true ,
241- "address" : " 0x000055b581db0e18"
241+ "writable" : true
242242 },
243243 {
244- "signum" : 28 ,
245- "signal" : " SIGWINCH" ,
246244 "type" : " signal" ,
247245 "is_active" : true ,
248246 "is_referenced" : false ,
249- "address" : " 0x000055b581d80010"
247+ "address" : " 0x000055b581d80010" ,
248+ "signum" : 28 ,
249+ "signal" : " SIGWINCH"
250250 },
251251 {
252+ "type" : " tty" ,
253+ "is_active" : true ,
254+ "is_referenced" : true ,
255+ "address" : " 0x000055b581df59f8" ,
252256 "width" : 204 ,
253257 "height" : 55 ,
254258 "fd" : 19 ,
255259 "writeQueueSize" : 0 ,
256260 "readable" : true ,
257- "writable" : true ,
258- "type" : " tty" ,
259- "is_active" : true ,
260- "is_referenced" : true ,
261- "address" : " 0x000055b581df59f8"
261+ "writable" : true
262262 },
263263 {
264264 "type" : " loop" ,
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ void WalkHandle(uv_handle_t* h, void* arg) {
126126 uv_any_handle* handle = reinterpret_cast <uv_any_handle*>(h);
127127
128128 writer->json_start ();
129+ writer->json_keyvalue (" type" , type);
130+ writer->json_keyvalue (" is_active" , static_cast <bool >(uv_is_active (h)));
131+ writer->json_keyvalue (" is_referenced" , static_cast <bool >(uv_has_ref (h)));
132+ writer->json_keyvalue (" address" ,
133+ ValueToHexString (reinterpret_cast <uint64_t >(h)));
129134
130135 switch (h->type ) {
131136 case UV_FS_EVENT:
@@ -216,11 +221,6 @@ void WalkHandle(uv_handle_t* h, void* arg) {
216221 static_cast <bool >(uv_is_writable (&handle->stream )));
217222 }
218223
219- writer->json_keyvalue (" type" , type);
220- writer->json_keyvalue (" is_active" , static_cast <bool >(uv_is_active (h)));
221- writer->json_keyvalue (" is_referenced" , static_cast <bool >(uv_has_ref (h)));
222- writer->json_keyvalue (" address" ,
223- ValueToHexString (reinterpret_cast <uint64_t >(h)));
224224 writer->json_end ();
225225}
226226
Original file line number Diff line number Diff line change @@ -97,6 +97,22 @@ if (process.argv[2] === 'child') {
9797 const reports = helper . findReports ( child . pid , tmpdir . path ) ;
9898 assert . deepStrictEqual ( reports , [ ] , report_msg , reports ) ;
9999
100+ // Test libuv handle key order
101+ {
102+ const get_libuv = / " l i b u v " : \s \[ ( [ \s \S ] * ?) \] / gm;
103+ const get_handle_inner = / { ( [ \s \S ] * ?) , * ?} / gm;
104+ const libuv_handles_str = get_libuv . exec ( stdout ) [ 1 ] ;
105+ const libuv_handles_array = libuv_handles_str . match ( get_handle_inner ) ;
106+ for ( const i of libuv_handles_array ) {
107+ // Exclude nested structure
108+ if ( i . includes ( 'type' ) ) {
109+ const handle_keys = i . match ( / ( " .* " ) : / gm) ;
110+ assert ( handle_keys [ 0 ] , 'type' ) ;
111+ assert ( handle_keys [ 1 ] , 'is_active' ) ;
112+ }
113+ }
114+ }
115+
100116 const report = JSON . parse ( stdout ) ;
101117 const prefix = common . isWindows ? '\\\\?\\' : '' ;
102118 const expected_filename = `${ prefix } ${ __filename } ` ;
You can’t perform that action at this time.
0 commit comments