mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Clean up test-in-console output
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
// Global flag for phantomjs (or other browser) to eval to see if we're done.
|
||||
DONE = false;
|
||||
// Failure count for phantomjs exit code
|
||||
FAILURES = null;
|
||||
|
||||
var getName = function (result) {
|
||||
return (result.server ? "S: " : "C: ") +
|
||||
result.groupPath.join(" - ") + " - " + result.test;
|
||||
};
|
||||
|
||||
var log = function (/*arguments*/) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var finished = 0;
|
||||
@@ -16,9 +24,10 @@ var toReport = [];
|
||||
|
||||
var hrefPath = document.location.href.split("/");
|
||||
var platform = hrefPath.length && hrefPath[hrefPath.length - 1];
|
||||
if (_.isEmpty(platform))
|
||||
if (!platform)
|
||||
platform = "local";
|
||||
var doReport = Meteor &&
|
||||
Meteor.settings &&
|
||||
Meteor.settings.public &&
|
||||
Meteor.settings.public.runId;
|
||||
var report = function (name, last) {
|
||||
@@ -88,22 +97,22 @@ Meteor.startup(function () {
|
||||
case "PENDING":
|
||||
resultSet[name].status = "OK";
|
||||
report(name, true);
|
||||
console.log(name, ":", "OK");
|
||||
log(name, ":", "OK");
|
||||
passed++;
|
||||
break;
|
||||
case "EXPECTED":
|
||||
report(name, true);
|
||||
console.log(name, ":", "EXPECTED FAILURE");
|
||||
log(name, ":", "EXPECTED FAILURE");
|
||||
expected++;
|
||||
break;
|
||||
case "FAIL":
|
||||
failed++;
|
||||
report(name, true);
|
||||
console.log(name, ":", "!!!!!!!!! FAIL !!!!!!!!!!!");
|
||||
console.log(JSON.stringify(resultSet[name].info));
|
||||
log(name, ":", "!!!!!!!!! FAIL !!!!!!!!!!!");
|
||||
log(JSON.stringify(resultSet[name].info));
|
||||
break;
|
||||
default:
|
||||
console.log(name, ": unknown state for the test to be in");
|
||||
log(name, ": unknown state for the test to be in");
|
||||
}
|
||||
finished++;
|
||||
break;
|
||||
@@ -116,12 +125,21 @@ Meteor.startup(function () {
|
||||
},
|
||||
|
||||
function () {
|
||||
console.log("passed/expected/failed/total", passed, "/", expected, "/", failed, "/", _.size(resultSet));
|
||||
if (failed > 0) {
|
||||
log("~~~~~~~ THERE ARE FAILURES ~~~~~~~");
|
||||
}
|
||||
log("passed/expected/failed/total", passed, "/", expected, "/", failed, "/", _.size(resultSet));
|
||||
sendReports(function () {
|
||||
console.log("Waiting 3s for any last reports to get sent out");
|
||||
setTimeout(function () {
|
||||
if (doReport) {
|
||||
log("Waiting 3s for any last reports to get sent out");
|
||||
setTimeout(function () {
|
||||
FAILURES = failed;
|
||||
DONE = true;
|
||||
}, 3000);
|
||||
} else {
|
||||
FAILURES = failed;
|
||||
DONE = true;
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
},
|
||||
["tinytest"]);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
Package.describe({
|
||||
summary: "Run tests noninteractively in PhantomJS",
|
||||
summary: "Run tests noninteractively, with results going to the console.",
|
||||
internal: true
|
||||
});
|
||||
|
||||
Package.on_use(function (api) {
|
||||
|
||||
// XXX this should go away, and there should be a clean interface
|
||||
// that tinytest and the driver both implement?
|
||||
api.use('tinytest');
|
||||
api.use('http');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
var url = null;
|
||||
if (Meteor.settings &&
|
||||
Meteor.settings.public &&
|
||||
!_.isEmpty(Meteor.settings.public.runId) &&
|
||||
!_.isEmpty(Meteor.settings.public.reportTo)) {
|
||||
Meteor.settings.public.runId &&
|
||||
Meteor.settings.public.reportTo) {
|
||||
url = Meteor.settings.public.reportTo +
|
||||
"/report/" +
|
||||
Meteor.settings.public.runId;
|
||||
@@ -10,9 +10,11 @@ if (Meteor.settings &&
|
||||
|
||||
Meteor.methods({
|
||||
report: function (reports) {
|
||||
Meteor.http.post(url, {
|
||||
data: reports
|
||||
});
|
||||
if (url) {
|
||||
Meteor.http.post(url, {
|
||||
data: reports
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,28 +4,18 @@ cd `dirname $0`
|
||||
cd ../..
|
||||
export METEOR_HOME=`pwd`
|
||||
|
||||
#eventually this should be the new engine way to run tests
|
||||
cd $METEOR_HOME/packages
|
||||
|
||||
cat > settings.json <<EOF
|
||||
{
|
||||
"public": {
|
||||
"runId": "$RUN_ID",
|
||||
"reportTo": "$TEST_RESULT_URL"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
export PATH=$METEOR_HOME:$PATH
|
||||
meteor --version # syncronously get the dev bundle if its not there.
|
||||
./meteor --version 2>&1 | grep Unreleased || exit 1 # syncronously get the dev bundle if its not there.
|
||||
|
||||
cat settings.json
|
||||
meteor test-packages --driver-package test-in-console --settings=settings.json &
|
||||
export URL='http://localhost:4096/'
|
||||
|
||||
meteor test-packages --driver-package test-in-console -p 4096 &
|
||||
METEOR_PID=$!
|
||||
|
||||
sleep 2
|
||||
|
||||
phantomjs ./test-in-console/runner.js $PLATFORM
|
||||
phantomjs $METEOR_HOME/packages/test-in-console/runner.js
|
||||
STATUS=$?
|
||||
|
||||
kill $METEOR_PID
|
||||
rm settings.json
|
||||
exit $STATUS
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
var page = require('webpage').create();
|
||||
var system = require('system');
|
||||
var platform = system.args[1] || "";
|
||||
console.log("I am here");
|
||||
var platform = system.args[1] || "local";
|
||||
console.log("Running Meteor tests in PhantomJS...");
|
||||
page.onConsoleMessage = function (message) {
|
||||
console.log(message);
|
||||
};
|
||||
page.open("http://localhost:3000/" + platform);
|
||||
page.open(system.env.URL + platform);
|
||||
setInterval(function () {
|
||||
var done = page.evaluate(function () {
|
||||
return DONE;
|
||||
return typeof DONE !== 'undefined' && DONE;
|
||||
});
|
||||
if (done) {
|
||||
phantom.exit(0);
|
||||
var failures = page.evaluate(function () {
|
||||
if (typeof FAILURES === 'undefined') {
|
||||
return 1;
|
||||
}
|
||||
return FAILURES;
|
||||
});
|
||||
phantom.exit(failures ? 1 : 0);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
Reference in New Issue
Block a user