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

SlimerJS support #294

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
language: node_js

node_js: 0.10
# installs dependencies for testing
install: npm install -g [email protected]
# command to run tests
script: casperjs test tests/headless/run-testsuite.js

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

install:
- npm install -g http-server
- npm install -g [email protected]
- npm install -g [email protected]

before_script:
- http-server -s -a 0.0.0.0 -p 8080 &

script:
- casperjs test tests/headless/run-testsuite.js --host=http://0.0.0.0:8080/
- ./tests/run-slimerjs.sh
2 changes: 1 addition & 1 deletion tests/headless/modules/tawWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function runOneTestFunc(name, filename) {
results.push({
pass: false,
msg: msg + debugInfo("t.ok", name, filename)
})
});
} else {
results.push({pass: true, msg: msg});
}
Expand Down
43 changes: 15 additions & 28 deletions tests/headless/run-testsuite.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
var fs = require('fs'),
system = require('system'),
dash = fs.separator,
currentFile = system.args[4], // the full path to run-testsuite.js
curFileParts = fs.absolute(currentFile).split(dash);

// remove filename 'run-testsuite.js'
curFileParts.pop();
// remove containing folder 'headless'
curFileParts.pop();

var basePath = curFileParts.join(dash) + dash;
var modulePath = basePath + 'headless' + dash + 'modules' + dash;

// the html file with the links
var tawListOfTestsFile = basePath + 'list-tests.html';
var fs = require('fs'),
host = casper.cli.has('host') ? casper.cli.get('host') : 'http://localhost:8080/',
testsPath = host + 'tests/',
tawListOfTestsFile = testsPath + 'list-tests.html',
modulesPath = fs.workingDirectory + '/tests/headless/modules/';

var strUtil = require(modulePath + 'strUtil'),
var strUtil = require(modulesPath + 'strUtil'),
padLeft = strUtil.padLeft,
padRight = strUtil.padRight;

var tawWrapper = require(modulePath + 'tawWrapper'),
var tawWrapper = require(modulesPath + 'tawWrapper'),
getTestFiles = tawWrapper.getTestFiles,
getTestFunctions = tawWrapper.getTestFunctions,
runOneTestFunc = tawWrapper.runOneTestFunc;


// the variables we'll fill during the first phase and iterate over in the
// second phase
var links = [];
var funcCnt = 0;
var results = [];
var total = 0;


var links = [],
funcCnt = 0,
results = [],
total = 0;

// Open the TAW-list of urls
casper.start(tawListOfTestsFile);
Expand All @@ -45,7 +32,7 @@ casper.then(function() {
casper.then(function() {
links.forEach(function(link) {
var funcs;
casper.thenOpen(basePath + link, function(){
casper.thenOpen(testsPath + link, function(){
funcs = this.evaluate(getTestFunctions);
});
casper.then(function() {
Expand All @@ -62,7 +49,7 @@ casper.then(function() {
);
}, this);
});

});
});

Expand All @@ -77,7 +64,7 @@ casper.then(function(){
} else {
var message = padLeft((++cnt), 4) + ") " + result.msg;
if (result.skip) {
test.skip(1, message)
test.skip(1, message);
} else {
test.assert(result.pass, message);
}
Expand All @@ -89,4 +76,4 @@ casper.then(function(){

});

casper.run();
casper.run();
9 changes: 9 additions & 0 deletions tests/run-slimerjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

casperjs --engine=slimerjs test tests/headless/run-testsuite.js --host=http://0.0.0.0:8080/ | tee slimerjs.log

# Figure out the exit code ourselves because Gecko does not allow
# SlimerJS to do so for now.
[ -z "`grep ' 0 failed.' slimerjs.log`" ] && ERROR=1
rm slimerjs.log
exit $ERROR