1 | var test = require('tap').test;
|
2 | var exec = require('child_process').exec;
|
3 |
|
4 | var vm = require('vm');
|
5 | var fs = require('fs');
|
6 |
|
7 | var html = fs.readFileSync(__dirname + '/files/robot.html', 'utf8');
|
8 |
|
9 | test('cmd.js', function (t) {
|
10 | t.plan(1);
|
11 | exec(__dirname + '/../bin/cmd.js ' + __dirname + '/files/main.js',
|
12 | function (error, stdout, stderr) {
|
13 | if (error !== null) {
|
14 | t.fail();
|
15 | } else {
|
16 | vm.runInNewContext(stdout, {
|
17 | require: function () {},
|
18 | console: { log: log }
|
19 | });
|
20 | function log (msg) {
|
21 | t.equal(html, msg);
|
22 | };
|
23 | };
|
24 | }
|
25 | );
|
26 | }); |
\ | No newline at end of file |