Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Commit

Permalink
test stderr for error messages in integration test for publishing pac…
Browse files Browse the repository at this point in the history
…kages with invalid names, #108
  • Loading branch information
Caolan McMahon committed Dec 14, 2012
1 parent be8df1e commit 5ebd2a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports.error = function (err) {
if (err.stack) {
msg = err.stack.replace(/^Error: /, '');
}
console.log(red(bold('Error: ') + msg));
console.error(red(bold('Error: ') + msg));
};


Expand Down
26 changes: 18 additions & 8 deletions test/integration/test-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,27 @@ exports['publish to command-line repo'] = function (test) {
exports['publish with invalid .js package name'] = function (test) {
test.expect(1);
process.chdir('./fixtures/package-three-invalid-extjs');
utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
test.ok(err);
test.done();
});
utils.runJam(['publish'], {env: ENV, expect_error: true},
function (err, stdout, stderr) {
if (err) {
return test.done(err);
}
test.ok(/Invalid name property/.test(stderr));
test.done();
}
);
};

exports['publish with invalid package name characters'] = function (test) {
test.expect(1);
process.chdir('./fixtures/package-three-invalid-characters');
utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
test.ok(err);
test.done();
});
utils.runJam(['publish'], {env: ENV, expect_error: true},
function (err, stdout, stderr) {
if (err) {
return test.done(err);
}
test.ok(/Invalid name property/.test(stderr));
test.done();
}
);
};
2 changes: 1 addition & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports.runJam = function (args, /*optional*/opts, callback) {
stderr += data.toString();
});
jam.on('exit', function (code) {
if (code !== 0) {
if (code !== 0 && !opts.expect_error) {
console.log(['Jam command failed', args]);
console.log(stdout);
console.log(stderr);
Expand Down

0 comments on commit 5ebd2a0

Please sign in to comment.