Skip to content

Commit

Permalink
Add initial browser test suite using phantomjs for headless testing a…
Browse files Browse the repository at this point in the history
…nd jasmine
  • Loading branch information
lukeapage committed Dec 16, 2012
1 parent ee4c0c8 commit 6554117
Show file tree
Hide file tree
Showing 19 changed files with 3,678 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
*.flymake
*~
.#*
test/browser/less.js
test/browser/test-runner-main.htm
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ DIST = dist/less-${VERSION}.js
RHINO = dist/less-rhino-${VERSION}.js
DIST_MIN = dist/less-${VERSION}.min.js

browser-prepare: DIST := test/browser/less.js

less:
@@mkdir -p dist
@@touch ${DIST}
Expand All @@ -37,6 +39,15 @@ less:
build/amd.js >> ${DIST}
@@echo "})(window);" >> ${DIST}
@@echo ${DIST} built.

browser-prepare: less
node test/browser-test-prepare.js

browser-test: browser-prepare
phantomjs test/browser/phantom-runner.js

browser-test-server: browser-prepare
phantomjs test/browser/phantom-runner.js --no-tests

rhino:
@@mkdir -p dist
Expand Down
7 changes: 7 additions & 0 deletions lib/less/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ less.fileAsync = less.fileAsync || false;
// Interval between watch polls
less.poll = less.poll || (isFileProtocol ? 1000 : 1500);

//Setup user functions
if (less.functions) {
for(var func in less.functions) {
less.tree.functions[func] = less.functions[func];
}
}

var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(location.hash);
if (dumpLineNumbers) {
less.dumpLineNumbers = dumpLineNumbers[1];
Expand Down
19 changes: 19 additions & 0 deletions test/browser-test-prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var path = require('path'),
fs = require('fs'),
sys = require('util'),
output = '<html><head>\n';

fs.readdirSync(path.join('test/less/', '')).forEach(function (file) {
if (! /\.less/.test(file)) { return; }

var name = path.basename(file, '.less');

if (name === "javascript" || name === "urls") { return; }

output += '<link id="original-less:less-'+name+'" rel="stylesheet/less" type="text/css" href="http://localhost:8081/' + path.join('less', name) + '.less' +'">\n';
output += '<link id="expected-less:less-'+name+'" rel="stylesheet" type="text/css" href="http://localhost:8081/' + path.join('css', name) + '.css' + '">\n';
});

output += String(fs.readFileSync(path.join('test/browser', 'template.htm'))).replace("{runner-name}", "main");

fs.writeFileSync(path.join('test/browser', 'test-runner-main.htm'), output);
Loading

0 comments on commit 6554117

Please sign in to comment.