Skip to content
Permalink
Browse files

Merge pull request #5 from slide/7f437947b485d56895cff3a6e48450d6192e…

…26bb

Fix JENKINS-12685
Thanks !
  • Loading branch information
olamy committed Feb 15, 2012
2 parents da2858d + 7f43794 commit 38919bf309fc93f985481959da1705ab1dcd9456
@@ -61,7 +61,7 @@

private static final String delimitedTokenRegex = "\\{" + spaceRegex + "(" + tokenNameRegex + ")" + argsRegex + spaceRegex + "\\}";

private static final String tokenRegex = "\\$((" + tokenNameRegex + ")|(" + delimitedTokenRegex + "))";
private static final String tokenRegex = "(?<!\\\\)\\$((" + tokenNameRegex + ")|(" + delimitedTokenRegex + "))";

private static final Pattern argPattern = Pattern.compile(argRegex);

@@ -37,6 +37,19 @@ public void testNested() throws Exception {

assertEquals("{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"${TEST_NESTED}"));
}

public void testEscaped() throws Exception {
FreeStyleProject p = createFreeStyleProject("foo");
FreeStyleBuild b = p.scheduleBuild2(0).get();

listener = new StreamTaskListener(System.out);
assertEquals("\\${TEST_NESTED}",TokenMacro.expand(b,listener,"\\${TEST_NESTED}"));
assertEquals("\\$TEST_NESTED",TokenMacro.expand(b,listener,"\\$TEST_NESTED"));
assertEquals("\\$TEST_NESTED{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"\\$TEST_NESTED$TEST_NESTED"));
assertEquals("\\${TEST_NESTED}{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"\\${TEST_NESTED}$TEST_NESTED"));
assertEquals("{abc=[def, ghi], jkl=[true]}\\$TEST_NESTED",TokenMacro.expand(b,listener,"$TEST_NESTED\\$TEST_NESTED"));
assertEquals("{abc=[def, ghi], jkl=[true]}\\${TEST_NESTED}",TokenMacro.expand(b,listener,"$TEST_NESTED\\${TEST_NESTED}"));
}

@TestExtension
public static class TestMacro extends TokenMacro {

0 comments on commit 38919bf

Please sign in to comment.
You can’t perform that action at this time.