Commit 79e86f32 by xzyfer

Tweak spec.js to support :only_on and multiple :todo engines

parent 65321899
......@@ -62,6 +62,8 @@
"in-publish": "^2.0.0",
"lodash.assign": "^4.2.0",
"lodash.clonedeep": "^4.3.2",
"lodash.isarray": "^4.0.0",
"lodash.mergewith": "^4.6.0",
"meow": "^3.7.0",
"mkdirp": "^0.5.1",
"nan": "^2.3.2",
......
......@@ -7,7 +7,9 @@ var assert = require('assert'),
? require('../lib-cov')
: require('../lib'),
readYaml = require('read-yaml'),
objectMerge = require('object-merge'),
mergeWith = require('lodash.mergewith'),
assign = require('lodash.assign'),
isArray = require('lodash.isarray'),
glob = require('glob'),
specPath = require('sass-spec').dirname.replace(/\\/g, '/'),
impl = 'libsass',
......@@ -32,7 +34,7 @@ var initialize = function(inputCss, options) {
testCase.statusPath = join(folder, 'status');
testCase.optionsPath = join(folder, 'options.yml');
if (exists(testCase.optionsPath)) {
options = objectMerge(options, readYaml.sync(testCase.optionsPath));
options = mergeWith(assign({}, options), readYaml.sync(testCase.optionsPath), customizer);
}
testCase.includePaths = [
folder,
......@@ -41,6 +43,7 @@ var initialize = function(inputCss, options) {
testCase.precision = parseFloat(options[':precision']) || 5;
testCase.outputStyle = options[':output_style'] ? options[':output_style'].replace(':', '') : 'nested';
testCase.todo = options[':todo'] !== undefined && options[':todo'] !== null && options[':todo'].indexOf(impl) !== -1;
testCase.only = options[':only_on'] !== undefined && options[':only_on'] !== null && options[':only_on'];
testCase.warningTodo = options[':warning_todo'] !== undefined && options[':warning_todo'] !== null && options[':warning_todo'].indexOf(impl) !== -1;
testCase.startVersion = parseFloat(options[':start_version']) || 0;
testCase.endVersion = parseFloat(options[':end_version']) || 99;
......@@ -59,6 +62,8 @@ var runTest = function(inputCssPath, options) {
it(test.name, function(done) {
if (test.todo || test.warningTodo) {
this.skip('Test marked with TODO');
} else if (test.only && test.only.indexOf(impl) === -1) {
this.skip('Tests marked for only: ' + test.only.join(', '));
} else if (version < test.startVersion) {
this.skip('Tests marked for newer Sass versions only');
} else if (version > test.endVersion) {
......@@ -109,11 +114,18 @@ var specSuite = {
suites: [],
options: {}
};
function customizer(objValue, srcValue) {
if (isArray(objValue)) {
return objValue.concat(srcValue);
}
}
var executeSuite = function(suite, tests) {
var suiteFolderLength = suite.folder.split('/').length;
var optionsFile = join(suite.folder, 'options.yml');
if (exists(optionsFile)) {
suite.options = objectMerge(suite.options, readYaml.sync(optionsFile));
suite.options = mergeWith(assign({}, suite.options), readYaml.sync(optionsFile), customizer);
}
// Push tests in the current suite
......@@ -143,7 +155,7 @@ var executeSuite = function(suite, tests) {
folder: suite.folder + '/' + prevSuite,
tests: [],
suites: [],
options: suite.options
options: assign({}, suite.options),
},
tests.slice(prevSuiteStart, i)
)
......@@ -159,7 +171,7 @@ var executeSuite = function(suite, tests) {
folder: suite.folder + '/' + suiteName,
tests: [],
suites: [],
options: suite.options
options: assign({}, suite.options),
},
tests.slice(prevSuiteStart, tests.length)
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment