summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorNeil Guzman2013-06-11 11:09:40 (EDT)
committer Alexander Kurtakov2013-06-14 10:34:40 (EDT)
commit147fe95b9f3f3fd3d813166f804685bec2ad904c (patch)
treec6b41f45042ac6a39810d71365d7105b53802227
parentb991db9d4412be76a4e1f3f92a0701e1e1cb27cd (diff)
downloadorg.eclipse.linuxtools-147fe95b9f3f3fd3d813166f804685bec2ad904c.zip
org.eclipse.linuxtools-147fe95b9f3f3fd3d813166f804685bec2ad904c.tar.gz
org.eclipse.linuxtools-147fe95b9f3f3fd3d813166f804685bec2ad904c.tar.bz2
rpm: resolve defines will resolve whole word onlyrefs/changes/50/13750/4
Previously resolves any word that has a macro define in it (e.g. "version" in "version_suffix" will resolve to %{version}_suffix). Now it will only resolve the whole word amend: added test case Change-Id: Ife8aefb5cde5c672a16497802c00270b9db66afc Reviewed-on: https://git.eclipse.org/r/13750 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/parser/SpecfileDefineTest.java12
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/UiUtils.java2
2 files changed, 12 insertions, 2 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/parser/SpecfileDefineTest.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/parser/SpecfileDefineTest.java
index dcc8aec..8b46ef6 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/parser/SpecfileDefineTest.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/parser/SpecfileDefineTest.java
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.internal.rpm.ui.editor.UiUtils;
import org.eclipse.linuxtools.rpm.ui.editor.markers.SpecfileErrorHandler;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement;
@@ -41,7 +42,11 @@ public class SpecfileDefineTest extends FileTestCase {
// Characters 96 through 109
"%define -n -p" + "\n" +
// Characters 110 through 144
- "%define __find_requires %{SOURCE3}";
+ "%define __find_requires %{SOURCE3}" + "\n" +
+ // Characters 145 through 180
+ "%global version_suffix 201302130906" + "\n" +
+ // Characters 181 through 195
+ "Version: 2.3.0" + "\n";
@Override
@Before
@@ -134,5 +139,10 @@ public class SpecfileDefineTest extends FileTestCase {
assertEquals("__find_requires", blahDefine.getName());
assertEquals("%{SOURCE3}", blahDefine.getStringValue());
}
+ @Test
+ public void testWholeWordResolveDefine() {
+ String testResolve = UiUtils.resolveDefines(specfile, "%{version}.%{version_suffix}");
+ assertEquals(testResolve, "2.3.0.201302130906");
+ }
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/UiUtils.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/UiUtils.java
index 12ff0af..f45e27f 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/UiUtils.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/UiUtils.java
@@ -68,7 +68,7 @@ public class UiUtils {
while (variableMatcher.find()) {
define = specfile.getDefine(variableMatcher.group(1));
if (define != null) {
- stringToResolve = stringToResolve.replaceAll(variableMatcher.group(1), define.getStringValue());
+ stringToResolve = stringToResolve.replaceAll("\\b"+variableMatcher.group(1)+"\\b", define.getStringValue());
} else {
return originalString;
}