fix race condition in specificity tests and change expected result so all specificity tests now pass

master-undefined-tagcontent
Dane Springmeyer 12 years ago
parent c707188ed5
commit bd17eed9f5

@ -33,8 +33,21 @@ helper.files('specificity', 'mss', function(file) {
var mss = tree.toList({});
mss = helper.makePlain(mss, cleanupItem);
helper.compareToFile(mss, file, helper.resultFile(file));
var json = JSON.parse(fs.readFileSync(helper.resultFile(file)));
var actual = file.replace(path.extname(file),'') + '-actual.json';
var expected = file.replace(path.extname(file),'') + '-expected.json';
try {
assert.deepEqual(mss, json);
// cleanup any actual renders that no longer fail
try {
fs.unlinkSync(actual);
fs.unlinkSync(expected);
} catch (err) {}
} catch (err) {
fs.writeFileSync(actual,JSON.stringify(mss,null,4));
fs.writeFileSync(expected,JSON.stringify(json,null,4));
throw new Error('failed: ' + actual + ' not equal to expected: ' + expected);
}
done();
});
});

@ -1,6 +1,6 @@
[
{"elements":["#world"],"filters":["OBJECTID=12"],"specificity":[1,0,1,131]},
{"elements":["#world"],"filters":["NET_INFLOW>-10000"],"specificity":[1,0,1,83]},
{"elements":["#world"],"filters":["NET_INFLOW>-30000"],"specificity":[1,0,1,35]},
{"elements":["#world"],"filters":["[OBJECTID]=12"],"specificity":[1,0,1,131]},
{"elements":["#world"],"filters":["[NET_INFLOW]>-10000"],"specificity":[1,0,1,83]},
{"elements":["#world"],"filters":["[NET_INFLOW]>-30000"],"specificity":[1,0,1,35]},
{"elements":["#world"],"specificity":[1,0,0,0]}
]

@ -70,20 +70,6 @@ exports.makePlain = function(obj, fn) {
return JSON.parse(JSON.stringify(obj, fn));
};
exports.compareToFile = function(value, originalFile, resultFile) {
helper.json(resultFile, function(json) {
try {
assert.deepEqual(value, json);
} catch (e) {
console.warn(helper.stylize('Failure', 'red')
+ ': ' + helper.stylize(originalFile, 'underline')
+ ' differs from expected result.');
helper.showDifferences(e, helper.formatJSON);
throw '';
}
});
};
exports.parseXML = function(xml, callback) {
var parser = sax.parser(true);
var i = 0;

Loading…
Cancel
Save