(source, count)
| 9 | } |
| 10 | |
| 11 | function produce(source, count) { |
| 12 | count ||= 1; |
| 13 | |
| 14 | const out = spawnSync(process.execPath, [ '-e', ` |
| 15 | 'use strict'; |
| 16 | const assert = require('assert'); |
| 17 | const vm = require('vm'); |
| 18 | |
| 19 | var data; |
| 20 | for (var i = 0; i < ${count}; i++) { |
| 21 | var script = new vm.Script(process.argv[1], { |
| 22 | produceCachedData: true |
| 23 | }); |
| 24 | |
| 25 | assert(!script.cachedDataProduced || script.cachedData instanceof Buffer); |
| 26 | |
| 27 | if (script.cachedDataProduced) |
| 28 | data = script.cachedData.toString('base64'); |
| 29 | } |
| 30 | console.log(data); |
| 31 | `, source]); |
| 32 | |
| 33 | assert.strictEqual(out.status, 0, String(out.stderr)); |
| 34 | |
| 35 | return Buffer.from(out.stdout.toString(), 'base64'); |
| 36 | } |
| 37 | |
| 38 | function testProduceConsume() { |
| 39 | const source = getSource('original'); |
no test coverage detected
searching dependent graphs…