@@ -6,12 +6,6 @@ const tmpdir = require('../common/tmpdir');
66const fs = require ( 'fs' ) ;
77const assert = require ( 'assert' ) ;
88
9- // When the test fails this helper can be modified to write outputs
10- // differently and aid debugging.
11- function log ( line ) {
12- console . log ( line ) ;
13- }
14-
159function generateSnapshot ( ) {
1610 tmpdir . refresh ( ) ;
1711
@@ -21,7 +15,7 @@ function generateSnapshot() {
2115 '--random_seed=42' ,
2216 '--predictable' ,
2317 '--build-snapshot' ,
24- 'node:generate_default_snapshot ' ,
18+ 'node:generate_default_snapshot_source ' ,
2519 ] ,
2620 {
2721 env : { ...process . env , NODE_DEBUG_NATIVE : 'SNAPSHOT_SERDES' } ,
@@ -38,33 +32,10 @@ function generateSnapshot() {
3832 } ,
3933 }
4034 ) ;
41- const blobPath = tmpdir . resolve ( 'snapshot.blob ' ) ;
42- return fs . readFileSync ( blobPath ) ;
35+ const outputPath = tmpdir . resolve ( 'snapshot.cc ' ) ;
36+ return fs . readFileSync ( outputPath , 'utf-8' ) . split ( '\n' ) ;
4337}
4438
45- const buf1 = generateSnapshot ( ) ;
46- const buf2 = generateSnapshot ( ) ;
47-
48- const diff = [ ] ;
49- let offset = 0 ;
50- const step = 16 ;
51- do {
52- const length = Math . min ( buf1 . length - offset , step ) ;
53- const slice1 = buf1 . slice ( offset , offset + length ) . toString ( 'hex' ) ;
54- const slice2 = buf2 . slice ( offset , offset + length ) . toString ( 'hex' ) ;
55- if ( slice1 !== slice2 ) {
56- diff . push ( { offset : '0x' + ( offset ) . toString ( 16 ) , slice1, slice2 } ) ;
57- }
58- offset += length ;
59- } while ( offset < buf1 . length ) ;
60-
61- assert . strictEqual ( offset , buf1 . length ) ;
62- if ( offset < buf2 . length ) {
63- const length = Math . min ( buf2 . length - offset , step ) ;
64- const slice2 = buf2 . slice ( offset , offset + length ) . toString ( 'hex' ) ;
65- diff . push ( { offset, slice1 : '' , slice2 } ) ;
66- offset += length ;
67- } while ( offset < buf2 . length ) ;
68-
69- assert . deepStrictEqual ( diff , [ ] ) ;
70- assert . strictEqual ( buf1 . length , buf2 . length ) ;
39+ const source1 = generateSnapshot ( ) ;
40+ const source2 = generateSnapshot ( ) ;
41+ assert . deepStrictEqual ( source1 , source2 ) ;
0 commit comments