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) {
if (process.platform == 'win32') {
return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir,
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
} else {
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:
// $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/
var echo = is_windows ? spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo',
'node&&', 'echo', 'and&&', 'echo', 'world']) :
spawn('echo', ['hello\nnode\nand\nworld\n']),
grep = spawn('grep', ['o']),
sed = spawn('sed', ['s/o/O/']);
var grep = spawn('grep', ['o']),
sed = spawn('sed', ['s/o/O/']),
echo;
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

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

@ -26,14 +26,14 @@ var match = false;
var isDebug = process.features.debug;
var debugPaths = [ path.normalize(path.join(__dirname, '..', '..',
'out', 'Debug', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Debug', 'node'))];
var defaultPaths = [ path.normalize(path.join(__dirname, '..', '..',
'out', 'Release', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Release', 'node'))];
var debugPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Debug', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Debug', 'node'))];
var defaultPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Release', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Release', 'node'))];
console.error('debugPaths: ' + debugPaths);
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() {
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' +
'Accept: */*\r\n' +
'\r\n');
@ -147,7 +148,8 @@ function test(handler, request_generator, response_validator) {
function request_generator() {
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' +
'Host: 127.0.0.1:1337\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 resolvedFile = path.resolve(file);
var networkFile = '\\\\someserver\\someshare\\somefile';
assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file));
assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\someserver\\someshare\\somefile'));
path._makeLong('\\\\someserver\\someshare\\somefile'));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile'));
assert.equal('\\\\.\\pipe\\somepipe', path._makeLong('\\\\.\\pipe\\somepipe'));
path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile'));
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
function ArrayStream() {
this.run = function (data) {
this.run = function(data) {
var self = this;
data.forEach(function (line) {
data.forEach(function(line) {
self.emit('data', line);
});
}
@ -36,11 +36,11 @@ function ArrayStream() {
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function () {};
ArrayStream.prototype.write = function () {};
ArrayStream.prototype.resume = function() {};
ArrayStream.prototype.write = function() {};
var works = [ [ 'inner.one' ], 'inner.o' ];
var doesNotBreak = [ [], 'inner.o' ];
var works = [['inner.one'], 'inner.o'];
var doesNotBreak = [[], 'inner.o'];
var putIn = new ArrayStream();
var testMe = repl.start('', putIn);
@ -49,14 +49,15 @@ var testMe = repl.start('', putIn);
putIn.run(['.clear']);
putIn.run([
'var inner = {',
'one:1']);
testMe.complete('inner.o', function (error, data) {
'one:1'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
// Tab Complete will return globaly scoped variables
putIn.run(['};']);
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -66,8 +67,9 @@ putIn.run(['.clear']);
putIn.run([
'var inner = ( true ' ,
'?',
'{one: 1} : ']);
testMe.complete('inner.o', function (error, data) {
'{one: 1} : '
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
@ -76,15 +78,16 @@ putIn.run(['.clear']);
// Tab Complete will return a simple local variable
putIn.run([
'var top = function () {',
'var inner = {one:1};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {one:1};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
// When you close the function scope tab complete will not return the
// locally scoped variable
putIn.run(['};']);
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
@ -93,10 +96,11 @@ putIn.run(['.clear']);
// Tab Complete will return a complex local variable
putIn.run([
'var top = function () {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -106,10 +110,11 @@ putIn.run(['.clear']);
// has paramaters
putIn.run([
'var top = function (one, two) {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -119,11 +124,12 @@ putIn.run(['.clear']);
// scope is nested inside an immediately executed function
putIn.run([
'var top = function () {',
'(function test () {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'(function test () {',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -133,12 +139,13 @@ putIn.run(['.clear']);
// def has the params and { on a seperate line
putIn.run([
'var top = function () {',
'r = function test (',
' one, two) {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test (',
' one, two) {',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
@ -147,12 +154,13 @@ putIn.run(['.clear']);
// currently does not work, but should not break, not the {
putIn.run([
'var top = function () {',
'r = function test ()',
'{',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test ()',
'{',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});
@ -161,13 +169,14 @@ putIn.run(['.clear']);
// currently does not work, but should not break
putIn.run([
'var top = function () {',
'r = function test (',
')',
'{',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test (',
')',
'{',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

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

@ -54,9 +54,11 @@ try {
}
catch (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
function isTypeError(o) {

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

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

Loading…
Cancel
Save