Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix race condition in specificity tests and change expected result so…

… all specificity tests now pass
  • Loading branch information...
commit bd17eed9f5d8f5c94e0b2fc194b137b6c3040515 1 parent c707188
@springmeyer springmeyer authored
View
17 test/specificity.test.js
@@ -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();
});
});
View
6 test/specificity/issue60.result
@@ -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]}
]
View
14 test/support/helper.js
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.