Browse Source

tests: fix more lint issues

v0.7.4-release
Bert Belder 13 years ago
parent
commit
892056bf97
  1. 2
      test/common.js
  2. 15
      test/simple/test-child-process-double-pipe.js
  3. 16
      test/simple/test-executable-path.js
  4. 6
      test/simple/test-http-1.0.js
  5. 8
      test/simple/test-path-makelong.js
  6. 101
      test/simple/test-repl-tab-complete.js
  7. 6
      test/simple/test-script-context.js
  8. 2
      test/simple/test-stdin-child-proc.js

2
test/common.js

@ -55,7 +55,7 @@ exports.indirectInstanceOf = function(obj, cls) {
exports.ddCommand = function(filename, kilobytes) { exports.ddCommand = function(filename, kilobytes) {
if (process.platform == 'win32') { if (process.platform == 'win32') {
return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir, return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir,
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024); 'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
} else { } else {
return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes;
} }

15
test/simple/test-child-process-double-pipe.js

@ -28,11 +28,16 @@ var assert = require('assert'),
// We're trying to reproduce: // We're trying to reproduce:
// $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/ // $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/
var echo = is_windows ? spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo', var grep = spawn('grep', ['o']),
'node&&', 'echo', 'and&&', 'echo', 'world']) : sed = spawn('sed', ['s/o/O/']),
spawn('echo', ['hello\nnode\nand\nworld\n']), echo;
grep = spawn('grep', ['o']),
sed = spawn('sed', ['s/o/O/']); if (is_windows) {
echo = spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo',
'node&&', 'echo', 'and&&', 'echo', 'world']);
} else {
echo = spawn('echo', ['hello\nnode\nand\nworld\n']);
}
/* /*
* grep and sed hang if the spawn function leaks file descriptors to child * grep and sed hang if the spawn function leaks file descriptors to child

16
test/simple/test-executable-path.js

@ -26,14 +26,14 @@ var match = false;
var isDebug = process.features.debug; var isDebug = process.features.debug;
var debugPaths = [ path.normalize(path.join(__dirname, '..', '..', var debugPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Debug', 'node')), 'out', 'Debug', 'node')),
path.normalize(path.join(__dirname, '..', '..', path.normalize(path.join(__dirname, '..', '..',
'Debug', 'node'))]; 'Debug', 'node'))];
var defaultPaths = [ path.normalize(path.join(__dirname, '..', '..', var defaultPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Release', 'node')), 'out', 'Release', 'node')),
path.normalize(path.join(__dirname, '..', '..', path.normalize(path.join(__dirname, '..', '..',
'Release', 'node'))]; 'Release', 'node'))];
console.error('debugPaths: ' + debugPaths); console.error('debugPaths: ' + debugPaths);
console.error('defaultPaths: ' + defaultPaths); console.error('defaultPaths: ' + defaultPaths);

6
test/simple/test-http-1.0.js

@ -112,7 +112,8 @@ function test(handler, request_generator, response_validator) {
function request_generator() { function request_generator() {
return ('GET / HTTP/1.0\r\n' + return ('GET / HTTP/1.0\r\n' +
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 ' +
'OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
'Host: 127.0.0.1:1337\r\n' + 'Host: 127.0.0.1:1337\r\n' +
'Accept: */*\r\n' + 'Accept: */*\r\n' +
'\r\n'); '\r\n');
@ -147,7 +148,8 @@ function test(handler, request_generator, response_validator) {
function request_generator() { function request_generator() {
return ('GET / HTTP/1.1\r\n' + return ('GET / HTTP/1.1\r\n' +
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 ' +
'OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
'Connection: close\r\n' + 'Connection: close\r\n' +
'Host: 127.0.0.1:1337\r\n' + 'Host: 127.0.0.1:1337\r\n' +
'Accept: */*\r\n' + 'Accept: */*\r\n' +

8
test/simple/test-path-makelong.js

@ -26,13 +26,13 @@ if (process.platform === 'win32') {
var file = path.join(common.fixturesDir, 'a.js'); var file = path.join(common.fixturesDir, 'a.js');
var resolvedFile = path.resolve(file); var resolvedFile = path.resolve(file);
var networkFile = '\\\\someserver\\someshare\\somefile';
assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file)); assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file));
assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file)); assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\someserver\\someshare\\somefile')); path._makeLong('\\\\someserver\\someshare\\somefile'));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile')); path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile'));
assert.equal('\\\\.\\pipe\\somepipe', path._makeLong('\\\\.\\pipe\\somepipe')); assert.equal('\\\\.\\pipe\\somepipe',
path._makeLong('\\\\.\\pipe\\somepipe'));
} }

101
test/simple/test-repl-tab-complete.js

@ -26,9 +26,9 @@ var repl = require('repl');
// A stream to push an array into a REPL // A stream to push an array into a REPL
function ArrayStream() { function ArrayStream() {
this.run = function (data) { this.run = function(data) {
var self = this; var self = this;
data.forEach(function (line) { data.forEach(function(line) {
self.emit('data', line); self.emit('data', line);
}); });
} }
@ -36,11 +36,11 @@ function ArrayStream() {
util.inherits(ArrayStream, require('stream').Stream); util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true; ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true; ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function () {}; ArrayStream.prototype.resume = function() {};
ArrayStream.prototype.write = function () {}; ArrayStream.prototype.write = function() {};
var works = [ [ 'inner.one' ], 'inner.o' ]; var works = [['inner.one'], 'inner.o'];
var doesNotBreak = [ [], 'inner.o' ]; var doesNotBreak = [[], 'inner.o'];
var putIn = new ArrayStream(); var putIn = new ArrayStream();
var testMe = repl.start('', putIn); var testMe = repl.start('', putIn);
@ -49,14 +49,15 @@ var testMe = repl.start('', putIn);
putIn.run(['.clear']); putIn.run(['.clear']);
putIn.run([ putIn.run([
'var inner = {', 'var inner = {',
'one:1']); 'one:1'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });
// Tab Complete will return globaly scoped variables // Tab Complete will return globaly scoped variables
putIn.run(['};']); putIn.run(['};']);
testMe.complete('inner.o', function (error, data) { testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works); assert.deepEqual(data, works);
}); });
@ -66,8 +67,9 @@ putIn.run(['.clear']);
putIn.run([ putIn.run([
'var inner = ( true ' , 'var inner = ( true ' ,
'?', '?',
'{one: 1} : ']); '{one: 1} : '
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });
@ -76,15 +78,16 @@ putIn.run(['.clear']);
// Tab Complete will return a simple local variable // Tab Complete will return a simple local variable
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'var inner = {one:1};']); 'var inner = {one:1};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works); assert.deepEqual(data, works);
}); });
// When you close the function scope tab complete will not return the // When you close the function scope tab complete will not return the
// locally scoped variable // locally scoped variable
putIn.run(['};']); putIn.run(['};']);
testMe.complete('inner.o', function (error, data) { testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });
@ -93,10 +96,11 @@ putIn.run(['.clear']);
// Tab Complete will return a complex local variable // Tab Complete will return a complex local variable
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works); assert.deepEqual(data, works);
}); });
@ -106,10 +110,11 @@ putIn.run(['.clear']);
// has paramaters // has paramaters
putIn.run([ putIn.run([
'var top = function (one, two) {', 'var top = function (one, two) {',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works); assert.deepEqual(data, works);
}); });
@ -119,11 +124,12 @@ putIn.run(['.clear']);
// scope is nested inside an immediately executed function // scope is nested inside an immediately executed function
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'(function test () {', '(function test () {',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works); assert.deepEqual(data, works);
}); });
@ -133,12 +139,13 @@ putIn.run(['.clear']);
// def has the params and { on a seperate line // def has the params and { on a seperate line
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'r = function test (', 'r = function test (',
' one, two) {', ' one, two) {',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });
@ -147,12 +154,13 @@ putIn.run(['.clear']);
// currently does not work, but should not break, not the { // currently does not work, but should not break, not the {
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'r = function test ()', 'r = function test ()',
'{', '{',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });
@ -161,13 +169,14 @@ putIn.run(['.clear']);
// currently does not work, but should not break // currently does not work, but should not break
putIn.run([ putIn.run([
'var top = function () {', 'var top = function () {',
'r = function test (', 'r = function test (',
')', ')',
'{', '{',
'var inner = {', 'var inner = {',
' one:1', ' one:1',
'};']); '};'
testMe.complete('inner.o', function (error, data) { ]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak); assert.deepEqual(data, doesNotBreak);
}); });

6
test/simple/test-script-context.js

@ -54,9 +54,11 @@ try {
} }
catch (e) { catch (e) {
gh1140Exception = e; gh1140Exception = e;
assert.ok(/expected-filename/.test(e.stack), 'expected appearance of filename in Error stack'); assert.ok(/expected-filename/.test(e.stack),
'expected appearance of filename in Error stack');
} }
assert.ok(gh1140Exception, 'expected exception from runInContext signature test'); assert.ok(gh1140Exception,
'expected exception from runInContext signature test');
// GH-558, non-context argument segfaults / raises assertion // GH-558, non-context argument segfaults / raises assertion
function isTypeError(o) { function isTypeError(o) {

2
test/simple/test-stdin-child-proc.js

@ -24,4 +24,4 @@
var child_process = require('child_process'); var child_process = require('child_process');
var path = require('path'); var path = require('path');
child_process.spawn(process.execPath, child_process.spawn(process.execPath,
[ path.resolve(__dirname, 'test-stdin-pause-resume.js') ]); [path.resolve(__dirname, 'test-stdin-pause-resume.js')]);

Loading…
Cancel
Save