| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f989fdc commit a0a8c96
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1382,6 +1382,21 @@ ExitCode GenerateAndWriteSnapshotData(const SnapshotData** snapshot_data_ptr, | |||
| 1382 | 1382 | DCHECK(snapshot_config.builder_script_path.has_value()); | |
| 1383 | 1383 | const std::string& builder_script = | |
| 1384 | 1384 | snapshot_config.builder_script_path.value(); | |
| 1385 | + | ||
| 1386 | + // For the special builder node:generate_default_snapshot_source, generate | ||
| 1387 | + // the snapshot as C++ source and write it to snapshot.cc (for testing). | ||
| 1388 | + if (builder_script == "node:generate_default_snapshot_source") { | ||
| 1389 | + // Reset to empty to generate from scratch. | ||
| 1390 | + snapshot_config.builder_script_path = {}; | ||
| 1391 | + exit_code = | ||
| 1392 | + node::SnapshotBuilder::GenerateAsSource("snapshot.cc", | ||
| 1393 | + args_maybe_patched, | ||
| 1394 | + result->exec_args(), | ||
| 1395 | + snapshot_config, | ||
| 1396 | + true /* use_array_literals */); | ||
| 1397 | + return exit_code; | ||
| 1398 | + } | ||
| 1399 | + | ||
| 1385 | 1400 | // node:embedded_snapshot_main indicates that we are using the | |
| 1386 | 1401 | // embedded snapshot and we are not supposed to clean it up. | |
| 1387 | 1402 | if (builder_script == "node:embedded_snapshot_main") { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ function generateSnapshot() { | |||
| 21 | 21 | '--random_seed=42', | |
| 22 | 22 | '--predictable', | |
| 23 | 23 | '--build-snapshot', | |
| 24 | - 'node:generate_default_snapshot', | ||
| 24 | + 'node:generate_default_snapshot_source', | ||
| 25 | 25 | ], | |
| 26 | 26 | { | |
| 27 | 27 | env: { ...process.env, NODE_DEBUG_NATIVE: 'SNAPSHOT_SERDES' }, | |
@@ -38,33 +38,10 @@ function generateSnapshot() { | |||
| 38 | 38 | }, | |
| 39 | 39 | } | |
| 40 | 40 | ); | |
| 41 | - const blobPath = tmpdir.resolve('snapshot.blob'); | ||
| 42 | - return fs.readFileSync(blobPath); | ||
| 41 | + const outputPath = tmpdir.resolve('snapshot.cc'); | ||
| 42 | + return fs.readFileSync(outputPath, 'utf-8').split('\n'); | ||
| 43 | 43 | } | |
| 44 | 44 | ||
| 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); | ||
| 45 | + const source1 = generateSnapshot(); | ||
| 46 | + const source2 = generateSnapshot(); | ||
| 47 | + assert.deepStrictEqual(source1, source2); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments