GWicke has submitted this change and it was merged.

Change subject: Parse "options" sections in parserTests.txt test cases.
......................................................................


Parse "options" sections in parserTests.txt test cases.

Change-Id: I5ff431491575af9975101165c29e58550a1b6439
---
M js/tests/parserTests.js
M js/tests/parserTests.pegjs
2 files changed, 58 insertions(+), 3 deletions(-)

Approvals:
  GWicke: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index ce15b86..08905d5 100644
--- a/js/tests/parserTests.js
+++ b/js/tests/parserTests.js
@@ -91,6 +91,14 @@
        this.stats.modes = newModes;
 }
 
+var prettyPrintIOptions = function(iopts) {
+       if (!iopts) { return ''; }
+       return Object.keys(iopts).map(function(k) {
+               if (iopts[k]==='') { return k; }
+               return k+'='+iopts[k];
+       }).join(' ');
+};
+
 /**
  * Get the options from the command line.
  */
@@ -697,7 +705,7 @@
 
                if ( options ) {
                        console.log( 'OPTIONS'.cyan + ':' );
-                       console.log( iopts + '\n' );
+                       console.log( prettyPrintIOptions(iopts) + '\n' );
                }
 
                console.log( 'INPUT'.cyan + ':' );
diff --git a/js/tests/parserTests.pegjs b/js/tests/parserTests.pegjs
index 7e33d39..bcf8f08 100644
--- a/js/tests/parserTests.pegjs
+++ b/js/tests/parserTests.pegjs
@@ -100,7 +100,7 @@
 test =
     start_test
     title:text
-    sections:section*
+    sections:(section / option_section)*
     end_test
 {
     var test = {
@@ -115,7 +115,7 @@
 }
 
 section =
-    "!!" ws? (!"end") name:(c:[a-zA-Z0-9]+ { return c.join(''); }) rest_of_line
+    "!!" ws? (!"end") (!"options") name:(c:[a-zA-Z0-9]+ { return c.join(''); 
}) rest_of_line
     text:text
 {
     return {
@@ -124,6 +124,53 @@
     };
 }
 
+option_section =
+    "!!" ws? "options" ws? eol
+    opts:option_list?
+{
+    var o = {};
+    if (opts && opts.length) {
+        for (var i = 0; i < opts.length; i++) {
+            o[opts[i].k] = opts[i].v || '';
+        }
+    }
+    return {
+        name: "options",
+        text: o
+    };
+}
+
+option_list = o:an_option [ \t\n]+ rest:option_list?
+{
+    var result = [ o ];
+    if (rest && rest.length) {
+        result.push.apply(result, rest);
+    }
+    return result;
+}
+
+an_option = simple_option / prefix_option
+
+simple_option = k:("pst"i / "msg"i / "cat"i / "ill"i / "subpage"i /
+                   "noxml"i / "disabled"i / "showtitle"i / "comment"i /
+                   "local"i / "rawhtml"i / "preload"i )
+{
+    return {k:k.toLowerCase()};
+}
+prefix_option = title_option / nospace_prefix_option
+
+nospace_prefix_option = k:(c:[^ \t\n=]+ { return c.join(''); }) ws? "=" ws?
+                  v:(c:[^ \t\n]+ { return c.join(''); })
+{
+    return {k:k, v:v};
+}
+
+title_option = k:"title" ws? "=" ws?
+               v:("[[" (c:[^\]]+ { return c.join(''); }) "]]")
+{
+    return {k:k, v:"[["+v+"]]"};
+}
+
 /* the : is for a stray one, not sure it should be there */
 
 start_test =

-- 
To view, visit https://gerrit.wikimedia.org/r/50259
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5ff431491575af9975101165c29e58550a1b6439
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to