Files: ca90b5ca0579ebdcc0635288bce4978e3fb200f5 / test / test-50-require-main-parent / main.js
2229 bytesRaw
1 | |
2 | |
3 | 'use strict'; |
4 | |
5 | const path = require('path'); |
6 | const assert = require('assert'); |
7 | const utils = require('../utils.js'); |
8 | |
9 | assert(!module.parent); |
10 | assert(__dirname === process.cwd()); |
11 | |
12 | const target = process.argv[2] || 'host'; |
13 | const input = './test-x-index.js'; |
14 | const output = './run-time/test-output.exe'; |
15 | |
16 | let left, right; |
17 | utils.mkdirp.sync(path.dirname(output)); |
18 | |
19 | left = utils.spawn.sync( |
20 | 'node', [ path.basename(input) ], |
21 | { cwd: path.dirname(input) } |
22 | ); |
23 | |
24 | utils.pkg.sync([ |
25 | '--target', target, |
26 | '--output', output, input |
27 | ]); |
28 | |
29 | right = utils.spawn.sync( |
30 | './' + path.basename(output), [], |
31 | { cwd: path.dirname(output) } |
32 | ); |
33 | |
34 | // это директории. под |
35 | // виндой они case-insensitive |
36 | left = left.toLowerCase(); |
37 | right = right.toLowerCase(); |
38 | |
39 | left = left.split('\n'); |
40 | right = right.split('\n'); |
41 | |
42 | assert.equal(left.length, right.length); |
43 | assert(left.length > 100); |
44 | |
45 | var nonSnapshot; |
46 | left.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 | |
89 | utils.vacuum.sync(path.dirname(output)); |
90 |
Built with git-ssb-web