From 302d409fab4755e01bfb94a65d565e8af9420b48 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Tue, 20 May 2014 16:10:31 -0400 Subject: [PATCH] Update error handling tests. --- test/errorhandling.test.js | 44 +++++-------------- test/errorhandling/color_functions.result | 2 +- test/errorhandling/contradiction.result | 2 +- test/errorhandling/contradiction_2.result | 2 +- test/errorhandling/function_args.result | 2 +- test/errorhandling/invalid_color_in_fn.result | 2 +- test/errorhandling/invalid_property.result | 2 +- test/errorhandling/invalid_value.result | 2 +- test/errorhandling/issue119.result | 1 + test/errorhandling/issue123.result | 2 +- test/errorhandling/issue124.result | 1 + test/errorhandling/issue297.result | 2 +- test/errorhandling/issue_204_a.result | 1 + test/errorhandling/issue_204_b.result | 1 + test/errorhandling/issue_204_c.result | 1 + test/errorhandling/issue_218.result | 1 + test/errorhandling/mapnik_keyword.result | 2 +- test/errorhandling/missing_close.result | 2 +- test/errorhandling/multi_stylesheets.result | 1 + test/errorhandling/multi_stylesheets_b.result | 1 + test/errorhandling/nopound.result | 1 + test/errorhandling/notenoughargs.result | 1 + test/errorhandling/undefined_variable.result | 2 +- test/errorhandling/zoom_as_var.result | 2 +- test/errorhandling/zoommax.result | 2 +- 25 files changed, 34 insertions(+), 48 deletions(-) create mode 100644 test/errorhandling/issue119.result create mode 100644 test/errorhandling/issue124.result create mode 100644 test/errorhandling/issue_204_a.result create mode 100644 test/errorhandling/issue_204_b.result create mode 100644 test/errorhandling/issue_204_c.result create mode 100644 test/errorhandling/issue_218.result create mode 100644 test/errorhandling/multi_stylesheets.result create mode 100644 test/errorhandling/multi_stylesheets_b.result create mode 100644 test/errorhandling/nopound.result create mode 100644 test/errorhandling/notenoughargs.result diff --git a/test/errorhandling.test.js b/test/errorhandling.test.js index 749f293..422f0cc 100644 --- a/test/errorhandling.test.js +++ b/test/errorhandling.test.js @@ -19,29 +19,17 @@ helper.files('errorhandling', 'mml', function(file) { data_dir: path.join(__dirname, '../data'), local_data_dir: path.join(__dirname, 'rendering'), filename: file - }).render(mml, function (err) { - if (!err) { - throw new Error("*** invalid error handling test found: " + basename + ": all error handling tests should throw!"); - } - var result = helper.resultFile(file); - var output = err.message; - // @TODO for some reason, fs.readFile includes an additional \n - // at the end of read files. Determine why. - fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { - if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); - done(); - }); - }); + }).render(mml); } catch(err) { if (err.message.indexOf('***') > -1) throw err; var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. - fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { - if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); - done(); - }); + // fs.writeFileSync(helper.resultFile(file), output); + var data = fs.readFileSync(helper.resultFile(file), 'utf8'); + assert.deepEqual(output, data); + done(); } }); }); @@ -65,29 +53,17 @@ helper.files('errorhandling', 'mss', function(file) { // note: we use the basename here so that the expected error result // will match if the style was loaded from mml filename: basename - }).renderMSS(mss, function (err) { - if (!err) { - throw new Error("*** invalid error handling test found: " + basename + ": all error handling tests should throw!"); - } - var result = helper.resultFile(file); - var output = err.message; - // @TODO for some reason, fs.readFile includes an additional \n - // at the end of read files. Determine why. - fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { - if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); - done(); - }); - }); + }).renderMSS(mss); } catch(err) { if (err.message.indexOf('***') > -1) throw err; var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. - fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { - if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); - done(); - }); + // fs.writeFileSync(helper.resultFile(file), output); + var data = fs.readFileSync(helper.resultFile(file), 'utf8'); + assert.deepEqual(output, data); + done(); } }); }); diff --git a/test/errorhandling/color_functions.result b/test/errorhandling/color_functions.result index c400c05..8d27065 100644 --- a/test/errorhandling/color_functions.result +++ b/test/errorhandling/color_functions.result @@ -1 +1 @@ -color_functions.mss:3:31 incorrect arguments given to hsl() +color_functions.mss:3:31 incorrect arguments given to hsl() \ No newline at end of file diff --git a/test/errorhandling/contradiction.result b/test/errorhandling/contradiction.result index 63c7724..8af476b 100644 --- a/test/errorhandling/contradiction.result +++ b/test/errorhandling/contradiction.result @@ -1 +1 @@ -contradiction.mss:1:37 [[FeatureCla]=] added to [FeatureCla]!= produces an invalid filter +contradiction.mss:1:37 [[FeatureCla]=] added to [FeatureCla]!= produces an invalid filter \ No newline at end of file diff --git a/test/errorhandling/contradiction_2.result b/test/errorhandling/contradiction_2.result index 99588ed..7269ced 100644 --- a/test/errorhandling/contradiction_2.result +++ b/test/errorhandling/contradiction_2.result @@ -1 +1 @@ -contradiction_2.mss:1:37 [[FeatureCla]!=] added to [FeatureCla]= produces an invalid filter +contradiction_2.mss:1:37 [[FeatureCla]!=] added to [FeatureCla]= produces an invalid filter \ No newline at end of file diff --git a/test/errorhandling/function_args.result b/test/errorhandling/function_args.result index d58d33f..a189b88 100644 --- a/test/errorhandling/function_args.result +++ b/test/errorhandling/function_args.result @@ -1 +1 @@ -function_args.mss:3:38 unknown function agg-stack-blu(), did you mean agg-stack-blur(2) +function_args.mss:3:38 unknown function agg-stack-blu(), did you mean agg-stack-blur(2) \ No newline at end of file diff --git a/test/errorhandling/invalid_color_in_fn.result b/test/errorhandling/invalid_color_in_fn.result index 88370e8..8106354 100644 --- a/test/errorhandling/invalid_color_in_fn.result +++ b/test/errorhandling/invalid_color_in_fn.result @@ -1 +1 @@ -invalid_color_in_fn.mss:2:34 incorrect arguments given to spin() +invalid_color_in_fn.mss:2:34 incorrect arguments given to spin() \ No newline at end of file diff --git a/test/errorhandling/invalid_property.result b/test/errorhandling/invalid_property.result index 6daf2ef..d384047 100644 --- a/test/errorhandling/invalid_property.result +++ b/test/errorhandling/invalid_property.result @@ -1 +1 @@ -invalid_property.mss:3:2 Unrecognized rule: polygonopacity. Did you mean polygon-opacity? +invalid_property.mss:3:2 Unrecognized rule: polygonopacity. Did you mean polygon-opacity? \ No newline at end of file diff --git a/test/errorhandling/invalid_value.result b/test/errorhandling/invalid_value.result index 32dc5e9..db5a079 100644 --- a/test/errorhandling/invalid_value.result +++ b/test/errorhandling/invalid_value.result @@ -1,2 +1,2 @@ invalid_value.mss:2:2 Invalid value for text-face-name, the type font is expected. 2 (of type float) was given. -invalid_value.mss:3:2 Invalid value for line-rasterizer, the type keyword (options: full, fast) is expected. full (of type string) was given. +invalid_value.mss:3:2 Invalid value for line-rasterizer, the type keyword (options: full, fast) is expected. full (of type string) was given. \ No newline at end of file diff --git a/test/errorhandling/issue119.result b/test/errorhandling/issue119.result new file mode 100644 index 0000000..1204e91 --- /dev/null +++ b/test/errorhandling/issue119.result @@ -0,0 +1 @@ +issue119.mss:2:2 Map properties are not permitted in other rules \ No newline at end of file diff --git a/test/errorhandling/issue123.result b/test/errorhandling/issue123.result index ed6f8ad..875e815 100644 --- a/test/errorhandling/issue123.result +++ b/test/errorhandling/issue123.result @@ -1 +1 @@ -issue123.mss:3:31 incorrect number of arguments for darken(). 2 expected. +issue123.mss:3:31 incorrect number of arguments for darken(). 2 expected. \ No newline at end of file diff --git a/test/errorhandling/issue124.result b/test/errorhandling/issue124.result new file mode 100644 index 0000000..3fd8797 --- /dev/null +++ b/test/errorhandling/issue124.result @@ -0,0 +1 @@ +issue124.mss:6:0 missing closing `}` \ No newline at end of file diff --git a/test/errorhandling/issue297.result b/test/errorhandling/issue297.result index 422c58e..ecb845f 100644 --- a/test/errorhandling/issue297.result +++ b/test/errorhandling/issue297.result @@ -1 +1 @@ -issue297.mss:2:2 Invalid value for text-name, the type expression is expected. invalid (of type keyword) was given. +issue297.mss:2:2 Invalid value for text-name, the type expression is expected. invalid (of type keyword) was given. \ No newline at end of file diff --git a/test/errorhandling/issue_204_a.result b/test/errorhandling/issue_204_a.result new file mode 100644 index 0000000..ca4418e --- /dev/null +++ b/test/errorhandling/issue_204_a.result @@ -0,0 +1 @@ +issue_204_a.mss:3:1 missing opening `{` \ No newline at end of file diff --git a/test/errorhandling/issue_204_b.result b/test/errorhandling/issue_204_b.result new file mode 100644 index 0000000..1ddd28f --- /dev/null +++ b/test/errorhandling/issue_204_b.result @@ -0,0 +1 @@ +issue_204_b.mss:3:3 missing opening `{` \ No newline at end of file diff --git a/test/errorhandling/issue_204_c.result b/test/errorhandling/issue_204_c.result new file mode 100644 index 0000000..8588127 --- /dev/null +++ b/test/errorhandling/issue_204_c.result @@ -0,0 +1 @@ +issue_204_c.mss:4:0 missing opening `{` \ No newline at end of file diff --git a/test/errorhandling/issue_218.result b/test/errorhandling/issue_218.result new file mode 100644 index 0000000..2acca5c --- /dev/null +++ b/test/errorhandling/issue_218.result @@ -0,0 +1 @@ +issue_218.mss:5:2 missing opening `{` \ No newline at end of file diff --git a/test/errorhandling/mapnik_keyword.result b/test/errorhandling/mapnik_keyword.result index d44a1dc..598985b 100644 --- a/test/errorhandling/mapnik_keyword.result +++ b/test/errorhandling/mapnik_keyword.result @@ -1 +1 @@ -mapnik_keyword.mss:1:6 nul is not a valid keyword in a filter expression +mapnik_keyword.mss:1:6 nul is not a valid keyword in a filter expression \ No newline at end of file diff --git a/test/errorhandling/missing_close.result b/test/errorhandling/missing_close.result index b178bb7..29e63fb 100644 --- a/test/errorhandling/missing_close.result +++ b/test/errorhandling/missing_close.result @@ -1 +1 @@ -missing_close.mss:1:5 Missing closing ] of filter. +missing_close.mss:1:5 Missing closing ] of filter. \ No newline at end of file diff --git a/test/errorhandling/multi_stylesheets.result b/test/errorhandling/multi_stylesheets.result new file mode 100644 index 0000000..74ff117 --- /dev/null +++ b/test/errorhandling/multi_stylesheets.result @@ -0,0 +1 @@ +multi_stylesheets_b.mss:2:2 Unrecognized rule: polygonopacity. Did you mean polygon-opacity? \ No newline at end of file diff --git a/test/errorhandling/multi_stylesheets_b.result b/test/errorhandling/multi_stylesheets_b.result new file mode 100644 index 0000000..74ff117 --- /dev/null +++ b/test/errorhandling/multi_stylesheets_b.result @@ -0,0 +1 @@ +multi_stylesheets_b.mss:2:2 Unrecognized rule: polygonopacity. Did you mean polygon-opacity? \ No newline at end of file diff --git a/test/errorhandling/nopound.result b/test/errorhandling/nopound.result new file mode 100644 index 0000000..eebd7da --- /dev/null +++ b/test/errorhandling/nopound.result @@ -0,0 +1 @@ +nopound.mss:1:0 Invalid code: world { diff --git a/test/errorhandling/notenoughargs.result b/test/errorhandling/notenoughargs.result new file mode 100644 index 0000000..5ee5ba2 --- /dev/null +++ b/test/errorhandling/notenoughargs.result @@ -0,0 +1 @@ +notenoughargs.mss:3:31 incorrect number of arguments for darken(). 2 expected. \ No newline at end of file diff --git a/test/errorhandling/undefined_variable.result b/test/errorhandling/undefined_variable.result index ff2e384..2a6c6cc 100644 --- a/test/errorhandling/undefined_variable.result +++ b/test/errorhandling/undefined_variable.result @@ -1,3 +1,3 @@ undefined_variable.mss:2:16 variable @something is undefined undefined_variable.mss:3:14 variable @something is undefined -undefined_variable.mss:4:22 variable @something is undefined +undefined_variable.mss:4:22 variable @something is undefined \ No newline at end of file diff --git a/test/errorhandling/zoom_as_var.result b/test/errorhandling/zoom_as_var.result index 3c5d9fc..b1849cd 100644 --- a/test/errorhandling/zoom_as_var.result +++ b/test/errorhandling/zoom_as_var.result @@ -1 +1 @@ -zoom_as_var.mss:2:2 Cannot do math with type keyword. +zoom_as_var.mss:2:2 Cannot do math with type keyword. \ No newline at end of file diff --git a/test/errorhandling/zoommax.result b/test/errorhandling/zoommax.result index 23e7cbc..d93ec43 100644 --- a/test/errorhandling/zoommax.result +++ b/test/errorhandling/zoommax.result @@ -1 +1 @@ -zoommax.mss:1:6 Only zoom levels between 0 and 22 supported. +zoommax.mss:1:6 Only zoom levels between 0 and 22 supported. \ No newline at end of file