git ssb

0+

cel-desktop / ssb-pkg



Tree: 8f4b43a09aab9801bf28987edd59c2e366180327

Files: 8f4b43a09aab9801bf28987edd59c2e366180327 / test / test-50-fs-runtime-layer-2 / main.js

1730 bytesRaw
1#!/usr/bin/env node
2
3/* eslint-disable no-multi-spaces */
4
5'use strict';
6
7const path = require('path');
8const assert = require('assert');
9const utils = require('../utils.js');
10
11assert(!module.parent);
12assert(__dirname === process.cwd());
13
14const host = 'node' + process.version.match(/^v(\d+)/)[1];
15const target = process.argv[2] || host;
16const input = './test-x-index.js';
17const output = './run-time/test-output.exe';
18
19// see readFromSnapshot "NODE_VERSION_MAJOR"
20
21function bitty (version) {
22 return (2 * (/^(node|v)?4/.test(version))) |
23 (2 * (/^(node|v)?5/.test(version))) |
24 (4 * (/^(node|v)?6/.test(version))) |
25 (4 * (/^(node|v)?7/.test(version))) |
26 (4 * (/^(node|v)?8/.test(version))) |
27 (4 * (/^(node|v)?9/.test(version))) |
28 (8 * (/^(node|v)?10/.test(version))) |
29 (8 * (/^(node|v)?11/.test(version))) |
30 (16 * (/^(node|v)?12/.test(version))) |
31 (16 * (/^(node|v)?13/.test(version))) |
32 (16 * (/^(node|v)?14/.test(version)));
33}
34
35const version1 = process.version;
36const version2 = target;
37if (bitty(version1) !== bitty(version2)) return;
38
39let left, right;
40utils.mkdirp.sync(path.dirname(output));
41
42left = utils.spawn.sync(
43 'node', [ path.basename(input) ],
44 { cwd: path.dirname(input) }
45);
46
47utils.pkg.sync([
48 '--target', target,
49 '--output', output, input
50]);
51
52right = utils.spawn.sync(
53 './' + path.basename(output), [],
54 { cwd: path.dirname(output) }
55);
56
57left = left.split('\n');
58right = right.split('\n');
59// right may have less lines, premature exit,
60// less trusted, so using left.length here
61for (let i = 0; i < left.length; i += 1) {
62 assert.equal(left[i], right[i]);
63}
64
65utils.vacuum.sync(path.dirname(output));
66

Built with git-ssb-web