Replace parboiled with custom built version
Parboiled library was updated to work with asm 5 library: [1], [2].
Unfortunately this version wasn't released yet.
Since change If5009c676, Gerrit itself depends on asm 5.0.3.
Add a test to verify parboiled behaviour, and update to use a custom
built version of the latest master including support for asm 5.
[1] https://github.com/sirthias/parboiled/issues/76
[2] 41b3c1282b
Change-Id: I9cbc8e8f685aa87056f8beb17ab40104b4a129a1
			
			
This commit is contained in:
		 David Ostrovsky
					David Ostrovsky
				
			
				
					committed by
					
						 David Pursehouse
						David Pursehouse
					
				
			
			
				
	
			
			
			 David Pursehouse
						David Pursehouse
					
				
			
						parent
						
							8cdfe6d960
						
					
				
				
					commit
					34545b5fe3
				
			| @@ -189,6 +189,7 @@ java_test( | ||||
|  | ||||
| java_test( | ||||
|   name = 'server_tests', | ||||
|   labels = ['server'], | ||||
|   srcs = glob( | ||||
|     ['src/test/java/**/*.java'], | ||||
|     excludes = TESTUTIL + PROLOG_TESTS + PROLOG_TEST_CASE + QUERY_TESTS | ||||
| @@ -212,6 +213,8 @@ java_test( | ||||
|     '//lib/jgit:jgit', | ||||
|     '//lib/jgit:junit', | ||||
|     '//lib/joda:joda-time', | ||||
|     '//lib:parboiled-core', | ||||
|     '//lib:parboiled-java', | ||||
|     '//lib/prolog:prolog-cafe', | ||||
|   ], | ||||
|   source_under_test = [':server'], | ||||
|   | ||||
| @@ -0,0 +1,75 @@ | ||||
| // Copyright (C) 2014 The Android Open Source Project | ||||
| // | ||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| // you may not use this file except in compliance with the License. | ||||
| // You may obtain a copy of the License at | ||||
| // | ||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||
| // | ||||
| // Unless required by applicable law or agreed to in writing, software | ||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
|  | ||||
| package com.google.gerrit.server.util; | ||||
|  | ||||
| import static com.google.common.truth.Truth.assertThat; | ||||
|  | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.parboiled.BaseParser; | ||||
| import org.parboiled.Parboiled; | ||||
| import org.parboiled.Rule; | ||||
| import org.parboiled.annotations.BuildParseTree; | ||||
| import org.parboiled.parserunners.ReportingParseRunner; | ||||
| import org.parboiled.support.ParseTreeUtils; | ||||
| import org.parboiled.support.ParsingResult; | ||||
|  | ||||
| public class ParboiledTest { | ||||
|  | ||||
|   private static final String EXPECTED = | ||||
|   "[Expression] '42'\n" + | ||||
|   "  [Term] '42'\n" + | ||||
|   "    [Factor] '42'\n" + | ||||
|   "      [Number] '42'\n" + | ||||
|   "        [0..9] '4'\n" + | ||||
|   "        [0..9] '2'\n" + | ||||
|   "    [ZeroOrMore]\n" + | ||||
|   "  [ZeroOrMore]\n"; | ||||
|  | ||||
|   private CalculatorParser parser; | ||||
|  | ||||
|   @Before | ||||
|   public void setUp() { | ||||
|     parser = Parboiled.createParser(CalculatorParser.class); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void test() { | ||||
|     ParsingResult<String> result = | ||||
|         new ReportingParseRunner<String>(parser.Expression()).run("42"); | ||||
|     assertThat(result.hasErrors()).isFalse(); | ||||
|     // next test is optional; we could stop here. | ||||
|     assertThat(ParseTreeUtils.printNodeTree(result)).isEqualTo(EXPECTED); | ||||
|   } | ||||
|  | ||||
|   @BuildParseTree | ||||
|   static class CalculatorParser extends BaseParser<Object> { | ||||
|     Rule Expression() { | ||||
|       return Sequence(Term(), ZeroOrMore(AnyOf("+-"), Term())); | ||||
|     } | ||||
|  | ||||
|     Rule Term() { | ||||
|       return Sequence(Factor(), ZeroOrMore(AnyOf("*/"), Factor())); | ||||
|     } | ||||
|  | ||||
|     Rule Factor() { | ||||
|       return FirstOf(Number(), Sequence('(', Expression(), ')')); | ||||
|     } | ||||
|  | ||||
|     Rule Number() { | ||||
|       return OneOrMore(CharRange('0', '9')); | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										7
									
								
								lib/BUCK
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								lib/BUCK
									
									
									
									
									
								
							| @@ -132,8 +132,8 @@ maven_jar( | ||||
|  | ||||
| maven_jar( | ||||
|   name = 'parboiled-java', | ||||
|   id = 'org.parboiled:parboiled-java:1.1.6', | ||||
|   sha1 = 'cb2ffa720f75b2fce8cfd1875599319e75ea9557', | ||||
|   id = 'org.parboiled:parboiled-java:1.1.6-14-g76586a4', | ||||
|   sha1 = '8cbe0bd4d41c4e2dc0db1107719ca44132f87fed', | ||||
|   license = 'Apache2.0', | ||||
|   deps = [ | ||||
|     ':parboiled-core', | ||||
| @@ -142,7 +142,8 @@ maven_jar( | ||||
|     '//lib/ow2:ow2-asm-util', | ||||
|   ], | ||||
|   attach_source = False, | ||||
|   visibility = [], | ||||
|   visibility = ['//gerrit-server:server_tests'], | ||||
|   repository = GERRIT, | ||||
| ) | ||||
|  | ||||
| maven_jar( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user