1 | var test = require('tap').test;
|
2 | var exec = require('child_process').exec;
|
3 |
|
4 | var browserify = require('browserify');
|
5 | var path = require('path');
|
6 | var vm = require('vm');
|
7 | var fs = require('fs');
|
8 |
|
9 | var text = fs.readFileSync(__dirname + '/files/separators.txt', 'utf8');
|
10 |
|
11 | test('run file with special unicode separators', function (t) {
|
12 | t.plan(1);
|
13 | exec(__dirname + '/../bin/cmd.js ' + __dirname + '/files/separators.js',
|
14 | function (error, stdout, stderr) {
|
15 | if (error !== null) {
|
16 | t.fail();
|
17 | } else {
|
18 | vm.runInNewContext(stdout, {
|
19 | require: function () {},
|
20 | console: { log: log }
|
21 | });
|
22 | function log (msg) {
|
23 | t.equal(text, msg);
|
24 | };
|
25 | };
|
26 | }
|
27 | );
|
28 | });
|
29 |
|
30 | test('bundle file with special unicode separators', function (t) {
|
31 | t.plan(1);
|
32 |
|
33 | var b = browserify();
|
34 | b.add(__dirname + '/files/separators.js');
|
35 | b.transform(path.dirname(__dirname));
|
36 |
|
37 | b.bundle(function (err, src) {
|
38 | if (err) t.fail(err);
|
39 | vm.runInNewContext(src, { console: { log: log } });
|
40 | });
|
41 |
|
42 | function log (msg) {
|
43 | t.equal(text, msg);
|
44 | }
|
45 | });
|