提交 51562a2a 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-8537] expanded the grammer to support binary operator sequence

上级 3a434230
......@@ -60,7 +60,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Label expression logic wasn't supporting a binary operator sequence like "a || b || c"
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-8537">issue 8537</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -41,9 +41,10 @@ returns [Label l]
term1
returns [Label l]
{ Label r; }
: l=term2( IFF r=term2 {l=l.iff(r);} )?
: l=term2( IFF r=term2 {l=l.iff(r);} )*
;
// (a->b)->c != a->(b->c) (for example in case of a=F,b=T,c=F) so don't allow chaining
term2
returns [Label l]
{ Label r; }
......@@ -53,13 +54,13 @@ returns [Label l]
term3
returns [Label l]
{ Label r; }
: l=term4 ( OR r=term4 {l=l.or(r);} )?
: l=term4 ( OR r=term4 {l=l.or(r);} )*
;
term4
returns [Label l]
{ Label r; }
: l=term5 ( AND r=term5 {l=l.and(r);} )?
: l=term5 ( AND r=term5 {l=l.and(r);} )*
;
term5
......
......@@ -34,6 +34,7 @@ import hudson.model.Label;
import hudson.model.Node.Mode;
import hudson.slaves.DumbSlave;
import hudson.slaves.RetentionStrategy;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SequenceLock;
import org.jvnet.hudson.test.TestBuilder;
......@@ -135,6 +136,11 @@ public class LabelExpressionTest extends HudsonTestCase {
parseAndVerify("!foo<->bar", "!foo <-> bar");
}
@Bug(8537)
public void testParser2() throws Exception {
parseAndVerify("aaa&&bbb&&ccc","aaa&&bbb&&ccc");
}
private void parseAndVerify(String expected, String expr) throws ANTLRException {
assertEquals(expected, LabelExpression.parseExpression(expr).getName());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册