git ssb

0+

cel-desktop / ssb-pkg



Tree: 65191f9a9664f013ebe726bb95a1a54b086e1bd5

Files: 65191f9a9664f013ebe726bb95a1a54b086e1bd5 / test / test-50-require-main-parent / main.js

2229 bytesRaw
1#!/usr/bin/env node
2
3'use strict';
4
5const path = require('path');
6const assert = require('assert');
7const utils = require('../utils.js');
8
9assert(!module.parent);
10assert(__dirname === process.cwd());
11
12const target = process.argv[2] || 'host';
13const input = './test-x-index.js';
14const output = './run-time/test-output.exe';
15
16let left, right;
17utils.mkdirp.sync(path.dirname(output));
18
19left = utils.spawn.sync(
20 'node', [ path.basename(input) ],
21 { cwd: path.dirname(input) }
22);
23
24utils.pkg.sync([
25 '--target', target,
26 '--output', output, input
27]);
28
29right = utils.spawn.sync(
30 './' + path.basename(output), [],
31 { cwd: path.dirname(output) }
32);
33
34// это директории. под
35// виндой они case-insensitive
36left = left.toLowerCase();
37right = right.toLowerCase();
38
39left = left.split('\n');
40right = right.split('\n');
41
42assert.equal(left.length, right.length);
43assert(left.length > 100);
44
45var nonSnapshot;
46left.some(function (leftValue, index) {
47 const rightValue = right[index];
48 if (leftValue.slice(1, 3) === ':\\') {
49 assert.equal(rightValue.slice(1, 12), ':\\snapshot\\');
50 nonSnapshot = rightValue.length - 12;
51 assert.equal(leftValue.slice(-nonSnapshot),
52 rightValue.slice(-nonSnapshot));
53 } else
54 if (leftValue.slice(0, 1) === '/') {
55 assert.equal(rightValue.slice(0, 10), '/snapshot/');
56 nonSnapshot = rightValue.length - 10;
57 assert.equal(leftValue.slice(-nonSnapshot),
58 rightValue.slice(-nonSnapshot));
59 } else
60 if (leftValue === '') {
61 assert.equal(leftValue, rightValue);
62 } else
63 if (leftValue === 'empty') {
64 assert.equal(leftValue, rightValue);
65 } else
66 if (leftValue === 'string') {
67 assert.equal(leftValue, rightValue);
68 } else
69 if (leftValue === 'object') {
70 assert.equal(leftValue, rightValue);
71 } else
72 if (leftValue === 'function') {
73 assert.equal(leftValue, rightValue);
74 } else
75 if (leftValue === 'true') {
76 assert.equal(leftValue, rightValue);
77 } else
78 if (leftValue === 'false') {
79 assert.equal(leftValue, rightValue);
80 } else
81 if (leftValue === 'null') {
82 assert.equal(leftValue, rightValue);
83 } else {
84 console.log(leftValue, rightValue);
85 assert(false);
86 }
87});
88
89utils.vacuum.sync(path.dirname(output));
90

Built with git-ssb-web