-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚡️ Automated Leak Detection on CI ⚡️ #1464
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var fs = require('fs'); | ||
var frameworkNamePattern = /^[a-z-_\d]+$/; | ||
|
||
var excludedFrameworks = [ | ||
// this implementation deviates from the specification to such an extent that they are | ||
// not worth testing via a generic mechanism | ||
'gwt', | ||
// these implementations cannot be run offline, because they are hosted | ||
'firebase-angular', 'meteor', 'socketstream', | ||
// YUI is a special case here, it is not hosted, but fetches JS files dynamically | ||
'yui', | ||
// these frameworks take a long time to start-up, and there is no easy way to determine when they are ready | ||
'cujo', | ||
// sammyjs fails intermittently, it would appear that its state is sometimes updated asynchronously? | ||
'sammyjs', | ||
// elm-html batches UI updates with requestAnimationFrame which the tests | ||
// don't wait for | ||
'elm', | ||
// these are examples that have been removed or are empty folders | ||
'emberjs_require', 'dermis' | ||
]; | ||
|
||
module.exports = function (names) { | ||
// collect together the framework names from each of the subfolders | ||
var list = fs.readdirSync('../examples/') | ||
.map(function (folderName) { | ||
return { name: folderName, path: 'examples/' + folderName }; | ||
}); | ||
|
||
// apps that are not hosted at the root of their folder need to be handled explicitly | ||
var exceptions = [ | ||
{ name: 'chaplin-brunch', path: 'examples/chaplin-brunch/public' }, | ||
{ name: 'angular-dart', path: 'examples/angular-dart/web' }, | ||
{ name: 'duel', path: 'examples/duel/www' }, | ||
{ name: 'vanilladart', path: 'examples/vanilladart/build/web' }, | ||
{ name: 'canjs_require', path: 'examples/canjs_require/' }, | ||
{ name: 'troopjs', path: 'examples/troopjs_require/' }, | ||
{ name: 'thorax_lumbar', path: 'examples/thorax_lumbar/public' } | ||
]; | ||
list = list.map(function (framework) { | ||
var exception = exceptions.filter(function (exFramework) { | ||
return exFramework.name === framework.name; | ||
}); | ||
return exception.length > 0 ? exception[0] : framework; | ||
}); | ||
|
||
// filter out any folders that are not frameworks (.e.g hidden files) | ||
list = list.filter(function (framework) { | ||
return frameworkNamePattern.test(framework.name); | ||
}); | ||
|
||
// filter out un-supported implementations | ||
list = list.filter(function (framework) { | ||
return excludedFrameworks.indexOf(framework.name) === -1; | ||
}); | ||
|
||
return list.filter(function (framework) { | ||
return [].concat(names).some(function (f) { | ||
return f === framework.name; | ||
}); | ||
}); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var drool = require('drool'); | ||
var frameworkPathLookup = require('./framework-path-lookup'); | ||
var argv = require('optimist').default('laxMode', false).default('browser', 'chrome').argv; | ||
var driverConfig = { | ||
chromeOptions: 'no-sandbox' | ||
}; | ||
|
||
if (typeof process.env.CHROME_PATH !== 'undefined') { | ||
driverConfig.chromeBinaryPath = process.env.CHROME_PATH; | ||
} | ||
|
||
var driver = drool.start(driverConfig); | ||
var list = frameworkPathLookup(argv.framework); | ||
|
||
function idApp() { | ||
return driver.findElement(drool.webdriver.By.css('#todoapp')) | ||
.then(function () { return true; }) | ||
.thenCatch(function () { return false; }); | ||
} | ||
|
||
function newTodoSelector(name) { | ||
return idApp().then(function (isId) { | ||
if (isId) { | ||
return '#new-todo'; | ||
} | ||
|
||
return '.new-todo'; | ||
}); | ||
} | ||
|
||
function listSelector(name) { | ||
return idApp().then(function (isId) { | ||
if (isId) { | ||
return '#todo-list li'; | ||
} | ||
|
||
return '.todo-list li'; | ||
}); | ||
} | ||
|
||
list.forEach(function (framework) { | ||
drool.flow({ | ||
repeatCount: 5, | ||
setup: function () { | ||
driver.get('http://localhost:8000/' + framework.path + '/index.html'); | ||
}, | ||
action: function (name) { | ||
driver.wait(function () { | ||
return driver.findElement(drool.webdriver.By.css(newTodoSelector(name))) | ||
.sendKeys('find magical goats', drool.webdriver.Key.ENTER) | ||
.thenCatch(function () { | ||
return false; | ||
}) | ||
.then(function () { | ||
return driver.findElement(drool.webdriver.By.css(listSelector(name))).isDisplayed() | ||
.then(function () { | ||
return true; | ||
}) | ||
}); | ||
}, 10000); | ||
|
||
driver.wait(function () { | ||
return driver.findElement(drool.webdriver.By.css(listSelector(name))).click() | ||
.thenCatch(function () { | ||
return false; | ||
}) | ||
.then(function () { | ||
return true; | ||
}); | ||
}); | ||
|
||
driver.findElement(drool.webdriver.By.css('.destroy')).click(); | ||
}.bind(null, framework.name), | ||
assert: function (after, initial) { | ||
var nodeIncrease = (after.nodes - initial.nodes); | ||
var listenerIncrease = (after.jsEventListeners - initial.jsEventListeners); | ||
console.log(this + ', ' + nodeIncrease + ', ' + | ||
(after.jsHeapSizeUsed - initial.jsHeapSizeUsed) + ', ' + listenerIncrease); | ||
|
||
//https://code.google.com/p/chromium/issues/detail?id=516153 | ||
if (nodeIncrease > 5) { | ||
throw new Error('Node Count leak detected!'); | ||
} | ||
|
||
if (listenerIncrease > 0) { | ||
throw new Error('Event Listener leak detected!'); | ||
} | ||
|
||
}.bind(framework.name) | ||
}, driver) | ||
}); | ||
|
||
driver.quit(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
args="$@" | ||
|
||
npm i && \ | ||
eval "node memory.js $args" && \ | ||
eval "npm test -- $args" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon, why didn't the linting process catch this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or me! Outrageous! Fixed in master with 1567e60.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @passy! Still we should check what's wrong with the linting tooling though.