mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
bug 295290: JUnit failure: ManagedBuildMacrosTests.testMacroOptL()
test case fixed
This commit is contained in:
parent
2f140d6523
commit
ee9e75b76f
1 changed files with 21 additions and 14 deletions
|
@ -13,6 +13,8 @@ package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
@ -67,14 +69,16 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
|
|
||||||
static final String UNKNOWN = "<HZ>"; //$NON-NLS-1$
|
static final String UNKNOWN = "<HZ>"; //$NON-NLS-1$
|
||||||
static final String LISTSEP = "|"; //$NON-NLS-1$
|
static final String LISTSEP = "|"; //$NON-NLS-1$
|
||||||
|
static final String LISTSEP_REGEX = "\\|"; //$NON-NLS-1$
|
||||||
static final String TEST = "TEST"; //$NON-NLS-1$
|
static final String TEST = "TEST"; //$NON-NLS-1$
|
||||||
static final String[] TST = {"DUMMY", "FILETEST", //$NON-NLS-1$ //$NON-NLS-2$
|
static final String[] TST = {"DUMMY", "FILETEST", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
"OPTTEST", "CFGTEST", "PRJTEST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"OPTTEST", "CFGTEST", "PRJTEST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"WSPTEST", "INSTEST", "ENVTEST"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"WSPTEST", "INSTEST", "ENVTEST"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// used for options testing
|
// used for options testing
|
||||||
final String OPT_IDS = "macro.test.string"; //$NON-NLS-1$
|
static final String OPT_IDS = "macro.test.string"; //$NON-NLS-1$
|
||||||
final String OPT_IDL = "macro.test.list"; //$NON-NLS-1$
|
static final String OPT_IDL = "macro.test.list"; //$NON-NLS-1$
|
||||||
final String INC_DEF = "${IncludeDefaults}";//$NON-NLS-1$
|
static final String INC_DEF = "${IncludeDefaults}";//$NON-NLS-1$
|
||||||
|
static final String PATH_ENV_VAR = "${PATH}"; //$NON-NLS-1$
|
||||||
|
|
||||||
public ManagedBuildMacrosTests() { super(); }
|
public ManagedBuildMacrosTests() { super(); }
|
||||||
public ManagedBuildMacrosTests(String name) { super(name); }
|
public ManagedBuildMacrosTests(String name) { super(name); }
|
||||||
|
@ -237,12 +241,16 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
try {
|
try {
|
||||||
String[] set0 = opt.getStringListValue();
|
String[] set0 = opt.getStringListValue();
|
||||||
assertNotNull(set0);
|
assertNotNull(set0);
|
||||||
final String[] set1 = {"new a", /*"test=${TEST}",*/ INC_DEF, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
final String[] set1 = {"new a", /*"test=${TEST}",*/ INC_DEF,
|
||||||
"${PATH}", "PRJ=${NEW_FOR_PRJ}", "LIST=" + INC_DEF};//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"PRJ=${NEW_FOR_PRJ}", "LIST=" + INC_DEF, PATH_ENV_VAR};
|
||||||
String[] res1 = {"new a", /*"test=CFGTEST",*/ "x", "y", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
String[] resArr1 = {"new a", /*"test=CFGTEST",*/ "x", "y",
|
||||||
"z", ":", "PRJ=NewMacrosForProjectContext", "LIST=x|y|z"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
"z", "PRJ=NewMacrosForProjectContext", "LIST=x|y|z"};
|
||||||
|
List<String> res1 = new ArrayList<String>(Arrays.asList(resArr1));
|
||||||
try {
|
try {
|
||||||
res1[4] = mp.resolveValue("${Path}", UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, ocd); //$NON-NLS-1$
|
// Add split ${PATH} to res1
|
||||||
|
String strList = mp.resolveValue(PATH_ENV_VAR, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
||||||
|
String[] split = strList.split(LISTSEP_REGEX);
|
||||||
|
res1.addAll(Arrays.asList(split));
|
||||||
} catch (BuildMacroException e) {
|
} catch (BuildMacroException e) {
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -250,7 +258,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
opt = cfgs[0].setOption(t, opt, set1);
|
opt = cfgs[0].setOption(t, opt, set1);
|
||||||
assertNotNull(opt);
|
assertNotNull(opt);
|
||||||
|
|
||||||
ArrayList<String> ar = new ArrayList<String>(1);
|
ArrayList<String> res2 = new ArrayList<String>(res1.size());
|
||||||
for (int i = 0; i < set1.length; i++) {
|
for (int i = 0; i < set1.length; i++) {
|
||||||
try {
|
try {
|
||||||
String[] aus = mp.resolveStringListValue(set1[i], UNKNOWN, LISTSEP,
|
String[] aus = mp.resolveStringListValue(set1[i], UNKNOWN, LISTSEP,
|
||||||
|
@ -258,15 +266,14 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
if (aus == null)
|
if (aus == null)
|
||||||
continue;
|
continue;
|
||||||
for (int j = 0; j < aus.length; j++)
|
for (int j = 0; j < aus.length; j++)
|
||||||
ar.add(aus[j]);
|
res2.add(aus[j]);
|
||||||
} catch (BuildMacroException e) {
|
} catch (BuildMacroException e) {
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] res = ar.toArray(new String[0]);
|
assertEquals(res1.size(), res2.size());
|
||||||
assertEquals(res.length, res1.length);
|
for (int i = 0; i < res1.size(); i++)
|
||||||
for (int i = 0; i < res.length; i++)
|
assertEquals(res1.get(i), res2.get(i));
|
||||||
assertEquals(res[i], res1[i]);
|
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue