Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const assert = require('assert');
const os = require('os');
var pid = os.fork();
if (pid == 0) {
// child
os.exit(42);
} else {
// parent
var r = os.waitpid(pid);
assert.equal(r.pid, pid);
assert(os.WIFEXITED(r.status));
assert.equal(os.WEXITSTATUS(r.status), 42);
}
exports.testHaltOptions = function () {
var parser = Parser();
var options = parser.parse(['command', '--', '-svalue']);
assert.eq(undefined, options.set);
assert.eq(['-svalue'], options.args);
};
exports.testNoSuchOption = function () {
var parser = Parser();
assert.throwsError(function () {
parser.parse(['command', '--no-such-option']);
}, test.Exit)
};
if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
assert['throws'](makeBlock(thrower, TypeError));
//when passing a type, only catch errors of the appropriate type
var threw = false;
try {
assert['throws'](makeBlock(thrower, TypeError), assert.AssertionError);
} catch (e) {
threw = true;
assert.ok(e instanceof TypeError, 'type');
}
assert.ok(threw, 'assert.throws with an explicit error is eating extra errors', assert.AssertionError);
threw = false;
};
if (module === require.main)
require("os").exit(require("test").run(exports));
["/foo/bar/baz", "/foo/bar/quux/baz", "quux/baz"],
["/foo/bar/baz", "/foo/quux/baz", "../quux/baz"]
], function (from, to, expected) {
exports[
'testRelative ' +
'from: ' + util.repr(from) + ' ' +
'to: ' + util.repr(to) + ' ' +
'is: ' + util.repr(expected)
] = function () {
var actual = uri.relative(from, to);
assert.eq(expected, actual);
};
});
if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
exports.testNormalTemplate = require("./normal-template-tests");
exports.testNormalTPP = require("./normal-template/tpp-tests");
if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
var encoded = 'T25jZSB1cG9uIGEgdGltZSwgaW4gYSBmYXIgYXdheSBsYW5kLgo=';
exports.testEncode = function () {
assert.eq(base64.encode(raw), encoded, 'encoded');
};
exports.testDecode = function () {
assert.eq(base64.decode(encoded), raw, 'decoded');
};
exports.testEncodeDecode = function () {
assert.eq(base64.decode(base64.encode(raw)), raw, 'encode decode identity');
};
if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
exports.testCommunicateStdout = function () {
assert.eq("hi\n", os.popen("echo hi").communicate().stdout.read());
assert.eq("hi\n", os.popen("cat").communicate("hi").stdout.read());
};
exports.testCommunicateStderr = function () {
assert.eq("hi\n", os.popen("echo hi >&2").communicate().stderr.read());
};
exports.testCommunicateStdin = function () {
assert.eq("", os.popen("exit 0").communicate("hi").stdin.read());
};
if (require.main == module.id)
os.exit(require("test/runner").run(exports));
function handleError(err) {
console.error(err);
os.exit(1);
}
if (shouldCheckSyntax)
{
try
{
new Function(GET_CODE(fragment));
}
catch (e)
{
var lines = code.split("\n"),
PAD = 3;
print("Syntax error in "+GET_FILE(fragment).path+
" on preprocessed line number "+e.lineNumber+"\n"+
"\t"+lines.slice(Math.max(0, e.lineNumber - 1 - PAD), e.lineNumber+PAD).join("\n\t"));
OS.exit(1);
}
}
if (shouldCompress)
{
code = compress("function(){" + code + '}', FILE.basename(aFilePath));
code = code.substr("function(){".length, code.length - "function(){};\n\n".length);
}
preprocessed += MARKER_CODE + ';' + code.length + ';' + code;
}
}
return preprocessed;
}
directories.forEach(function(/*String*/ aDirectory) {
if (FILE.isDirectory(aDirectory)) {
if (OS.system("cd " + OS.enquote(aDirectory) + " && " + serializeEnv(env) + " jake " + OS.enquote(aTaskName)))
OS.exit(1);
}
});
}