Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

test:lint Lint added for test folder and also fixed intial level of lint errors #25280 #25288

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ bench-idle:
./node benchmark/idle_clients.js &

jslintfix:
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js

jslint:
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js,test/fixtures/throws_error4.js,test/fixtures/uncaught-exceptions/parse-error-mod.js,test/message/throw_in_line_with_tabs.js

CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_root_certs.h
Expand Down
6 changes: 3 additions & 3 deletions test/addons/async-hello-world/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ var assert = require('assert');
var binding = require('./build/Release/binding');
var called = false;

process.on('exit', function () {
process.on('exit', function() {
assert(called);
});

binding(5, function (err, val) {
binding(5, function(err, val) {
assert.equal(null, err);
assert.equal(10, val);
process.nextTick(function () {
process.nextTick(function() {
called = true;
});
});
4 changes: 2 additions & 2 deletions test/addons/repl-domain-abort/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ process.on('exit', function() {
var lines = [
// This line shouldn't cause an assertion error.
'require(\'' + buildPath + '\')' +
// Log output to double check callback ran.
'.method(function() { console.log(\'cb_ran\'); });',
// Log output to double check callback ran.
'.method(function() { console.log(\'cb_ran\'); });'
];

var dInput = new stream.Readable();
Expand Down
36 changes: 18 additions & 18 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ if (!fs.existsSync(exports.opensslCli))
if (process.platform === 'win32') {
exports.faketimeCli = false;
} else {
exports.faketimeCli = path.join(__dirname, "..", "tools", "faketime", "src",
"faketime");
exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src',
'faketime');
}

var ifaces = os.networkInterfaces();
Expand Down Expand Up @@ -175,8 +175,8 @@ function leakedGlobals() {
if (-1 === knownGlobals.indexOf(global[val]))
leaked.push(val);

return leaked;
};
return leaked;
}
exports.leakedGlobals = leakedGlobals;

// Turn this off if the test should not check for global leaks.
Expand Down Expand Up @@ -243,7 +243,7 @@ exports.checkSpawnSyncRet = function(ret) {
var etcServicesFileName = path.join('/etc', 'services');
if (process.platform === 'win32') {
etcServicesFileName = path.join(process.env.SystemRoot, 'System32', 'drivers',
'etc', 'services');
'etc', 'services');
}

/*
Expand All @@ -258,11 +258,11 @@ if (process.platform === 'win32') {
*/
exports.getServiceName = function getServiceName(port, protocol) {
if (port == null) {
throw new Error("Missing port number");
throw new Error('Missing port number');
}

if (typeof protocol !== 'string') {
throw new Error("Protocol must be a string");
throw new Error('Protocol must be a string');
}

/*
Expand All @@ -273,36 +273,36 @@ exports.getServiceName = function getServiceName(port, protocol) {

try {
/*
* I'm not a big fan of readFileSync, but reading /etc/services asynchronously
* here would require implementing a simple line parser, which seems overkill
* for a simple utility function that is not running concurrently with any
* other one.
* I'm not a big fan of readFileSync, but reading /etc/services
* asynchronously here would require implementing a simple
* line parser, which seems overkill for a simple utility function
* that is not running concurrently with any other one.
*/
var servicesContent = fs.readFileSync(etcServicesFileName,
{ encoding: 'utf8'});
{ encoding: 'utf8'});
var regexp = util.format('^(\\w+)\\s+\\s%d/%s\\s', port, protocol);
var re = new RegExp(regexp, 'm');

var matches = re.exec(servicesContent);
if (matches && matches.length > 1) {
serviceName = matches[1];
}
} catch(e) {
} catch (e) {
console.error('Cannot read file: ', etcServicesFileName);
return undefined;
}

return serviceName;
}
};

exports.isValidHostname = function(str) {
// See http://stackoverflow.com/a/3824105
var re = new RegExp(
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' +
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' +
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');

return !!str.match(re) && str.length <= 255;
}
};
exports.hasMultiLocalhost = function hasMultiLocalhost() {
var TCP = process.binding('tcp_wrap').TCP;
var t = new TCP();
Expand All @@ -328,4 +328,4 @@ exports.getNodeVersion = function getNodeVersion() {
patch: patch,
pre: pre
};
}
};
48 changes: 24 additions & 24 deletions test/debugger/test-debug-break-on-uncaught.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var scenarios;
function addScenario(scriptName, throwsInFile, throwsOnLine) {
if (!scenarios) scenarios = [];
scenarios.push(
runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run)
runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run)
);
}

Expand All @@ -56,16 +56,16 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) {
var port = common.PORT + 1337;

var testScript = path.join(
common.fixturesDir,
'uncaught-exceptions',
scriptName
);
common.fixturesDir,
'uncaught-exceptions',
scriptName
);

var child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]);
var child = spawn(process.execPath, ['--debug-brk=' + port, testScript]);
child.on('close', function() {
assert(asserted, 'debugger did not pause on exception');
if (next) next();
})
});

var exceptions = [];

Expand All @@ -90,25 +90,25 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) {

function runTest(client) {
client.req(
{
command: 'setexceptionbreak',
arguments: {
type: 'uncaught',
enabled: true
}
},
function(error, result) {
assert.ifError(error);
{
command: 'setexceptionbreak',
arguments: {
type: 'uncaught',
enabled: true
}
},
function(error, result) {
assert.ifError(error);

client.on('exception', function(event) {
exceptions.push(event.body);
});
client.on('exception', function(event) {
exceptions.push(event.body);
});

client.reqContinue(function(error, result) {
assert.ifError(error);
setTimeout(assertHasPaused.bind(null, client), 100);
});
}
client.reqContinue(function(error, result) {
assert.ifError(error);
setTimeout(assertHasPaused.bind(null, client), 100);
});
}
);
}

Expand Down
26 changes: 13 additions & 13 deletions test/debugger/test-debugger-repl-break-in-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [

// continue - the breakpoint should be triggered
repl.addTest('c', [
/break in .*[\\\/]mod\.js:23/,
/21/, /22/, /23/, /24/, /25/
/break in .*[\\\/]mod\.js:23/,
/21/, /22/, /23/, /24/, /25/
]);

// -- RESTORE BREAKPOINT ON RESTART --

// Restart the application - breakpoint should be restored
repl.addTest('restart', [].concat(
[
/terminated/
],
repl.handshakeLines,
[
/Restoring breakpoint mod.js:23/,
/Warning: script 'mod\.js' was not loaded yet\./,
/Restoring breakpoint \).*:\d+/,
/Warning: script '\)[^']*' was not loaded yet\./
],
repl.initialBreakLines));
[
/terminated/
],
repl.handshakeLines,
[
/Restoring breakpoint mod.js:23/,
/Warning: script 'mod\.js' was not loaded yet\./,
/Restoring breakpoint \).*:\d+/,
/Warning: script '\)[^']*' was not loaded yet\./
],
repl.initialBreakLines));

// continue - the breakpoint should be triggered
repl.addTest('c', [
Expand Down
6 changes: 3 additions & 3 deletions test/debugger/test-debugger-repl-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ var repl = require('./helper-debugger-repl.js');

repl.startDebugger('breakpoints.js');
var linesWithBreakpoint = [
/1/, /2/, /3/, /4/, /5/, /\* 6/
/1/, /2/, /3/, /4/, /5/, /\* 6/
];
// We slice here, because addTest will change the given array.
repl.addTest('sb(6)', linesWithBreakpoint.slice());

var initialLines = repl.initialLines.slice()
var initialLines = repl.initialLines.slice();
initialLines.splice(2, 0, /Restoring/, /Warning/);

// Restart the debugged script
repl.addTest('restart', [
/terminated/,
/terminated/
].concat(initialLines));

repl.addTest('list(5)', linesWithBreakpoint);
Expand Down
6 changes: 3 additions & 3 deletions test/debugger/test-debugger-repl-term.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ addTest('n', [
addTest('', [
/debug>/,
/break in .*:5/,
/3/, /4/, /5/, /6/, /7/,
/3/, /4/, /5/, /6/, /7/
]);

// continue
Expand All @@ -52,12 +52,12 @@ addTest('c', [
addTest('', [
/debug>/,
/break in .*:5/,
/3/, /4/, /5/, /6/, /7/,
/3/, /4/, /5/, /6/, /7/
]);

// should repeat continue
addTest('', [
/debug>/,
/break in .*:23/,
/21/, /22/, /23/, /24/, /25/,
/21/, /22/, /23/, /24/, /25/
]);
4 changes: 2 additions & 2 deletions test/disabled/test-debug-brk-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function debug_client_connect() {
// get breakpoint list and check if it exists on line 0
if (!body.length) {
var req = JSON.stringify({'seq': 1, 'type': 'request',
'command': 'listbreakpoints'});
'command': 'listbreakpoints'});
conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req);
return;
}
Expand All @@ -97,7 +97,7 @@ function debug_client_connect() {
}

var req = JSON.stringify({'seq': 100, 'type': 'request',
'command': 'disconnect'});
'command': 'disconnect'});
conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req);
} finally {
msg = null;
Expand Down
11 changes: 6 additions & 5 deletions test/disabled/test-readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var readlineFakeStream = function() {
}
});
var _stdoutWrite = process.stdout.write;
process.stdout.write = function (data) {
process.stdout.write = function(data) {
data.split('').forEach(rl.written_bytes.push.bind(rl.written_bytes));
_stdoutWrite.apply(this, arguments);
}
Expand All @@ -73,7 +73,7 @@ var written_bytes_length, refreshed;

rl.write('foo');
assert.equal(3, rl.cursor);
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function (key) {
[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) {
rl.write.apply(rl, key.home);
assert.equal(0, rl.cursor);
rl.write.apply(rl, key.end);
Expand All @@ -95,8 +95,8 @@ rl.write.apply(rl, key.xterm.home);
{cursor: 8, key: key.xterm.metab},
{cursor: 7, key: key.xterm.metab},
{cursor: 4, key: key.xterm.metab},
{cursor: 0, key: key.xterm.metab},
].forEach(function (action) {
{cursor: 0, key: key.xterm.metab}
].forEach(function(action) {
written_bytes_length = rl.written_bytes.length;
rl.write.apply(rl, action.key);
assert.equal(action.cursor, rl.cursor);
Expand All @@ -107,7 +107,8 @@ rl.write.apply(rl, key.xterm.home);
rl = readlineFakeStream();
rl.write('foo bar.hop/zoo');
rl.write.apply(rl, key.xterm.home);
['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''].forEach(function (expectedLine) {
['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''
].forEach(function(expectedLine) {
rl.write.apply(rl, key.xterm.metad);
assert.equal(0, rl.cursor);
assert.equal(expectedLine, rl.line);
Expand Down
Loading