Remove need for execSync from tests.

This commit is contained in:
Chris Andrews
2013-02-04 20:17:23 +00:00
parent db12131bd3
commit ae94e89b60
2 changed files with 8 additions and 14 deletions
+4 -7
View File
@@ -1,23 +1,20 @@
var test = require('tap').test;
var format = require('util').format;
var dtest = require('./dtrace-test').dtraceTest;
var skip = false;
test(
'probes with json type',
dtest(
function() {
var execSync = require('execSync');
var cmd = ['/usr/sbin/dtrace', '-qn', '\'BEGIN { json("", ""); exit(0); }\''].join(' ');
var code = execSync.code(cmd);
skip = (code == 0) ? false : true;
},
function() { },
[
'dtrace', '-Zqn',
'nodeapp$target:::json1{ this->j = copyinstr(arg0); printf("%s\\n%d\\n%s\\n", this->j, strtoll(json(this->j, "foo")), json(this->j, "bar")) }',
'-c', format('node %s/json-args_fire.js', __dirname)
],
function(t, exit_code, traces) {
// skip if dtrace failed; assume no json() sub
skip = exit_code == 0 ? 0 : 1;
t.test("json tests, need json() subroutine", {"skip": skip}, function (t) {
t.notOk(exit_code, 'dtrace exited cleanly');
t.equal(traces[0], '{"foo":42,"bar":"forty-two"}');
+4 -7
View File
@@ -1,23 +1,20 @@
var test = require('tap').test;
var format = require('util').format;
var dtest = require('./dtrace-test').dtraceTest;
var skip = false;
test(
'probes with multiple json types',
dtest(
function() {
var execSync = require('execSync');
var cmd = ['/usr/sbin/dtrace', '-qn', '\'BEGIN { json("", ""); exit(0); }\''].join(' ');
var code = execSync.code(cmd);
skip = (code == 0) ? false : true;
},
function() { },
[
'dtrace', '-Zqn',
'nodeapp$target:::json1{ printf("%s %s", json(copyinstr(arg0), "value"), json(copyinstr(arg1), "value")) }',
'-c', format('node %s/multiple-json-args_fire.js', __dirname)
],
function(t, exit_code, traces) {
// skip if dtrace failed; assume no json() sub
skip = exit_code == 0 ? 0 : 1;
t.test("json tests, need json() subroutine", {"skip": skip}, function (t) {
t.notOk(exit_code, 'dtrace exited cleanly');
t.equal(traces[0], 'abc def');