Permalink
Browse files

test stderr for error messages in integration test for publishing pac…

…kages with invalid names, #108
  • Loading branch information...
caolan committed Dec 14, 2012
1 parent be8df1e commit 5ebd2a0f458c20b7b76c53dc04602fd154da0c0c
Showing with 20 additions and 10 deletions.
  1. +1 −1 lib/logger.js
  2. +18 −8 test/integration/test-publish.js
  3. +1 −1 test/utils.js
View
@@ -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));
};
@@ -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();
+ }
+ );
};
View
@@ -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);

0 comments on commit 5ebd2a0

Please sign in to comment.