Skip to content
This repository
Browse code

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

…kages with invalid names, #108
  • Loading branch information...
commit 5ebd2a0f458c20b7b76c53dc04602fd154da0c0c 1 parent be8df1e
Caolan McMahon authored December 14, 2012
2  lib/logger.js
@@ -105,7 +105,7 @@ exports.error = function (err) {
105 105
     if (err.stack) {
106 106
         msg = err.stack.replace(/^Error: /, '');
107 107
     }
108  
-    console.log(red(bold('Error: ') + msg));
  108
+    console.error(red(bold('Error: ') + msg));
109 109
 };
110 110
 
111 111
 
26  test/integration/test-publish.js
@@ -92,17 +92,27 @@ exports['publish to command-line repo'] = function (test) {
92 92
 exports['publish with invalid .js package name'] = function (test) {
93 93
     test.expect(1);
94 94
     process.chdir('./fixtures/package-three-invalid-extjs');
95  
-    utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
96  
-        test.ok(err);
97  
-        test.done();
98  
-    });
  95
+    utils.runJam(['publish'], {env: ENV, expect_error: true},
  96
+        function (err, stdout, stderr) {
  97
+            if (err) {
  98
+                return test.done(err);
  99
+            }
  100
+            test.ok(/Invalid name property/.test(stderr));
  101
+            test.done();
  102
+        }
  103
+    );
99 104
 };
100 105
 
101 106
 exports['publish with invalid package name characters'] = function (test) {
102 107
     test.expect(1);
103 108
     process.chdir('./fixtures/package-three-invalid-characters');
104  
-    utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
105  
-        test.ok(err);
106  
-        test.done();
107  
-    });
  109
+    utils.runJam(['publish'], {env: ENV, expect_error: true},
  110
+        function (err, stdout, stderr) {
  111
+            if (err) {
  112
+                return test.done(err);
  113
+            }
  114
+            test.ok(/Invalid name property/.test(stderr));
  115
+            test.done();
  116
+        }
  117
+    );
108 118
 };
2  test/utils.js
@@ -22,7 +22,7 @@ exports.runJam = function (args, /*optional*/opts, callback) {
22 22
         stderr += data.toString();
23 23
     });
24 24
     jam.on('exit', function (code) {
25  
-        if (code !== 0) {
  25
+        if (code !== 0 && !opts.expect_error) {
26 26
             console.log(['Jam command failed', args]);
27 27
             console.log(stdout);
28 28
             console.log(stderr);

0 notes on commit 5ebd2a0

Please sign in to comment.
Something went wrong with that request. Please try again.