Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

test-domain: fix the test to work on Windows

On Windows, full pathnames are stored in the Error object when
a file i/o error happens. This is not the case on Unix. Before
this fix the test would break because of these full paths.
  • Loading branch information...
piscisaureus committed Jun 19, 2012
1 parent 7a4dfb6 commit 26b11915b1c16440468a4b5f4b07d2409b98c68c
Showing with 18 additions and 3 deletions.
  1. +18 −3 test/simple/test-domain.js
@@ -34,7 +34,22 @@ var e = new events.EventEmitter();

d.on('error', function(er) {
console.error('caught', er);
switch (er.message) {

var er_message = er.message;
var er_path = er.path

// On windows, error messages can contain full path names. If this is the
// case, remove the directory part.
if (typeof er_path === 'string') {
var slash = er_path.lastIndexOf('\\');
if (slash !== -1) {
var dir = er_path.slice(0, slash + 1);
er_path = er_path.replace(dir, '');
er_message = er_message.replace(dir, '');
}
}

switch (er_message) {
case 'emitted':
assert.equal(er.domain, d);
assert.equal(er.domain_emitter, e);
@@ -60,14 +75,14 @@ d.on('error', function(er) {
assert.equal(typeof er.domain_bound, 'function');
assert.ok(!er.domain_emitter);
assert.equal(er.code, 'ENOENT');
assert.equal(er.path, 'this file does not exist');
assert.equal(er_path, 'this file does not exist');
assert.equal(typeof er.errno, 'number');
break;

case "ENOENT, open 'stream for nonexistent file'":
assert.equal(typeof er.errno, 'number');
assert.equal(er.code, 'ENOENT');
assert.equal(er.path, 'stream for nonexistent file');
assert.equal(er_path, 'stream for nonexistent file');
assert.equal(er.domain, d);
assert.equal(er.domain_emitter, fst);
assert.ok(!er.domain_bound);

0 comments on commit 26b1191

Please sign in to comment.
You can’t perform that action at this time.