Search in sources :

Example 6 with CommandParser

use of com.synopsys.integration.common.util.parse.CommandParser in project synopsys-detect by blackducksoftware.

the class CompileCommandParserTest method testCrazyNestedQuoting.

@Test
public void testCrazyNestedQuoting() {
    CompileCommand command = new CompileCommand();
    command.setCommand("X=\"\\\" a  b\\\"\"");
    CompileCommandParser commandParser = new CompileCommandParser(new CommandParser());
    List<String> result = commandParser.parseCommand(command, Collections.emptyMap());
    assertEquals(1, result.size());
    int i = 0;
    assertEquals("X=\"\\\" a  b\\\"\"", result.get(i++));
}
Also used : CompileCommandParser(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandParser) CompileCommand(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand) CommandParser(com.synopsys.integration.common.util.parse.CommandParser) CompileCommandParser(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandParser) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 7 with CommandParser

use of com.synopsys.integration.common.util.parse.CommandParser in project synopsys-detect by blackducksoftware.

the class CompileCommandParserTest method testComplexCompileCommand.

@Test
public void testComplexCompileCommand() {
    CompileCommand command = new CompileCommand();
    command.setCommand("/usr/bin/clang++-3.6 -DCMAKE_BUILD_TYPE=\\\"Debug\\\" -DCMAKE_CC_FLAGS=\"\\\" -ggdb -Wstrict-aliasing=2 -pedantic -fPIC --std=c11\\\"\"  -c ./pb.cc");
    CompileCommandParser commandParser = new CompileCommandParser(new CommandParser());
    List<String> result = commandParser.parseCommand(command, Collections.emptyMap());
    assertEquals(5, result.size());
    int i = 0;
    assertEquals("/usr/bin/clang++-3.6", result.get(i++));
    assertEquals("-DCMAKE_BUILD_TYPE=\\\"Debug\\\"", result.get(i++));
    assertEquals("-DCMAKE_CC_FLAGS=\"\\\" -ggdb -Wstrict-aliasing=2 -pedantic -fPIC --std=c11\\\"\"", result.get(i++));
    assertEquals("-c", result.get(i++));
    assertEquals("./pb.cc", result.get(i++));
}
Also used : CompileCommandParser(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandParser) CompileCommand(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand) CommandParser(com.synopsys.integration.common.util.parse.CommandParser) CompileCommandParser(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandParser) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Aggregations

CommandParser (com.synopsys.integration.common.util.parse.CommandParser)7 CompileCommand (com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand)7 CompileCommandParser (com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandParser)7 Test (org.junit.jupiter.api.Test)7 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)5 Gson (com.google.gson.Gson)2 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)2 CompileCommandDatabaseParser (com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandDatabaseParser)2 HashMap (java.util.HashMap)1