1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 17:55:39 +02:00

bug 232373: testGenerateCommandLineInfoParameters re-added

This commit is contained in:
Andrew Gvozdev 2010-10-23 19:14:51 +00:00
parent e609e153a6
commit dc5d147ab5

View file

@ -32,10 +32,16 @@ import org.eclipse.core.runtime.IPath;
public class ManagedCommandLineGeneratorTest extends TestCase { public class ManagedCommandLineGeneratorTest extends TestCase {
private static String[] testCommandLinePatterns = {null, "${COMMAND}", "${COMMAND} ${FLAGS}", "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}", private static String[] testCommandLinePatterns = {
"${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}", "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT}", null,
"${COMMAND}",
"${COMMAND} ${FLAGS}",
"${COMMAND} ${FLAGS} ${OUTPUT_FLAG}",
"${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}",
"${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT}",
"${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}", "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}",
"${command} ${flags} ${output_flag}${output_prefix}${output} ${WRONG_VAR_NAME}"}; "${command} ${flags} ${output_flag}${output_prefix}${output} ${WRONG_VAR_NAME}"
};
private static String COMMAND_VAL = "[command]"; private static String COMMAND_VAL = "[command]";
private static String FLAGS_VAL = "[flags]"; private static String FLAGS_VAL = "[flags]";
private static String[] FLAGS_ARRAY_VAL = FLAGS_VAL.split( "\\s" ); private static String[] FLAGS_ARRAY_VAL = FLAGS_VAL.split( "\\s" );
@ -46,19 +52,13 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
private static String[] INPUTS_ARRAY_VAL = INPUTS_VAL.split( "\\s" ); private static String[] INPUTS_ARRAY_VAL = INPUTS_VAL.split( "\\s" );
private static String[] commandLineEtalonesForPatterns = { private static String[] commandLineEtalonesForPatterns = {
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "\"" + INPUTS_VAL + "\"", COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "\"" + INPUTS_VAL + "\"",
COMMAND_VAL, COMMAND_VAL + " " + FLAGS_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL, COMMAND_VAL,
COMMAND_VAL + " " + FLAGS_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL, COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"", COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"",
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "\"" + INPUTS_VAL + "\"", COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "\"" + INPUTS_VAL + "\"",
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "${WRONG_VAR_NAME}" }; COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + "\"" + OUTPUT_VAL + "\"" + " " + "${WRONG_VAR_NAME}" };
private static String[] commandLineEtalonesForParameters = {
FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + " " + INPUTS_VAL,
COMMAND_VAL + " " + FLAGS_VAL + " " + OUTPUT_FLAG_VAL + OUTPUT_PREFIX_VAL + OUTPUT_VAL + " ",
};
public ManagedCommandLineGeneratorTest( String name ) { public ManagedCommandLineGeneratorTest( String name ) {
super(name); super(name);
@ -68,8 +68,7 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
TestSuite suite = new TestSuite( ManagedCommandLineGeneratorTest.class.getName() ); TestSuite suite = new TestSuite( ManagedCommandLineGeneratorTest.class.getName() );
suite.addTest( new ManagedCommandLineGeneratorTest( "testGetCommandLineGenerator" ) ); suite.addTest( new ManagedCommandLineGeneratorTest( "testGetCommandLineGenerator" ) );
suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoPatterns" ) ); suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoPatterns" ) );
// TODO: The parameters set to NULL in these tests are not currently allowed to be null suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoParameters" ) );
//suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoParameters" ) );
suite.addTest( new ManagedCommandLineGeneratorTest( "testCustomGenerator" ) ); suite.addTest( new ManagedCommandLineGeneratorTest( "testCustomGenerator" ) );
suite.addTest( new ManagedCommandLineGeneratorTest( "testDollarValue" ) ); suite.addTest( new ManagedCommandLineGeneratorTest( "testDollarValue" ) );
return suite; return suite;
@ -88,31 +87,37 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
testCommandLinePatterns[i] ); testCommandLinePatterns[i] );
assertNotNull( info ); assertNotNull( info );
if( i < commandLineEtalonesForPatterns.length ) { if( i < commandLineEtalonesForPatterns.length ) {
assertEquals( info.getCommandLine(), commandLineEtalonesForPatterns[i] ); assertEquals("i="+i, commandLineEtalonesForPatterns[i], info.getCommandLine());
} }
} }
} }
public final void testGenerateCommandLineInfoParameters() { public final void testGenerateCommandLineInfoParameters() {
IManagedCommandLineGenerator gen = ManagedCommandLineGenerator.getCommandLineGenerator(); IManagedCommandLineGenerator gen = ManagedCommandLineGenerator.getCommandLineGenerator();
IManagedCommandLineInfo info = gen.generateCommandLineInfo( null, null, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
IManagedCommandLineInfo info = gen.generateCommandLineInfo( null, "", FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine(), commandLineEtalonesForParameters[0] ); assertEquals(FLAGS_VAL+" "+OUTPUT_FLAG_VAL+OUTPUT_PREFIX_VAL + "\""+OUTPUT_VAL + "\""+" " + "\""+INPUTS_VAL + "\"", info.getCommandLine());
info = gen.generateCommandLineInfo( null, COMMAND_VAL, null, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
info = gen.generateCommandLineInfo( null, COMMAND_VAL, new String[0], OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine(), commandLineEtalonesForParameters[1] ); assertEquals(COMMAND_VAL+" "+OUTPUT_FLAG_VAL+OUTPUT_PREFIX_VAL + "\""+OUTPUT_VAL + "\""+" " + "\""+INPUTS_VAL + "\"", info.getCommandLine());
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, null, OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, "", OUTPUT_PREFIX_VAL, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine(), commandLineEtalonesForParameters[2] ); assertEquals(COMMAND_VAL+" "+FLAGS_VAL+" "+OUTPUT_PREFIX_VAL + "\""+OUTPUT_VAL + "\""+" " + "\""+INPUTS_VAL + "\"", info.getCommandLine());
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, null, OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, "", OUTPUT_VAL, INPUTS_ARRAY_VAL, null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine(), commandLineEtalonesForParameters[3] ); assertEquals(COMMAND_VAL+" "+FLAGS_VAL+" "+OUTPUT_FLAG_VAL + "\""+OUTPUT_VAL + "\""+" " + "\""+INPUTS_VAL + "\"", info.getCommandLine());
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, null, INPUTS_ARRAY_VAL, null );
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, "", INPUTS_ARRAY_VAL, null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine(), commandLineEtalonesForParameters[4] ); assertEquals(COMMAND_VAL+" "+FLAGS_VAL+" "+OUTPUT_FLAG_VAL+OUTPUT_PREFIX_VAL+" " + "\""+INPUTS_VAL + "\"", info.getCommandLine());
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, null, null );
info = gen.generateCommandLineInfo( null, COMMAND_VAL, FLAGS_ARRAY_VAL, OUTPUT_FLAG_VAL, OUTPUT_PREFIX_VAL, OUTPUT_VAL, new String[0], null );
assertNotNull( info ); assertNotNull( info );
assertEquals( info.getCommandLine().trim(), commandLineEtalonesForParameters[5].trim() ); assertEquals(COMMAND_VAL+" "+FLAGS_VAL+" "+OUTPUT_FLAG_VAL+OUTPUT_PREFIX_VAL + "\""+OUTPUT_VAL + "\"", info.getCommandLine());
} }
public final void testCustomGenerator() { public final void testCustomGenerator() {
@ -134,7 +139,8 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
assertNotNull(option); assertNotNull(option);
Object val = option.getValue(); Object val = option.getValue();
assertTrue(val instanceof ArrayList); assertTrue(val instanceof ArrayList);
ArrayList list = (ArrayList)val; @SuppressWarnings("unchecked")
ArrayList<String> list = (ArrayList<String>)val;
assertEquals("foo", list.get(0)); assertEquals("foo", list.get(0));
assertEquals("bar", list.get(1)); assertEquals("bar", list.get(1));