common.error() is just deprecated util.error() renamed.
Remove calls to it and some other extraneous console logging
in tests.
PR-URL: https://github.com/nodejs/node/pull/3079
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
// test that empty file will be created and have content added
var filename = join(common.tmpDir, 'append-sync.txt');
-common.error('appending to ' + filename);
fs.appendFileSync(filename, data);
var fileData = fs.readFileSync(filename);
-console.error('filedata is a ' + typeof fileData);
assert.equal(Buffer.byteLength(data), fileData.length);
var filename2 = join(common.tmpDir, 'append-sync2.txt');
fs.writeFileSync(filename2, currentFileData);
-common.error('appending to ' + filename2);
fs.appendFileSync(filename2, data);
var fileData2 = fs.readFileSync(filename2);
var filename3 = join(common.tmpDir, 'append-sync3.txt');
fs.writeFileSync(filename3, currentFileData);
-common.error('appending to ' + filename3);
-
var buf = new Buffer(data, 'utf8');
fs.appendFileSync(filename3, buf);
var filename4 = join(common.tmpDir, 'append-sync4.txt');
fs.writeFileSync(filename4, currentFileData, { mode: m });
-common.error('appending to ' + filename4);
var m = 0o600;
fs.appendFileSync(filename4, num, { mode: m });
//exit logic for cleanup
process.on('exit', function() {
- common.error('done');
-
fs.unlinkSync(filename);
fs.unlinkSync(filename2);
fs.unlinkSync(filename3);
var filename = join(common.tmpDir, 'append.txt');
-common.error('appending to ' + filename);
-
var currentFileData = 'ABCD';
var n = 220;
if (e) throw e;
ncallbacks++;
- common.error('appended to file');
fs.readFile(filename, function(e, buffer) {
if (e) throw e;
- common.error('file read');
ncallbacks++;
assert.equal(Buffer.byteLength(s), buffer.length);
});
if (e) throw e;
ncallbacks++;
- common.error('appended to file2');
fs.readFile(filename2, function(e, buffer) {
if (e) throw e;
- common.error('file2 read');
ncallbacks++;
assert.equal(Buffer.byteLength(s) + currentFileData.length, buffer.length);
});
fs.writeFileSync(filename3, currentFileData);
var buf = new Buffer(s, 'utf8');
-common.error('appending to ' + filename3);
fs.appendFile(filename3, buf, function(e) {
if (e) throw e;
ncallbacks++;
- common.error('appended to file3');
fs.readFile(filename3, function(e, buffer) {
if (e) throw e;
- common.error('file3 read');
ncallbacks++;
assert.equal(buf.length + currentFileData.length, buffer.length);
});
var filename4 = join(common.tmpDir, 'append4.txt');
fs.writeFileSync(filename4, currentFileData);
-common.error('appending to ' + filename4);
-
var m = 0o600;
fs.appendFile(filename4, n, { mode: m }, function(e) {
if (e) throw e;
ncallbacks++;
- common.error('appended to file4');
// windows permissions aren't unix
if (!common.isWindows) {
fs.readFile(filename4, function(e, buffer) {
if (e) throw e;
- common.error('file4 read');
ncallbacks++;
assert.equal(Buffer.byteLength('' + n) + currentFileData.length,
buffer.length);
});
process.on('exit', function() {
- common.error('done');
assert.equal(8, ncallbacks);
fs.unlinkSync(filename);
var file = path.join(common.fixturesDir, 'a.js');
-common.error('open ' + file);
-
fs.open(file, 'a', 0o777, function(err, fd) {
- common.error('fd ' + fd);
if (err) throw err;
fs.fdatasyncSync(fd);
- common.error('fdatasync SYNC: ok');
successes++;
fs.fsyncSync(fd);
- common.error('fsync SYNC: ok');
successes++;
fs.fdatasync(fd, function(err) {
if (err) throw err;
- common.error('fdatasync ASYNC: ok');
successes++;
fs.fsync(fd, function(err) {
if (err) throw err;
- common.error('fsync ASYNC: ok');
successes++;
});
});
var filename = join(common.tmpDir, 'test.txt');
-common.error('writing to ' + filename);
-
var n = 220;
var s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
'广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
if (e) throw e;
ncallbacks++;
- common.error('file written');
fs.readFile(filename, function(e, buffer) {
if (e) throw e;
- common.error('file read');
ncallbacks++;
assert.equal(Buffer.byteLength(s), buffer.length);
});
// test that writeFile accepts buffers
var filename2 = join(common.tmpDir, 'test2.txt');
var buf = new Buffer(s, 'utf8');
-common.error('writing to ' + filename2);
fs.writeFile(filename2, buf, function(e) {
if (e) throw e;
ncallbacks++;
- common.error('file2 written');
fs.readFile(filename2, function(e, buffer) {
if (e) throw e;
- common.error('file2 read');
ncallbacks++;
assert.equal(buf.length, buffer.length);
});
// test that writeFile accepts numbers.
var filename3 = join(common.tmpDir, 'test3.txt');
-common.error('writing to ' + filename3);
var m = 0o600;
fs.writeFile(filename3, n, { mode: m }, function(e) {
}
ncallbacks++;
- common.error('file3 written');
fs.readFile(filename3, function(e, buffer) {
if (e) throw e;
- common.error('file3 read');
ncallbacks++;
assert.equal(Buffer.byteLength('' + n), buffer.length);
});
process.on('exit', function() {
- common.error('done');
assert.equal(6, ncallbacks);
fs.unlinkSync(filename);
function(err, stdout, stderr) {
if (err) throw err;
s.close();
- common.error('curled response correctly');
- common.error(common.inspect(stdout));
});
});
-
-console.log('Server running at http://127.0.0.1:' + common.PORT + '/');
var gotReq = false;
var server = http.createServer(function(req, res) {
- common.error('got req');
gotReq = true;
assert.equal('GET', req.method);
assert.equal('/blah', req.url);
var c = net.createConnection(common.PORT);
c.on('connect', function() {
- common.error('client wrote message');
c.write('GET /blah HTTP/1.1\r\n' +
'Host: mapdevel.trolologames.ru:443\r\n' +
'Cookie:\r\n' +
});
c.on('close', function() {
- common.error('client close');
server.close();
});
});
req.write(new Buffer(N));
req.end();
-
- common.error('client finished sending request');
});
process.on('exit', function() {
req.write('2\n');
req.write('3\n');
req.end();
-
- common.error('client finished sending request');
});
process.on('exit', function() {
method: 'HEAD',
path: '/'
}, function(res) {
- common.error('response');
res.on('end', function() {
- common.error('response end');
server.close();
responseComplete = true;
});
res.resume();
});
- common.error('req');
req.end();
});
method: 'HEAD',
path: '/'
}, function(res) {
- common.error('response');
res.on('end', function() {
- common.error('response end');
server.close();
responseComplete = true;
});
res.resume();
});
- common.error('req');
req.end();
});
var http = require('http');
var url = require('url');
-function p(x) {
- common.error(common.inspect(x));
-}
-
var responses_sent = 0;
var responses_recvd = 0;
var body0 = '';
responses_sent += 1;
});
req.resume();
-
- //assert.equal('127.0.0.1', res.connection.remoteAddress);
});
server.listen(common.PORT, function() {
}
if (req.id == 1) {
- common.error('req 1');
assert.equal('POST', req.method);
assert.equal('/quit', url.parse(req.url).pathname);
}
if (req.id == 2) {
- common.error('req 2');
assert.equal('foo', req.headers['x-x']);
}
if (req.id == 3) {
- common.error('req 3');
assert.equal('bar', req.headers['x-x']);
this.close();
- common.error('server closed');
}
setTimeout(function() {
var net = require('net');
var server = http.createServer(function(req, res) {
- common.error('got req');
throw new Error('This shouldn\'t happen.');
});
server.on('upgrade', function(req, socket, upgradeHead) {
- common.error('got upgrade event');
// test that throwing an error from upgrade gets
// is uncaught
throw new Error('upgrade error');
var gotError = false;
process.on('uncaughtException', function(e) {
- common.error('got \'clientError\' event');
assert.equal('upgrade error', e.message);
gotError = true;
process.exit(0);
var c = net.createConnection(common.PORT);
c.on('connect', function() {
- common.error('client wrote message');
c.write('GET /blah HTTP/1.1\r\n' +
'Upgrade: WebSocket\r\n' +
'Connection: Upgrade\r\n' +
});
c.on('close', function() {
- common.error('client close');
server.close();
});
});
res.on('data', function(chunk) {
response += chunk;
});
- common.error('Got /hello response');
});
});
var http = require('http');
var url = require('url');
-function p(x) {
- common.error(common.inspect(x));
-}
-
var responses_sent = 0;
var responses_recvd = 0;
var body0 = '';
for (var i = 255; i >= 0; i--) {
var s = '\'\\' + i.toString(8) + '\'';
var S = eval(s);
- common.error(s +
- ' ' +
- JSON.stringify(S) +
- ' ' +
- JSON.stringify(String.fromCharCode(i)) +
- ' ' +
- S.charCodeAt(0));
assert.ok(S.charCodeAt(0) == i);
assert.ok(S == String.fromCharCode(i));
binaryString += S;
// safe constructor
var echoServer = net.Server(function(connection) {
- console.error('SERVER got connection');
connection.setEncoding('binary');
connection.on('data', function(chunk) {
- common.error('SERVER recved: ' + JSON.stringify(chunk));
connection.write(chunk, 'binary');
});
connection.on('end', function() {
- console.error('SERVER ending');
connection.end();
});
});
var recv = '';
echoServer.on('listening', function() {
- console.error('SERVER listening');
var j = 0;
var c = net.createConnection({
port: common.PORT
c.setEncoding('binary');
c.on('data', function(chunk) {
- console.error('CLIENT data %j', chunk);
var n = j + chunk.length;
while (j < n && j < 256) {
- common.error('CLIENT write ' + j);
c.write(String.fromCharCode(j), 'binary');
j++;
}
if (j === 256) {
- console.error('CLIENT ending');
c.end();
}
recv += chunk;
});
c.on('connect', function() {
- console.error('CLIENT connected, writing');
c.write(binaryString, 'binary');
});
c.on('close', function() {
- console.error('CLIENT closed');
- console.dir(recv);
echoServer.close();
});
-
- c.on('finish', function() {
- console.error('CLIENT finished');
- });
});
process.on('exit', function() {
- console.log('recv: ' + JSON.stringify(recv));
-
assert.equal(2 * 256, recv.length);
var a = recv.split('');
var first = a.slice(0, 256).reverse().join('');
- console.log('first: ' + JSON.stringify(first));
var second = a.slice(256, 2 * 256).join('');
- console.log('second: ' + JSON.stringify(second));
assert.equal(first, second);
});
var count = 0;
var server = http.createServer(function(req, res) {
- console.error('SERVER request');
var timeoutId;
assert.equal('POST', req.method);
req.pause();
- common.error('request paused');
setTimeout(function() {
req.resume();
- common.error('request resumed');
}, 1000);
req.on('data', function(chunk) {
- common.error('recv data! nchars = ' + chunk.length);
count += chunk.length;
});
if (timeoutId) {
clearTimeout(timeoutId);
}
- console.log('request complete from server');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
});
server.on('listening', function() {
var cmd = common.ddCommand(filename, 10240);
- console.log('dd command: ', cmd);
cp.exec(cmd, function(err, stdout, stderr) {
if (err) throw err;
- console.error('EXEC returned successfully stdout=%d stderr=%d',
- stdout.length, stderr.length);
makeRequest();
});
});
method: 'POST'
});
- common.error('pipe!');
-
var s = fs.ReadStream(filename);
s.pipe(req);
- s.on('data', function(chunk) {
- console.error('FS data chunk=%d', chunk.length);
- });
- s.on('end', function() {
- console.error('FS end');
- });
s.on('close', function(err) {
if (err) throw err;
clientReqComplete = true;
- common.error('client finished sending request');
});
req.on('response', function(res) {
- console.error('RESPONSE', res.statusCode, res.headers);
res.resume();
res.on('end', function() {
- console.error('RESPONSE end');
server.close();
});
});
var conn_closed = false;
var server = net.createServer(function(stream) {
- common.error('pump!');
util.pump(fs.createReadStream(fn), stream, function(err) {
- common.error('util.pump\'s callback fired');
if (err) {
got_error = true;
} else {
- console.error('util.pump\'s callback fired with no error');
- console.error('this shouldn\'t happen as the file doesn\'t exist...');
+ // util.pump's callback fired with no error
+ // this shouldn't happen as the file doesn't exist...
assert.equal(true, false);
}
server.close();
var conn = net.createConnection(common.PORT);
conn.setEncoding('utf8');
conn.on('data', function(chunk) {
- common.error('recv data! nchars = ' + chunk.length);
buffer += chunk;
});
});
conn.on('close', function() {
- common.error('client connection close');
conn_closed = true;
});
});
process.on('exit', function() {
assert.equal(true, got_error);
assert.equal(true, conn_closed);
- console.log('exiting');
});
var expected = fs.readFileSync(fn, 'utf8');
var server = net.createServer(function(stream) {
- common.error('pump!');
util.pump(fs.createReadStream(fn), stream, function() {
- common.error('server stream close');
- common.error('server close');
server.close();
});
});
var conn = net.createConnection(common.PORT);
conn.setEncoding('utf8');
conn.on('data', function(chunk) {
- common.error('recv data! nchars = ' + chunk.length);
buffer += chunk;
});
conn.on('end', function() {
conn.end();
});
- conn.on('close', function() {
- common.error('client connection close');
- });
});
var buffer = '';