mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 564123 Remove long commented out and dead test code
Change-Id: I0022463409db4de701b3ad18e1309f894d499e2a
This commit is contained in:
parent
8c1be591ff
commit
ef79d15071
2 changed files with 0 additions and 972 deletions
|
@ -32,29 +32,14 @@ import junit.framework.TestSuite;
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
public class ManagedBuildEnvironmentTests extends TestCase {
|
public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
// final private String REQUIRED_TYPE = "cdt.managedbuild.target.testgnu.exe"; //$NON-NLS-1$
|
|
||||||
// test variable names
|
// test variable names
|
||||||
final private String NAME_CWD = "CWD"; //$NON-NLS-1$
|
final private String NAME_CWD = "CWD"; //$NON-NLS-1$
|
||||||
final private String NAME_PWD = "PWD"; //$NON-NLS-1$
|
final private String NAME_PWD = "PWD"; //$NON-NLS-1$
|
||||||
// final private String NAME_CMN = "COMMON"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_WSP = "WSP"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_PRJI = "PRJI"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_PRJL = "PRJL"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_CFGI = "CFGI"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_CFGL = "CFGL"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_CFGX = "CFGX"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_CFG = "CFG"; //$NON-NLS-1$
|
|
||||||
// final private String NAME_REM1 = "REMTST1";//$NON-NLS-1$
|
|
||||||
// final private String NAME_REM2 = "REMTST2";//$NON-NLS-1$
|
|
||||||
// test variable values
|
// test variable values
|
||||||
final private String VAL_CWDPWD = "CWD_&_PWD_should not be changed"; //$NON-NLS-1$
|
final private String VAL_CWDPWD = "CWD_&_PWD_should not be changed"; //$NON-NLS-1$
|
||||||
// final private String VAL_DUMMY1 = "/a/b/c"; //$NON-NLS-1$
|
|
||||||
// final private String VAL_DUMMY2 = "/d/e/f"; //$NON-NLS-1$
|
|
||||||
final private String VAL_PRO_INC = "/project/inc"; //$NON-NLS-1$
|
final private String VAL_PRO_INC = "/project/inc"; //$NON-NLS-1$
|
||||||
final private String VAL_PRO_LIB = "/project/lib"; //$NON-NLS-1$
|
final private String VAL_PRO_LIB = "/project/lib"; //$NON-NLS-1$
|
||||||
|
|
||||||
// final private String LISTENER_DATA = "O1T1O1O2T2T1O1T1O2T2"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
// delimiters
|
// delimiters
|
||||||
final private String DEL_WIN = ";"; //$NON-NLS-1$
|
final private String DEL_WIN = ";"; //$NON-NLS-1$
|
||||||
final private String DEL_UNIX = ":"; //$NON-NLS-1$
|
final private String DEL_UNIX = ":"; //$NON-NLS-1$
|
||||||
|
@ -82,16 +67,6 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite(ManagedBuildEnvironmentTests.class/*.getName()*/);
|
TestSuite suite = new TestSuite(ManagedBuildEnvironmentTests.class/*.getName()*/);
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvNotDef")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvUpper")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvAppend")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvCWDPWD")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvSuppliers")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetPath")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvSubscribe")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvGetParams")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvRemove")); //$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildEnvironmentTests("testEnvProvider")); //$NON-NLS-1$
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,57 +77,6 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking behaviour when vars are not defined (except system)
|
|
||||||
public void testEnvNotDef() {
|
|
||||||
doInit();
|
|
||||||
assertNotNull("System vars", envProvider.getVariables(null, true, false)); //$NON-NLS-1$
|
|
||||||
assertNotNull("Worksp. vars", envProvider.getVariables(worksp, true, false)); //$NON-NLS-1$
|
|
||||||
assertNotNull("Project vars", envProvider.getVariables(mproj, true, false)); //$NON-NLS-1$
|
|
||||||
IConfiguration[] cfgs = mproj.getConfigurations();
|
|
||||||
for (int k = 0; k < cfgs.length; k++) {
|
|
||||||
assertNotNull("Project vars[" + k + "]", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
envProvider.getVariables(cfgs[k], true, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* testEnvUpper - check uplevel variables
|
|
||||||
* In each context, up-level vars should be returned
|
|
||||||
*/
|
|
||||||
// public void testEnvUpper(){
|
|
||||||
// doInit();
|
|
||||||
// addTestVariables();
|
|
||||||
// IBuildEnvironmentVariable[] a = envProvider.getVariables(null, true, false);
|
|
||||||
// IBuildEnvironmentVariable[] b = envProvider.getVariables(worksp, true, false);
|
|
||||||
// assertTrue(varListContainNames(a, b));
|
|
||||||
// IBuildEnvironmentVariable[] c = envProvider.getVariables(mproj, true, false);
|
|
||||||
// assertTrue(varListContainNames(b, c));
|
|
||||||
//
|
|
||||||
// IConfiguration[] cfgs = mproj.getConfigurations();
|
|
||||||
// for (int k=0; k<cfgs.length; k++) {
|
|
||||||
// IBuildEnvironmentVariable[] d = envProvider.getVariables(cfgs[k], true, false);
|
|
||||||
// assertTrue(varListContainNames(c, d));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// public void testEnvAppend(){
|
|
||||||
// doInit();
|
|
||||||
//
|
|
||||||
// IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CMN, worksp, true, false);
|
|
||||||
// assertEquals(NAME_WSP, a.getValue());
|
|
||||||
//
|
|
||||||
// assertNotNull(a = envProvider.getVariable(NAME_CMN, mproj, true, false));
|
|
||||||
// assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI, a.getValue());
|
|
||||||
//
|
|
||||||
// IConfiguration cfg = mproj.getConfigurations()[0];
|
|
||||||
// assertNotNull(a = envProvider.getVariable(NAME_CMN, cfg, true, false));
|
|
||||||
// assertEquals(NAME_WSP+DEL_UNIX+NAME_PRJI+DEL_UNIX+NAME_CFGI, a.getValue());
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -161,97 +85,18 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
doInit();
|
doInit();
|
||||||
IConfiguration cfg = mproj.getConfigurations()[0];
|
IConfiguration cfg = mproj.getConfigurations()[0];
|
||||||
// CWD/PWD vars should NOT be overwritten anywhere
|
// CWD/PWD vars should NOT be overwritten anywhere
|
||||||
// assertNull(envProvider.getVariable(NAME_CWD, worksp, true, false));
|
|
||||||
// assertNull(envProvider.getVariable(NAME_CWD, mproj, true, false));
|
|
||||||
IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CWD, cfg, true, false);
|
IBuildEnvironmentVariable a = envProvider.getVariable(NAME_CWD, cfg, true, false);
|
||||||
assertNotNull(a);
|
assertNotNull(a);
|
||||||
if (VAL_CWDPWD.equals(a.getValue()))
|
if (VAL_CWDPWD.equals(a.getValue()))
|
||||||
fail("CWD should not be rewritten !"); //$NON-NLS-1$
|
fail("CWD should not be rewritten !"); //$NON-NLS-1$
|
||||||
|
|
||||||
// assertNull(envProvider.getVariable(NAME_PWD, worksp, true, false));
|
|
||||||
// assertNull(envProvider.getVariable(NAME_PWD, mproj, true, false));
|
|
||||||
a = envProvider.getVariable(NAME_PWD, cfg, true, false);
|
a = envProvider.getVariable(NAME_PWD, cfg, true, false);
|
||||||
assertNotNull(a);
|
assertNotNull(a);
|
||||||
if (VAL_CWDPWD.equals(a.getValue()))
|
if (VAL_CWDPWD.equals(a.getValue()))
|
||||||
fail("PWD should not be rewritten !"); //$NON-NLS-1$
|
fail("PWD should not be rewritten !"); //$NON-NLS-1$
|
||||||
|
|
||||||
// try to delete: should fail
|
|
||||||
// UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
|
|
||||||
// assertNull(usup.deleteVariable(NAME_CWD, cfg));
|
|
||||||
// assertNull(usup.deleteVariable(NAME_PWD, cfg));
|
|
||||||
// assertNotNull(envProvider.getVariable(NAME_CWD, cfg, true, false));
|
|
||||||
// assertNotNull(envProvider.getVariable(NAME_PWD, cfg, true, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void testEnvSuppliers() {
|
|
||||||
doInit();
|
|
||||||
|
|
||||||
IEnvironmentVariableSupplier[] arrSupSys = envProvider.getSuppliers(null);
|
|
||||||
assertEquals("System suppliers count not equal to 1", arrSupSys.length, 1); //$NON-NLS-1$
|
|
||||||
IBuildEnvironmentVariable[] a = arrSupSys[0].getVariables(null);
|
|
||||||
assertNotNull(a);
|
|
||||||
IBuildEnvironmentVariable[] b = envProvider.getVariables(null, false, false);
|
|
||||||
assertTrue(varListContainNames(a, b));
|
|
||||||
assertTrue(varListContainNames(b, a));
|
|
||||||
|
|
||||||
IEnvironmentVariableSupplier[] arrSupWrk = envProvider.getSuppliers(worksp);
|
|
||||||
assertEquals("Workspace suppliers count not equal to 1", arrSupWrk.length, 1); //$NON-NLS-1$
|
|
||||||
a = arrSupWrk[0].getVariables(worksp);
|
|
||||||
assertNotNull(a);
|
|
||||||
b = envProvider.getVariables(worksp, false, false);
|
|
||||||
assertTrue(varListContainNames(a, b));
|
|
||||||
assertTrue(varListContainNames(b, a));
|
|
||||||
|
|
||||||
IEnvironmentVariableSupplier[] arrSupPro = envProvider.getSuppliers(mproj);
|
|
||||||
assertEquals("Project suppliers count not equal to 2", arrSupPro.length, 2); //$NON-NLS-1$
|
|
||||||
|
|
||||||
b = envProvider.getVariables(mproj, false, false);
|
|
||||||
for (int k=0; k<arrSupPro.length; k++ ) {
|
|
||||||
assertTrue(varListContainNames(arrSupPro[k].getVariables(mproj), b));
|
|
||||||
}
|
|
||||||
|
|
||||||
IConfiguration[] configs = mproj.getConfigurations();
|
|
||||||
for (int j=0; j<configs.length; j++) {
|
|
||||||
b = envProvider.getVariables(configs[j], false, false);
|
|
||||||
IEnvironmentVariableSupplier[] arrSupCfg = envProvider.getSuppliers(configs[j]);
|
|
||||||
assertEquals("Configuration suppliers count not equal to 3", arrSupCfg.length, 3); //$NON-NLS-1$
|
|
||||||
for (int k=0; k<arrSupCfg.length; k++ ) {
|
|
||||||
assertTrue(varListContainNames(arrSupCfg[k].getVariables(configs[j]), b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* plugin.xml contents:
|
|
||||||
<projectType id="cdt.managedbuild.target.testgnu.exe">
|
|
||||||
...
|
|
||||||
<configuration name="Dbg"
|
|
||||||
...
|
|
||||||
<tool
|
|
||||||
...
|
|
||||||
<envVarBuildPath
|
|
||||||
pathType="buildpathInclude"
|
|
||||||
variableList="CFGI,CFG0,PRJI">
|
|
||||||
</envVarBuildPath>
|
|
||||||
<envVarBuildPath
|
|
||||||
pathType="buildpathLibrary"
|
|
||||||
variableList="CFGL,PRJL">
|
|
||||||
</envVarBuildPath>
|
|
||||||
...
|
|
||||||
<configuration name="Rel"
|
|
||||||
...
|
|
||||||
<tool
|
|
||||||
...
|
|
||||||
<envVarBuildPath
|
|
||||||
pathType="buildpathInclude"
|
|
||||||
variableList="CFGI,CFG1,PRJI">
|
|
||||||
</envVarBuildPath>
|
|
||||||
<envVarBuildPath
|
|
||||||
pathType="buildpathLibrary"
|
|
||||||
variableList="CFGL,PRJL">
|
|
||||||
</envVarBuildPath>
|
|
||||||
*/
|
|
||||||
public void rm_testEnvGetPath() {
|
public void rm_testEnvGetPath() {
|
||||||
doInit();
|
doInit();
|
||||||
IConfiguration[] configs = mproj.getConfigurations();
|
IConfiguration[] configs = mproj.getConfigurations();
|
||||||
|
@ -276,85 +121,6 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testEnvSubscribe(){
|
|
||||||
// doInit();
|
|
||||||
// IConfiguration[] configs = mproj.getConfigurations();
|
|
||||||
//
|
|
||||||
// IConfiguration cfg = configs[0];
|
|
||||||
// UserDefinedEnvironmentSupplier usup = getSupplier(cfg, cfg.getName());
|
|
||||||
// assertNotNull(usup);
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// usup.deleteVariable(NAME_CFGI,configs[0]);
|
|
||||||
// usup.deleteVariable(NAME_CFGI,configs[1]);
|
|
||||||
// usup.deleteVariable(NAME_CFG+"0",configs[0]);
|
|
||||||
// usup.deleteVariable(NAME_CFG+"1",configs[0]);
|
|
||||||
// usup.deleteVariable(NAME_CFG+"0",configs[1]);
|
|
||||||
// usup.deleteVariable(NAME_CFG+"1",configs[1]);
|
|
||||||
// usup.deleteVariable(NAME_CFGL,configs[0]);
|
|
||||||
// usup.deleteVariable(NAME_CFGL,configs[1]);
|
|
||||||
// usup.deleteVariable(NAME_PRJI,mproj);
|
|
||||||
// usup.deleteVariable(NAME_PRJL,mproj);
|
|
||||||
// usup.deleteVariable(NAME_CFGX,mproj);
|
|
||||||
// listenerResult = ""; //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// envProvider.subscribe(listener);
|
|
||||||
// // should affect config Deb
|
|
||||||
// usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
|
|
||||||
// assertEquals("Step 1", listenerResult, LISTENER_DATA.substring(0,2)); //$NON-NLS-1$
|
|
||||||
// // should affect config Rel
|
|
||||||
// usup.createVariable(NAME_CFGI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
|
|
||||||
// assertEquals("Step 2", listenerResult, LISTENER_DATA.substring(0,4)); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // should affect config Deb
|
|
||||||
// usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
|
|
||||||
// assertEquals("Step 3", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
|
|
||||||
// // should not affect anything - variable not in path of cfg 0
|
|
||||||
// usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]); //$NON-NLS-1$
|
|
||||||
// assertEquals("Step 4", listenerResult, LISTENER_DATA.substring(0,6)); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // should affect config Deb
|
|
||||||
// usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
|
|
||||||
// assertEquals("Step 5", listenerResult, LISTENER_DATA.substring(0,8)); //$NON-NLS-1$
|
|
||||||
// // should affect config Rel
|
|
||||||
// usup.createVariable(NAME_CFGL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
|
|
||||||
// assertEquals("Step 6", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // should not affect anything - variable not in path of cfg 1
|
|
||||||
// usup.createVariable(NAME_CFG+"0",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
|
|
||||||
// assertEquals("Step 7", listenerResult, LISTENER_DATA.substring(0,10)); //$NON-NLS-1$
|
|
||||||
// // should affect config Rel
|
|
||||||
// usup.createVariable(NAME_CFG+"1",VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]); //$NON-NLS-1$
|
|
||||||
// assertEquals("Step 8", listenerResult, LISTENER_DATA.substring(0,12)); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // should affect both configurations
|
|
||||||
// usup.createVariable(NAME_PRJI,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
|
|
||||||
// assertEquals("Step 9", listenerResult, LISTENER_DATA.substring(0,16)); //$NON-NLS-1$
|
|
||||||
// // should affect both configurations
|
|
||||||
// usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
|
|
||||||
// assertEquals("Step 10", listenerResult, LISTENER_DATA); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // should not affect anything - no changes
|
|
||||||
// usup.createVariable(NAME_PRJL,VAL_DUMMY2,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
|
|
||||||
// assertEquals("Step 11", listenerResult, LISTENER_DATA); //$NON-NLS-1$
|
|
||||||
// // should not affect anything - variable not in path
|
|
||||||
// usup.createVariable(NAME_CFGX,VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
|
|
||||||
// assertEquals("Step 12", listenerResult, LISTENER_DATA); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// envProvider.unsubscribe(listener);
|
|
||||||
//
|
|
||||||
// // should NOT affect anything - subscription cancelled
|
|
||||||
// usup.createVariable(NAME_PRJI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, mproj);
|
|
||||||
// usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[0]);
|
|
||||||
// usup.createVariable(NAME_CFGI,VAL_DUMMY1,IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, configs[1]);
|
|
||||||
// assertEquals("Step 13", listenerResult, LISTENER_DATA); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// fail("Failed to create configuration vars !"); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -387,50 +153,6 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// public void testEnvRemove(){
|
|
||||||
// doInit();
|
|
||||||
// IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
|
|
||||||
// UserDefinedEnvironmentSupplier usup = null;
|
|
||||||
//
|
|
||||||
// // create vars for removal tests
|
|
||||||
// assertNotNull(usup = getSupplier(worksp, "Workspace")); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_REPLACE, DEL_UNIX, worksp));
|
|
||||||
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
// assertNotNull(usup = getSupplier(mproj, "Project")); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM1, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, mproj));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM2, VAL_DUMMY2, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
|
|
||||||
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
// IConfiguration cfg = mproj.getConfigurations()[0];
|
|
||||||
// assertNotNull(usup = getSupplier(cfg, "Configuration 0")); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM1, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_REM2, VAL_CWDPWD, IBuildEnvironmentVariable.ENVVAR_REMOVE, DEL_UNIX, cfg));
|
|
||||||
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
// // Check vars presence/absence on different levels
|
|
||||||
// IBuildEnvironmentVariable a = env.getVariable(NAME_REM1, worksp, true, false);
|
|
||||||
// IBuildEnvironmentVariable b = env.getVariable(NAME_REM2, worksp, true, false);
|
|
||||||
// assertNotNull(a);
|
|
||||||
// assertNotNull(b);
|
|
||||||
// a = env.getVariable(NAME_REM1, mproj, true, false);
|
|
||||||
// b = env.getVariable(NAME_REM2, mproj, true, false);
|
|
||||||
// assertNull(a);
|
|
||||||
// assertNotNull(b);
|
|
||||||
// assertEquals(b.getValue(), VAL_DUMMY1 + DEL_UNIX + VAL_DUMMY2);
|
|
||||||
// a = env.getVariable(NAME_REM1, cfg, true, false);
|
|
||||||
// b = env.getVariable(NAME_REM2, cfg, true, false);
|
|
||||||
// assertNull(a);
|
|
||||||
// assertNull(b);
|
|
||||||
// }
|
|
||||||
/**
|
/**
|
||||||
* testEnvProvider() -
|
* testEnvProvider() -
|
||||||
*/
|
*/
|
||||||
|
@ -450,97 +172,8 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
a = envProvider.getVariable(TestMacro.CFG_VAR, cfgs[1], true, false);
|
a = envProvider.getVariable(TestMacro.CFG_VAR, cfgs[1], true, false);
|
||||||
assertNull(a);
|
assertNull(a);
|
||||||
|
|
||||||
// combination user-defined and provided variables
|
|
||||||
// UserDefinedEnvironmentSupplier usup = getSupplier(cfgs[0], cfgs[0].getName());
|
|
||||||
// usup.createVariable(TestMacro.PRJ_VAR, VAL_DUMMY1, IBuildEnvironmentVariable.ENVVAR_PREPEND, DEL_UNIX, cfgs[0]);
|
|
||||||
// a = envProvider.getVariable(TestMacro.PRJ_VAR, cfgs[0], true, false);
|
|
||||||
// assertNotNull(a);
|
|
||||||
// assertEquals(VAL_DUMMY1+DEL_UNIX+TestMacro.PRJ_VAR+mproj.getName(), a.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This test is not used iun suite. It just prints variabes
|
|
||||||
*/
|
|
||||||
// public void testEnvPrint(){
|
|
||||||
// doInit();
|
|
||||||
// printVar("s-Var", envProvider.getVariables(null, false, false)); //$NON-NLS-1$
|
|
||||||
// printVar("w-Var", envProvider.getVariables(worksp, false, false)); //$NON-NLS-1$
|
|
||||||
// printVar("p-Var", envProvider.getVariables(mproj, false, false)); //$NON-NLS-1$
|
|
||||||
// IConfiguration[] cfgs = mproj.getConfigurations();
|
|
||||||
// for (int k=0; k<cfgs.length; k++) {
|
|
||||||
// printVar("c[" + k + "]-Var", envProvider.getVariables(cfgs[k], false, false)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Create all required user variables
|
|
||||||
|
|
||||||
// public static UserDefinedEnvironmentSupplier getSupplier(Object obj, String objName) {
|
|
||||||
// IEnvironmentVariableSupplier[] arrSup = null;
|
|
||||||
// arrSup = ManagedBuildManager.getEnvironmentVariableProvider().getSuppliers(obj);
|
|
||||||
// for (int i=0; i<arrSup.length; i++ ) {
|
|
||||||
// if (arrSup[i] instanceof UserDefinedEnvironmentSupplier) {
|
|
||||||
// return (UserDefinedEnvironmentSupplier) arrSup[i];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// fail("Cannot access user variable supplier for " + objName); //$NON-NLS-1$
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note: CWD and PWD vars are not allowed to be added/changed
|
|
||||||
*/
|
|
||||||
// private void addTestVariables() {
|
|
||||||
// final int STD_MODE = IBuildEnvironmentVariable.ENVVAR_REPLACE;
|
|
||||||
// UserDefinedEnvironmentSupplier usup = null;
|
|
||||||
// usup = getSupplier(worksp, "Workspace"); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// if (usup != null) {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CMN, NAME_WSP, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, worksp));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_WSP,VAL_DUMMY1, STD_MODE, DEL_UNIX, worksp));
|
|
||||||
// assertNull(usup.createVariable(NAME_CWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
|
|
||||||
// assertNull(usup.createVariable(NAME_PWD,VAL_CWDPWD, STD_MODE, DEL_UNIX, worksp));
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// usup = getSupplier(mproj, "Project"); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// if (usup != null) {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CMN, NAME_PRJI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, mproj));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_PRJI,VAL_PRO_INC, STD_MODE, DEL_UNIX, mproj));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_PRJL,VAL_PRO_LIB, STD_MODE, DEL_UNIX, mproj));
|
|
||||||
// assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
|
|
||||||
// assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, mproj));
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// fail("Failed to create project vars " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// IConfiguration[] configs = mproj.getConfigurations();
|
|
||||||
// for (int i = 0; i < 2; i++) { // only 2 first configs are affected
|
|
||||||
// IConfiguration cfg = configs[i];
|
|
||||||
// usup = getSupplier(cfg, "Configuration " + cfg.getName()); //$NON-NLS-1$
|
|
||||||
// try {
|
|
||||||
// if (usup != null) {
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CMN, NAME_CFGI, IBuildEnvironmentVariable.ENVVAR_APPEND, DEL_UNIX, cfg));
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CFGI, "/config/include/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CFG+i,"/config"+i+"/include",STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CFGL, "/config/lib/"+i, STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
|
|
||||||
// assertNotNull(usup.createVariable(NAME_CFGX, "/config/unused", STD_MODE, DEL_UNIX, cfg)); //$NON-NLS-1$
|
|
||||||
// assertNull(usup.createVariable(NAME_CWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
|
|
||||||
// assertNull(usup.createVariable(NAME_PWD, VAL_CWDPWD, STD_MODE, DEL_UNIX, cfg));
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// fail("Failed to create configuration vars for <" + cfg.getName() + "> - "+ e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
|
|
||||||
// } catch (Exception e) {}
|
|
||||||
// }
|
|
||||||
private void doInit() {
|
private void doInit() {
|
||||||
envProvider = ManagedBuildManager.getEnvironmentVariableProvider();
|
envProvider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
assertNotNull(envProvider);
|
assertNotNull(envProvider);
|
||||||
|
@ -553,45 +186,6 @@ public class ManagedBuildEnvironmentTests extends TestCase {
|
||||||
assertNotNull(worksp);
|
assertNotNull(worksp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Print contents of env.var array, with given header.
|
|
||||||
*/
|
|
||||||
// private void printVar(String head, IBuildEnvironmentVariable[] vars) {
|
|
||||||
// if (vars != null) {
|
|
||||||
// if (vars.length > 0) {
|
|
||||||
// for (int i=0; i < vars.length; i++) {
|
|
||||||
// System.out.println(head + "[" + i + "] " + //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// vars[i].getName() + " = " + //$NON-NLS-1$
|
|
||||||
// vars[i].getValue() + " / " + //$NON-NLS-1$
|
|
||||||
// vars[i].getOperation() + vars[i].getDelimiter());
|
|
||||||
// }
|
|
||||||
// } else { System.out.println(head + ": array is empty"); } //$NON-NLS-1$
|
|
||||||
// } else { System.out.println(head + ": array is null"); } //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* check that ALL variables from list "a" have correspondence
|
|
||||||
* in list "b"
|
|
||||||
* empty list or null are treated as corresponding to anything
|
|
||||||
*/
|
|
||||||
// private boolean varListContainNames(IBuildEnvironmentVariable[] a, IBuildEnvironmentVariable[] b) {
|
|
||||||
// if (a == null) return true;
|
|
||||||
// else if (a.length == 0) return true;
|
|
||||||
// else if (b == null) return false;
|
|
||||||
//
|
|
||||||
// for (int i=0; i<a.length; i++) {
|
|
||||||
// boolean found = false;
|
|
||||||
// for (int j=0; j<b.length; j++) {
|
|
||||||
// if (a[i].getName().equals(b[j].getName())) {
|
|
||||||
// found = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!found) return false;
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param head
|
* @param head
|
||||||
|
|
|
@ -57,7 +57,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
IConfiguration[] cfgs = null;
|
IConfiguration[] cfgs = null;
|
||||||
IBuildMacroProvider mp = null;
|
IBuildMacroProvider mp = null;
|
||||||
IWorkspace worksp = null;
|
IWorkspace worksp = null;
|
||||||
boolean windows = false;
|
|
||||||
|
|
||||||
boolean print = false; // allows to print most of macros on console
|
boolean print = false; // allows to print most of macros on console
|
||||||
boolean flag = false; // uplevel flag for getMacro/getMacros methods
|
boolean flag = false; // uplevel flag for getMacro/getMacros methods
|
||||||
|
@ -92,24 +91,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite(ManagedBuildMacrosTests.class);
|
TestSuite suite = new TestSuite(ManagedBuildMacrosTests.class);
|
||||||
//$JUnit-BEGIN$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroConf"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroEEnv"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroInst"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroProj"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroWrks"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroOptS"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroOptL"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroFile"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroContext"));//$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroResolve"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroResolveExceptions"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroResolveLoop"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroResolveMake"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroResolveCase"));//$NON-NLS-1$
|
|
||||||
// suite.addTest(new ManagedBuildMacrosTests("testMacroSave"));//$NON-NLS-1$
|
|
||||||
//$JUnit-END$
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,127 +101,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroConf()
|
|
||||||
*/
|
|
||||||
/* public void testMacroConf(){
|
|
||||||
doInit();
|
|
||||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
assertNotNull(ms);
|
|
||||||
assertEquals(ms.length, 4);
|
|
||||||
assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_CONFIGURATION],
|
|
||||||
IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]));
|
|
||||||
functionCalled = 0;
|
|
||||||
String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0], flag), "Configuration"); //$NON-NLS-1$
|
|
||||||
assertEquals(GET_MANY_CONFIG, functionCalled);
|
|
||||||
String[] b = {"ConfigName", "BuildArtifactFileExt", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
"BuildArtifactFileBaseName", "TargetArchList", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
"TargetOsList", "BuildArtifactFileName", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
"PWD", "CWD", "ConfigDescription", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
TEST, "NEW_FOR_CFG" }; //$NON-NLS-1$
|
|
||||||
assertTrue(arrayContains(b, a));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* testMacroEEnv()
|
|
||||||
*/
|
|
||||||
/* public void testMacroEEnv(){
|
|
||||||
doInit();
|
|
||||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_ECLIPSEENV, null);
|
|
||||||
assertNotNull(ms);
|
|
||||||
assertEquals(ms.length, 1);
|
|
||||||
assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_ECLIPSEENV],
|
|
||||||
IBuildMacroProvider.CONTEXT_ECLIPSEENV, null));
|
|
||||||
String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_ECLIPSEENV, null, flag), "EclipseEnv"); //$NON-NLS-1$
|
|
||||||
// String[] b = {"PATH", "USERNAME"}; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// assertTrue(arrayContains(b, a));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* testMacroInst()
|
|
||||||
*/
|
|
||||||
/* public void testMacroInst(){
|
|
||||||
doInit();
|
|
||||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_INSTALLATIONS, null);
|
|
||||||
assertNotNull(ms);
|
|
||||||
assertEquals(ms.length, 1);
|
|
||||||
assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_INSTALLATIONS],
|
|
||||||
IBuildMacroProvider.CONTEXT_INSTALLATIONS, null));
|
|
||||||
String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_INSTALLATIONS, null, flag), "Installations "); //$NON-NLS-1$
|
|
||||||
String[] b = {"HostArchName", "MBSVersion", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
"EclipseVersion", "HostOsName", "CDTVersion"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
assertTrue(arrayContains(b, a));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* testMacroProj()
|
|
||||||
*/
|
|
||||||
// public void testMacroProj(){
|
|
||||||
// doInit();
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertEquals(ms.length, 4);
|
|
||||||
// assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_PROJECT],
|
|
||||||
// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
|
|
||||||
// functionCalled = 0;
|
|
||||||
// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), "Project "); //$NON-NLS-1$
|
|
||||||
// assertEquals(GET_MANY_PROJECT, functionCalled);
|
|
||||||
// String[] b = {"ProjDirPath", "ProjName", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// TEST, "NEW_FOR_PRJ"}; //$NON-NLS-1$
|
|
||||||
// assertTrue(arrayContains(b, a));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroWrks()
|
|
||||||
*/
|
|
||||||
// public void testMacroWrks(){
|
|
||||||
// doInit();
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertEquals(ms.length, 5);
|
|
||||||
// assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_WORKSPACE],
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), "Workspace "); //$NON-NLS-1$
|
|
||||||
// String[] b = {"DirectoryDelimiter", "WorkspaceDirPath", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// "PathDelimiter", TEST}; //$NON-NLS-1$
|
|
||||||
// assertTrue(arrayContains(b, a));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroOptn()
|
|
||||||
*/
|
|
||||||
// public void testMacroOptS(){
|
|
||||||
// doInit();
|
|
||||||
// IToolChain tc = cfgs[0].getToolChain();
|
|
||||||
// ITool t = cfgs[0].getTools()[0];
|
|
||||||
// IOption opt = t.getOptionById(OPT_IDS);
|
|
||||||
// assertNotNull(opt);
|
|
||||||
//
|
|
||||||
// // standard check of suppliers # and attempt to add macro (should fail)
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertEquals(ms.length, 1);
|
|
||||||
// assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_OPTION], IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t)));
|
|
||||||
//
|
|
||||||
// // modify value and check that macros is resolved
|
|
||||||
// try {
|
|
||||||
// opt = cfgs[0].setOption(t, opt, "222 " + INC_DEF); //$NON-NLS-1$
|
|
||||||
// String a = mp.resolveValue(opt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
|
||||||
// assertEquals(a, "222 111"); //$NON-NLS-1$
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
// catch (BuildException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
// // Create resource configuration
|
|
||||||
// IResourceConfiguration rc = cfgs[0].createResourceConfiguration(getFile());
|
|
||||||
// assertNotNull(rc);
|
|
||||||
// IOption ropt = rc.getTools()[0].getOptionById(OPT_IDS);
|
|
||||||
// try {
|
|
||||||
// ropt = rc.setOption(rc.getTools()[0], ropt, "333 " + INC_DEF); //$NON-NLS-1$
|
|
||||||
// String a = mp.resolveValue(ropt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
|
||||||
// assertEquals(a, "333 111"); //$NON-NLS-1$
|
|
||||||
// } catch (Exception e) { fail(e.getLocalizedMessage()); }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void testMacroOptL() {
|
public void testMacroOptL() {
|
||||||
doInit();
|
doInit();
|
||||||
ITool t = cfgs[0].getTools()[0];
|
ITool t = cfgs[0].getTools()[0];
|
||||||
|
@ -293,128 +153,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroFile()
|
|
||||||
*/
|
|
||||||
// public void testMacroFile(){
|
|
||||||
// final String EIN = "ein.c"; //$NON-NLS-1$
|
|
||||||
// final String AUS = "aus.o"; //$NON-NLS-1$
|
|
||||||
// final String UP2W = "..\\..\\"; //$NON-NLS-1$
|
|
||||||
// final String UP2U = "../../"; //$NON-NLS-1$
|
|
||||||
// final String KLMN = "\\k\\l\\m\\n\\o\\p\\"; //$NON-NLS-1$
|
|
||||||
// final String[] names =
|
|
||||||
// {"InputFileName", "InputFileExt", "InputFileBaseName", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
// "InputFileRelPath", "InputDirRelPath", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// "OutputFileName", "OutputFileExt", "OutputFileBaseName",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
// "OutputFileRelPath", "OutputDirRelPath"}; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// String[] values0wAbs =
|
|
||||||
// {"a.f77", "f77", "a", "\\xz\\a.f77", "\\xz\\", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
||||||
// "b.exe", "exe", "b", "\\tmp\\b.exe", "\\tmp\\"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
||||||
// final String[] values0wRel =
|
|
||||||
// {EIN, "c", "ein", UP2W+EIN, UP2W, //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// AUS, "o", "aus", UP2W+AUS, UP2W}; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
//
|
|
||||||
// final String[] values0u =
|
|
||||||
// {EIN, "c", "ein", UP2U+EIN, UP2U, //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// AUS, "o", "aus", UP2U+AUS, UP2U}; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
//
|
|
||||||
// final String[] values1 =
|
|
||||||
// {"$(notdir $<)", "$(suffix $(notdir $<))", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// "$(basename $(notdir $<))", "$<", "$(dir $<)", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
// "$(notdir $@)", "$(suffix $(notdir $@))", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// "$(basename $(notdir $@))", "$@", "$(dir $@)"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
//
|
|
||||||
// FileContextData fd = null;
|
|
||||||
//
|
|
||||||
// doInit();
|
|
||||||
// ITool t = cfgs[0].getTools()[0];
|
|
||||||
// assertNotNull(t);
|
|
||||||
// IOption opt = t.getOptionById(OPT_IDS);
|
|
||||||
//
|
|
||||||
// String dir=null;
|
|
||||||
// try {
|
|
||||||
// dir = mp.getMacro("WorkspaceDirPath", IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag).getStringValue(); //$NON-NLS-1$
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
// IPath p = (new Path(dir)).addTrailingSeparator();
|
|
||||||
//
|
|
||||||
// if (windows) {
|
|
||||||
// // check behaviour in case of different disks usage
|
|
||||||
//
|
|
||||||
// // config #4 has changed BuilderMakeFileGenerator, #0 has standard one
|
|
||||||
// IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", cfgs[0], false, true); //$NON-NLS-1$
|
|
||||||
// String dev0 = Path.fromOSString(cwdvar.getValue()).getDevice().toUpperCase();
|
|
||||||
// String dev1 = (dev0.startsWith("C")) ? "D:" : "C:"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
// values0wAbs[3] = dev1 + values0wAbs[3];
|
|
||||||
// values0wAbs[4] = dev1 + values0wAbs[4];
|
|
||||||
// values0wAbs[8] = dev1 + values0wAbs[8];
|
|
||||||
// values0wAbs[9] = dev1 + values0wAbs[9];
|
|
||||||
//
|
|
||||||
// fd = new FileContextData(new Path(values0wAbs[3]), new Path(values0wAbs[8]),opt,t);
|
|
||||||
// for (int i=0; i<names.length; i++)
|
|
||||||
// try {
|
|
||||||
// assertEquals(values0wAbs[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
// // check that relative path are reported OK
|
|
||||||
// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
|
|
||||||
// for (int i=0; i<names.length; i++)
|
|
||||||
// try {
|
|
||||||
// assertEquals(values0wRel[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
//
|
|
||||||
//// //TODO:
|
|
||||||
//// // check paths using changed BuilderMakeFileGenerator in cfg "Five"
|
|
||||||
/////*
|
|
||||||
//// int index = 4;
|
|
||||||
//// ManagedBuildManager.setDefaultConfiguration(proj, cfgs[index]);
|
|
||||||
//// OptionContextData op = new OptionContextData(cfgs[index].getTools()[0].getOptions()[0], cfgs[index].getToolChain());
|
|
||||||
//// String p0 = dev0 + KLMN;
|
|
||||||
//// fd = new FileContextData(new Path(p0+EIN), new Path(p0+AUS), op);
|
|
||||||
//// assertNotNull(fd);
|
|
||||||
//// //TODO: the same dir, upper dir, lower dir
|
|
||||||
//// try {
|
|
||||||
//// TestMacro.topBuildDir = Path.fromOSString(p0);
|
|
||||||
//// assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
////// p0 = Path.fromOSString(p0).removeLastSegments(2).addTrailingSeparator().toOSString();
|
|
||||||
////// p0 = dev0+KLMN+"x\\";
|
|
||||||
////// TestMacro.topBuildDir = Path.fromOSString(p0);
|
|
||||||
//// assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
//// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
////// */
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// // check relative path only
|
|
||||||
// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
|
|
||||||
// for (int i=0; i<names.length; i++)
|
|
||||||
// try {
|
|
||||||
// assertEquals(values0u[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // check supplier's parameters
|
|
||||||
// assertNotNull(fd);
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_FILE, fd);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertEquals(ms.length, 1);
|
|
||||||
// assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT,
|
|
||||||
// TST[IBuildMacroProvider.CONTEXT_FILE], IBuildMacroProvider.CONTEXT_FILE, fd));
|
|
||||||
//
|
|
||||||
// // For config #3, macros should contain lines specified in plugin.xml
|
|
||||||
// opt = cfgs[1].getTools()[0].getOptions()[0];
|
|
||||||
// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[1].getTools()[0]);
|
|
||||||
// for (int i=0; i<names.length; i++)
|
|
||||||
// try {
|
|
||||||
// assertEquals(values1[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
|
||||||
// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMacroContext()
|
* testMacroContext()
|
||||||
*/
|
*/
|
||||||
|
@ -435,62 +173,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroResolve()
|
|
||||||
*/
|
|
||||||
// public void testMacroResolve(){
|
|
||||||
// doInit();
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// String[] lst = {"AAA", "BBB", "CCC"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
// assertTrue(addMacro("LST", IBuildMacro.VALUE_TEXT_LIST, lst, //$NON-NLS-1$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// assertTrue(addMacro("ONE", IBuildMacro.VALUE_TEXT, "EIN", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// //
|
|
||||||
// assertTrue(addMacro("L1", IBuildMacro.VALUE_TEXT, "nested L1-${L2}-L1", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// assertTrue(addMacro("L2", IBuildMacro.VALUE_TEXT, "L2-${L3}-L2", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// assertTrue(addMacro("L3", IBuildMacro.VALUE_TEXT, "L3-${L4}-L3", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// assertTrue(addMacro("L4", IBuildMacro.VALUE_TEXT, "L4", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
//
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertTrue(addMacro("TWO", IBuildMacro.VALUE_TEXT, "ZWEI", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertTrue(addMacro("three", IBuildMacro.VALUE_TEXT, "DREI", //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // check normal workflow
|
|
||||||
// try {
|
|
||||||
// final String pattern = "${ONE} - ${TWO} - ${three} -> ${LST}"; //$NON-NLS-1$
|
|
||||||
// String a = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
|
|
||||||
// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
// String b = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
|
|
||||||
// IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
// String c = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// String d = mp.resolveValue("${L1}", UNKNOWN, LISTSEP, //$NON-NLS-1$
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// String e = mp.resolveValue("${one} - ${Two} - ${THREE} -> ${lst}", UNKNOWN, LISTSEP, //$NON-NLS-1$
|
|
||||||
// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
//
|
|
||||||
// assertEquals(a, "EIN - ZWEI - DREI -> AAA|BBB|CCC"); //$NON-NLS-1$
|
|
||||||
// assertEquals(b, "EIN - ZWEI - <HZ> -> AAA|BBB|CCC"); //$NON-NLS-1$
|
|
||||||
// assertEquals(c, "EIN - <HZ> - <HZ> -> AAA|BBB|CCC"); //$NON-NLS-1$
|
|
||||||
// assertEquals(d, "nested L1-L2-L3-L4-L3-L2-L1"); //$NON-NLS-1$
|
|
||||||
// assertEquals(e, "<HZ> - <HZ> - <HZ> -> <HZ>"); //$NON-NLS-1$
|
|
||||||
// } catch (BuildMacroException e) {
|
|
||||||
// fail("Exception while resolving: " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMacroResolveExceptions()
|
* testMacroResolveExceptions()
|
||||||
*/
|
*/
|
||||||
|
@ -516,181 +198,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
assertTrue("Exception not raised for undefined delimiter", exceptionRaised); //$NON-NLS-1$
|
assertTrue("Exception not raised for undefined delimiter", exceptionRaised); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroResolveLoop()
|
|
||||||
*/
|
|
||||||
// public void testMacroResolveLoop() {
|
|
||||||
// doInit();
|
|
||||||
// int ctx = IBuildMacroProvider.CONTEXT_WORKSPACE;
|
|
||||||
// Object obj = worksp;
|
|
||||||
// ms = mp.getSuppliers(ctx, obj);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
//
|
|
||||||
// // check state before macros added (should be OK)
|
|
||||||
// try {
|
|
||||||
// mp.checkIntegrity(ctx, obj);
|
|
||||||
// } catch (BuildMacroException e) {
|
|
||||||
// fail("Macros integrity check is failed"); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // create macro which references to undefined macro
|
|
||||||
// assertTrue(addMacro("B1", IBuildMacro.VALUE_TEXT, "B1-${B2}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// rmMacro("B2", ctx, obj); // usually it does not exist, but to be sure... //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // check state after macro added (should be exception)
|
|
||||||
// try {
|
|
||||||
// mp.checkIntegrity(ctx, obj);
|
|
||||||
// fail("Macros misintegrity (ref to undefined) is not detected"); //$NON-NLS-1$
|
|
||||||
// } catch (BuildMacroException e) {}
|
|
||||||
//
|
|
||||||
// // create "dead loop" of nested macros
|
|
||||||
// assertTrue(addMacro("B2", IBuildMacro.VALUE_TEXT, "B2-${B3}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// assertTrue(addMacro("B3", IBuildMacro.VALUE_TEXT, "B3-${B1}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
//
|
|
||||||
// // check state after macros added (should be exception)
|
|
||||||
// try {
|
|
||||||
// mp.checkIntegrity(ctx, obj);
|
|
||||||
// fail("Macros misintegrity (dead loop) is not detected"); //$NON-NLS-1$
|
|
||||||
// } catch (BuildMacroException e) {}
|
|
||||||
//
|
|
||||||
// // remove "dead loop" of nested macros
|
|
||||||
// assertTrue(rmMacro("B1", ctx, obj)); //$NON-NLS-1$
|
|
||||||
// assertTrue(rmMacro("B2", ctx, obj)); //$NON-NLS-1$
|
|
||||||
// assertTrue(rmMacro("B3", ctx, obj)); //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// // check state after macros removed (should be OK)
|
|
||||||
// try {
|
|
||||||
// mp.checkIntegrity(ctx, obj);
|
|
||||||
// } catch (BuildMacroException e) {
|
|
||||||
// fail("Macros integrity check is failed " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/**
|
|
||||||
* testMacroResolveMake()
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
public void testMacroResolveMake(){
|
|
||||||
final String p1 = "USERNAME: "; //$NON-NLS-1$
|
|
||||||
final String p2 = "${USERNAME} "; //$NON-NLS-1$
|
|
||||||
final String p3 = "PATH: "; //$NON-NLS-1$
|
|
||||||
final String p4 = "${PATH} "; //$NON-NLS-1$
|
|
||||||
final String p5 = "HostOsName: ${HostOsName} WorkspaceDirPath: ${WorkspaceDirPath}"; //$NON-NLS-1$
|
|
||||||
final String ein1 = p1 + p2 + p3;
|
|
||||||
final String ein2 = p4 + p5;
|
|
||||||
final String ein = ein1 + ein2;
|
|
||||||
final String aus1 = "@USERNAME "; //$NON-NLS-1$
|
|
||||||
final String aus2 = "@PATH "; //$NON-NLS-1$
|
|
||||||
doInit();
|
|
||||||
// Config #0 contains "variableFormat" macro = "@=". Result: 2 first macros NOT resolved
|
|
||||||
try {
|
|
||||||
UserDefinedEnvironmentSupplier env = EnvironmentVariableProvider.fUserSupplier;
|
|
||||||
env.createVariable("PATH","",IBuildEnvironmentVariable.ENVVAR_PREPEND,null,worksp);
|
|
||||||
env.createVariable("USERNAME","",IBuildEnvironmentVariable.ENVVAR_PREPEND,null,worksp);
|
|
||||||
functionCalled = 0;
|
|
||||||
String a = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
String b = p1 + aus1 + p3 + mp.resolveValue(ein2, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
|
|
||||||
assertEquals(a, b); // Env var names should not be resolved but converted to Makefile format
|
|
||||||
a = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
assertEquals(a, b); // Project context should return the same as default configuration
|
|
||||||
} catch (BuildMacroException e) {
|
|
||||||
fail(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
// Config #1 does not contain "variableFormat" macro. Result: all macros resolved.
|
|
||||||
try {
|
|
||||||
String a = mp.resolveValue(ein, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[1]);
|
|
||||||
String b = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[1]);
|
|
||||||
assertEquals(a, b);
|
|
||||||
} catch (BuildMacroException e) {
|
|
||||||
fail(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
// check that "isReservedName" was not called before
|
|
||||||
assertEquals(functionCalled & RESERVED_NAME, 0);
|
|
||||||
|
|
||||||
// Config #2 contains "...Supplier" macro. Result: PATH unresolved, USERNAME resolved.
|
|
||||||
try {
|
|
||||||
String a = mp.resolveValue(p1 + p2, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[2]);
|
|
||||||
String b = mp.resolveValue(p5, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[2]);
|
|
||||||
a = a + p3 + aus2 + b; // USERNAME: xxx PATH: @PATH HostOsName: xxx ...
|
|
||||||
b = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[2]);
|
|
||||||
assertEquals(a, b);
|
|
||||||
// check that "isReservedName" has been called
|
|
||||||
assertEquals(functionCalled & RESERVED_NAME, RESERVED_NAME);
|
|
||||||
} catch (BuildMacroException e) {
|
|
||||||
fail(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroResolveCase()
|
|
||||||
*/
|
|
||||||
// public void testMacroResolveCase(){
|
|
||||||
// doInit();
|
|
||||||
// addVars();
|
|
||||||
// final String winOut1 = "@CASETEST uppercase uppercase uppercase"; //$NON-NLS-1$
|
|
||||||
// final String winOut2 = "@CASETEST @CASETEST @CASETEST @CASETEST"; //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// final String unixOut1 = "@CASETEST capitalize lowercase upper2low"; //$NON-NLS-1$
|
|
||||||
// final String unixOut2 = "@CASETEST @CaseTest @casetest @CaSeTeSt"; //$NON-NLS-1$
|
|
||||||
//
|
|
||||||
// final String ein = "${CASETEST} ${CaseTest} ${casetest} ${CaSeTeSt}"; //$NON-NLS-1$
|
|
||||||
// final int ctx = IBuildMacroProvider.CONTEXT_CONFIGURATION;
|
|
||||||
// String a=null, b=null;
|
|
||||||
// try {
|
|
||||||
// // Config #0 contains isVariableCaseSensitive = false
|
|
||||||
// a = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, ctx, cfgs[0]);
|
|
||||||
// // Config #3 contains isVariableCaseSensitive = true
|
|
||||||
// b = mp.resolveValueToMakefileFormat(ein, UNKNOWN, LISTSEP, ctx, cfgs[3]);
|
|
||||||
// } catch (BuildMacroException e) {
|
|
||||||
// fail(e.getLocalizedMessage());
|
|
||||||
// }
|
|
||||||
// if (windows) {
|
|
||||||
// assertEquals(a, winOut1);
|
|
||||||
// assertEquals(b, winOut2);
|
|
||||||
// } else { // linux
|
|
||||||
// assertEquals(a, unixOut1);
|
|
||||||
// assertEquals(b, unixOut2);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* testMacroSave()
|
|
||||||
*/
|
|
||||||
|
|
||||||
// public void testMacroSave(){
|
|
||||||
// final String TO_SAVE_P = "TO_SAVE_P"; //$NON-NLS-1$
|
|
||||||
// final String TO_SAVE_W = "TO_SAVE_W"; //$NON-NLS-1$
|
|
||||||
// doInit();
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertTrue(addMacro(TO_SAVE_P, IBuildMacro.VALUE_TEXT, TO_SAVE_P,
|
|
||||||
// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// assertTrue(addMacro(TO_SAVE_W, IBuildMacro.VALUE_TEXT, TO_SAVE_W,
|
|
||||||
// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
|
|
||||||
// try {
|
|
||||||
// // Save the buildinfo, and then remove it, to be complete
|
|
||||||
// ManagedBuildManager.saveBuildInfo(proj, true);
|
|
||||||
// ManagedBuildManager.removeBuildInfo(proj);
|
|
||||||
// proj.close(null);
|
|
||||||
// proj.open(null);
|
|
||||||
// } catch (CoreException e) {
|
|
||||||
// fail("Failed on project close/open: " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), TO_SAVE_P);
|
|
||||||
// String[] b1 = {TO_SAVE_P};
|
|
||||||
// assertTrue(arrayContains(b1, a));
|
|
||||||
//
|
|
||||||
// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
|
|
||||||
// assertNotNull(ms);
|
|
||||||
// a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), TO_SAVE_W);
|
|
||||||
// String[] b2 = {TO_SAVE_W};
|
|
||||||
// assertTrue(arrayContains(b2, a));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Below are service methods
|
* Below are service methods
|
||||||
*/
|
*/
|
||||||
|
@ -821,7 +328,6 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
assertNotNull(mp);
|
assertNotNull(mp);
|
||||||
cfgs = mproj.getConfigurations();
|
cfgs = mproj.getConfigurations();
|
||||||
assertNotNull(cfgs);
|
assertNotNull(cfgs);
|
||||||
windows = System.getProperty("os.name").toLowerCase().startsWith("windows"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -847,79 +353,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* addMacro
|
|
||||||
* @param name
|
|
||||||
* @param type
|
|
||||||
* @param value
|
|
||||||
* @param context
|
|
||||||
* @param obj
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
/*private boolean addMacro(String name, int type, String value, int context, Object obj) {
|
|
||||||
assertNotNull(ms);
|
|
||||||
for(int i=0; i<ms.length; i++) {
|
|
||||||
if (ms[i] instanceof UserDefinedMacroSupplier) {
|
|
||||||
return (((UserDefinedMacroSupplier)ms[i]).createMacro(name,type,value,context,obj) != null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
/**
|
|
||||||
* addMacro
|
|
||||||
* @param name
|
|
||||||
* @param type
|
|
||||||
* @param value
|
|
||||||
* @param context
|
|
||||||
* @param obj
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* private boolean addMacro(String name, int type, String[] value, int context, Object obj) {
|
|
||||||
assertNotNull(ms);
|
|
||||||
for(int i=0; i<ms.length; i++) {
|
|
||||||
if (ms[i] instanceof UserDefinedMacroSupplier) {
|
|
||||||
return (((UserDefinedMacroSupplier)ms[i]).createMacro(name,type,value,context,obj) != null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
/**
|
|
||||||
* rmMacro
|
|
||||||
* @param name - name of macro
|
|
||||||
* @param context
|
|
||||||
* @param obj
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
/* private boolean rmMacro(String name, int context, Object obj) {
|
|
||||||
assertNotNull(ms);
|
|
||||||
for(int i=0; i<ms.length; i++) {
|
|
||||||
if (ms[i] instanceof UserDefinedMacroSupplier) {
|
|
||||||
return (((UserDefinedMacroSupplier)ms[i]).deleteMacro(name,context,obj) != null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* addVars() - adds macros for testMacroResolveCase
|
|
||||||
*/
|
|
||||||
// private void addVars() {
|
|
||||||
// int app = IBuildEnvironmentVariable.ENVVAR_APPEND;
|
|
||||||
// String del = ""; //$NON-NLS-1$
|
|
||||||
// UserDefinedEnvironmentSupplier usup = null;
|
|
||||||
// usup = ManagedBuildEnvironmentTests.getSupplier(worksp, "Workspace"); //$NON-NLS-1$
|
|
||||||
// if (usup != null) {
|
|
||||||
// try {
|
|
||||||
// usup.createVariable("casetest","lowercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// usup.createVariable("CaseTest","capitalize", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// usup.createVariable("CaSeTeSt","upper2low", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// usup.createVariable("CASETEST","uppercase", app, del, worksp ); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// fail("Failed to create workspace vars " + e.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/*
|
/*
|
||||||
* getFile() - open or creates sample file in current project
|
* getFile() - open or creates sample file in current project
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue