mirror of
https://github.com/less/less.js.git
synced 2026-02-07 21:45:08 -05:00
Make the test runner accept a argument to restrict the tests running (for debugging). Make the test runner pass the filename so it behaves like lessc - this fixed one of the tests. Also corrected the tests to run given the new format of the message
This commit is contained in:
@@ -4,6 +4,8 @@ var path = require('path'),
|
||||
|
||||
var less = require('../lib/less');
|
||||
|
||||
var oneTestOnly = process.argv[2];
|
||||
|
||||
less.tree.functions.add = function (a, b) {
|
||||
return new(less.tree.Dimension)(a.value + b.value);
|
||||
}
|
||||
@@ -18,9 +20,12 @@ sys.puts("\n" + stylize("LESS", 'underline') + "\n");
|
||||
|
||||
fs.readdirSync('test/less').forEach(function (file) {
|
||||
if (! /\.less/.test(file)) { return }
|
||||
|
||||
var name = path.basename(file, '.less');
|
||||
|
||||
if (oneTestOnly && name !== oneTestOnly) { return; }
|
||||
|
||||
toCSS('test/less/' + file, function (err, less) {
|
||||
var name = path.basename(file, '.less');
|
||||
|
||||
fs.readFile(path.join('test/css', name) + '.css', 'utf-8', function (e, css) {
|
||||
sys.print("- " + name + ": ")
|
||||
@@ -46,12 +51,15 @@ fs.readdirSync('test/less').forEach(function (file) {
|
||||
|
||||
fs.readdirSync('test/less/errors').forEach(function (file) {
|
||||
if (! /\.less/.test(file)) { return }
|
||||
|
||||
var name = path.basename(file, '.less');
|
||||
|
||||
if (oneTestOnly && ("error/" + name) !== oneTestOnly) { return; }
|
||||
|
||||
toCSS('test/less/errors/' + file, function (err, compiledLess) {
|
||||
var name = path.basename(file, '.less');
|
||||
|
||||
fs.readFile(path.join('test/less/errors', name) + '.txt', 'utf-8', function (e, expectedErr) {
|
||||
sys.print("- error/" + name + ": ");
|
||||
expectedErr = expectedErr.replace("{path}", path.join(process.cwd(), "/test/less/errors/"));
|
||||
if (!err) {
|
||||
if (compiledLess) {
|
||||
sys.print(stylize("No Error", 'red'));
|
||||
@@ -87,7 +95,8 @@ function toCSS(path, callback) {
|
||||
|
||||
new(less.Parser)({
|
||||
paths: [require('path').dirname(path)],
|
||||
optimization: 0
|
||||
optimization: 0,
|
||||
filename: require('path').resolve(process.cwd(), path)
|
||||
}).parse(str, function (err, tree) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ParseError: Syntax Error on line 1
|
||||
ParseError: Syntax Error on line 1 in {path}comment-in-selector.less:1:20
|
||||
1 #gaga /* Comment */ span { color: red }
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ParseError: Syntax Error on line 1
|
||||
ParseError: Syntax Error on line 1 in C:\git\less.js\test\less\errors\import-no-semi.less:1:0
|
||||
1 @import "this-statement-is-invalid.less"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
NameError: .mixin-not-defined is undefined in test\less\errors\mixin-not-defined.less:1:102
|
||||
NameError: .mixin-not-defined is undefined in test\less\errors\mixin-not-defined.less:11:0
|
||||
10
|
||||
11 .mixin-not-defined();
|
||||
11 .mixin-not-defined();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
NameError: .mixin-not-defined is undefined
|
||||
NameError: .mixin-not-defined is undefined in C:\git\less.js\test\less\errors\mixin-not-defined.less:11:0
|
||||
10
|
||||
11 .mixin-not-defined();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ParseError: Syntax Error on line 1
|
||||
ParseError: Syntax Error on line 1 in C:\git\less.js\test\less\errors\parse-error-curly-bracket.less:1:0
|
||||
1 }}
|
||||
|
||||
Reference in New Issue
Block a user