Skip to content
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

Y.Node._instances breaks GC #2014

Open
wants to merge 10 commits into
base: dev-master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
language: node_js
node_js:
- "0.10"
- "0.11"
script:
- grunt travis
git:
depth: 30
- 6.14.4
before_install:
- npm install -g yogi
branches:
except:
- live-docs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
YUI 3: The Yahoo User Interface Library
=======================================

[![Build Status](https://travis-ci.org/yui/yui3.svg?branch=master)](https://travis-ci.org/yui/yui3)
[![Build Status](https://travis-ci.org/jafl/yui3.svg?branch=fix-node-gc-3)](https://travis-ci.org/jafl/yui3)

YUI is a free, open source JavaScript and CSS framework for building richly
interactive web applications. YUI is provided under a BSD license and is
Expand Down
219 changes: 219 additions & 0 deletions bin/grover_patch_wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
Wrapper for PhantomJS and YUITest
*/

/*jslint browser: true */
/*global phantom */

var system = require('system');

/*
TODO --
onError: Handle JS errors and throw a YUITest error
Timeout: Specify a timeout (override too) to kill a test
*/
var waitTimer,
waitCounter = 0,
testTimer,
file = system.args[1],
timeout = parseInt(system.args[2], 10),
exited = false,
debug = false, //Internal debugging of wrapper
logConsole = (system.args[3] === 'true' ? true : false),
log = function(a, b) {
b = (typeof b === 'undefined') ? '' : b;
if (debug) {
console.log(a, b);
}
},
consoleInfo = [];

var injectGetYUITest = function() {
window.TestResults = null;
window.getYUITest = function() {
return window.YUITest;
};

window.getYUITestResults = function() {
if (window.TestResults) {
return window.TestResults;
}
var YUITest = window.getYUITest(), json, cover;
if (YUITest) {
json = YUITest.Runner.getResults(YUITest.Format.JSON);
cover = YUITest.Runner.getCoverage();

if (json && cover) {
json = JSON.parse(json);
json.coverage = cover;
json = JSON.stringify(json);

}
if (json && window.__coverage__) {
json = JSON.parse(json);
json.coverageType = 'istanbul';
json.coverage = window.__coverage__;
json = JSON.stringify(json);
}
return json;
}
};

};
var startTest = function(page, cb) {
log('Checking for YUITest');
testTimer = setInterval(function() {
//console.log('Checking..');
var status = page.evaluate(function() {
var t = window.getYUITest(),
i, name;
if (t) {
for (i in t) {
if (t.hasOwnProperty(i)) {
name = i.replace('Test', '');
t[name] = t[i];
}
}
}
return (t ? true : false);
});
log('Tester: ', status);
if (status) {
clearInterval(testTimer);
cb(status);
}
}, 50);
};

var throwError = function(msg, trace) {
log('throwError executed');
var json = {
passed: 0,
failed: 1,
total: 1,
ignored: 0,
name: file,
error: msg
};
if (trace) {
trace.forEach(function(item) {
json.error += '\n' + item.file + ':' + item.line;
});
}
if (!exited) {
console.log(JSON.stringify(json));
}
exited = true;
phantom.exit(1);
};

var waitForResults = function(page, cb) {

waitTimer = setInterval(function() {
waitCounter++;
log('Waiting on Results', waitCounter);
var status = page.evaluate(function() {
return window.getYUITestResults();
});
if (status) {
clearInterval(waitTimer);
log('Found Results');
cb(status);
return;
} else {
log('NO RESULTS');
}

}, 150);

};

var executeTest = function(file, cb) {
log('executing tests in ', file);
var page = require('webpage').create();

page.settings.javascriptEnabled = true;
page.settings.localToRemoteUrlAccessEnabled = true;
page.settings.loadImages = true;
page.settings.loadPlugins = true;
page.viewportSize = {
width: 1024,
height: 768
};

if (debug) {
page.onConsoleMessage = function(msg) {
console.log('[console.log]', msg);
};
}
if (logConsole) {
page.onConsoleMessage = function() {
var args = [], i = 0;
for (i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
consoleInfo.push({
type: 'console.log',
'arguments': args
});
};
page.onAlert = function(msg) {
consoleInfo.push({
type: 'window.alert',
'arguments': [msg]
});
};
}
page.onError = function(msg, trace) {
throwError(msg, trace);
};

log('Opening File', file);
page.open(file, function(status) {
log('Opened File', file);
if (status === 'fail') {
throwError('Phantom failed to load this page');
}
log('Status: ', status);
log('Injecting getYUITest');
page.evaluate(injectGetYUITest);

startTest(page, function() {
log('YUITest Found..');
waitForResults(page, function(results) {
log('YUITest Results Returned');
cb(page, results);
});
});
});
};


if (system.args.length < 2) {
console.log('Please provide some test files to execute');
phantom.exit(1);
}

if (isNaN(timeout)) {
timeout = 60; //Default to one minute before failing the test
}
setTimeout(function() {
throwError('Script Timeout');
}, (timeout * 1000));

executeTest(file, function(page, results) {
log('executeTest callback fired');
if (!exited) {
var json = JSON.parse(results);
if (typeof json === 'object') {
json.consoleInfo = consoleInfo;
}
if (Array.isArray(json)) {
json[0].consoleInfo = console.Info;
}
results = JSON.stringify(json);
console.log(results);
}
exited = true;
phantom.exit();
});
32 changes: 32 additions & 0 deletions bin/travis-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

echo ===;
whoami;
echo ===;

YOGI=`readlink -f $(which yogi)`;
YOGI=${YOGI%/*};
cp -f ./bin/grover_patch_wrapper.js $YOGI/../node_modules/grover/lib/wrapper/wrapper.js;

echo patched grover;
echo ===;

# build everything

for d in src/*; do
if [[ ! -f $d/build.json ]]; then continue; fi

pushd $d
if ! yogi build --no-lint; then exit 1; fi
popd
done

# test everything after all modules have been built

for d in src/*; do
if [[ ! -d $d/tests/unit ]]; then continue; fi

pushd $d
if ! yogi test; then echo =====; fi
popd
done
2 changes: 1 addition & 1 deletion build/gesture-simulate/gesture-simulate-coverage.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/node-core/node-core-coverage.js

Large diffs are not rendered by default.

Loading