Search in sources :

Example 16 with CompileDescription

use of io.sloeber.core.api.CompileDescription in project arduino-eclipse-plugin by Sloeber.

the class RegressionTest method issue1047_Board_Names_Can_Be_used_as_Strings.

/**
 * support void loop{};
 *
 * @throws Exception
 */
@Test
public void issue1047_Board_Names_Can_Be_used_as_Strings() throws Exception {
    MCUBoard unoBoard = ESP8266.nodeMCU();
    String projectName = "issue1047_Board_Names_Can_Be_used_as_Strings";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    try {
        IProject theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoard.getBoardDescriptor(), codeDescriptor, new CompileDescription(), new NullProgressMonitor());
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " issue1047 is not fixed");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) MCUBoard(io.sloeber.providers.MCUBoard) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 17 with CompileDescription

use of io.sloeber.core.api.CompileDescription in project arduino-eclipse-plugin by Sloeber.

the class RegressionTest method openAndClosePreservesSettings.

/**
 * open and close a project should keep the compileDescription and
 * BoardDescriotion
 *
 * @throws Exception
 */
@Test
public void openAndClosePreservesSettings() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "openAndClose";
    CodeDescription codeDescriptor = new CodeDescription(CodeDescription.CodeTypes.defaultCPP);
    CompileDescription inCompileDescription = getBunkersCompileDescription();
    theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, inCompileDescription, new NullProgressMonitor());
    // Read the data we want to test
    // for the indexer
    Shared.waitForAllJobsToFinish();
    SloeberProject sloeberDesc = SloeberProject.getSloeberProject(theTestProject);
    ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
    ICConfigurationDescription confDesc = projDesc.getActiveConfiguration();
    BoardDescription createdBoardDesc = sloeberDesc.getBoardDescription(confDesc.getName(), false);
    CompileDescription createdCompileDesc = sloeberDesc.getCompileDescription(confDesc.getName(), false);
    // close and reopen the project
    theTestProject.close(null);
    // just wait a while
    Thread.sleep(1000);
    Shared.waitForAllJobsToFinish();
    theTestProject.open(null);
    Shared.waitForAllJobsToFinish();
    // read the data we want to test
    sloeberDesc = SloeberProject.getSloeberProject(theTestProject);
    projDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
    confDesc = projDesc.getActiveConfiguration();
    BoardDescription reopenedBoardDesc = sloeberDesc.getBoardDescription(confDesc.getName(), false);
    CompileDescription reopenedCompileDesc = sloeberDesc.getCompileDescription(confDesc.getName(), false);
    // check the data is equal
    boolean createBoardsDiff = !unoBoardid.equals(createdBoardDesc);
    boolean createCompileDiff = !inCompileDescription.equals(createdCompileDesc);
    boolean openBoardsDiff = !reopenedBoardDesc.equals(createdBoardDesc);
    boolean openCompileDiff = !reopenedCompileDesc.equals(createdCompileDesc);
    if (createBoardsDiff || createCompileDiff) {
        fail("Created project does not match creation parameters.");
    }
    if (openBoardsDiff || openCompileDiff) {
        fail("Opened project does not match closed project parameters.");
    }
    // also do a build
    // for the indexer
    Shared.waitForAllJobsToFinish();
    theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
    if (Shared.hasBuildErrors(theTestProject)) {
        fail("Failed to compile the project:" + projectName);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) SloeberProject(io.sloeber.core.api.SloeberProject) CompileDescription(io.sloeber.core.api.CompileDescription) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 18 with CompileDescription

use of io.sloeber.core.api.CompileDescription in project arduino-eclipse-plugin by Sloeber.

the class RegressionTest method create_CPP_based_Sloeber_Project.

@Test
public void create_CPP_based_Sloeber_Project() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "createCPPProject";
    CodeDescription codeDescriptor = CodeDescription.createDefaultCPP();
    try {
        theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), new NullProgressMonitor());
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " CPP project no longer work");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 19 with CompileDescription

use of io.sloeber.core.api.CompileDescription in project arduino-eclipse-plugin by Sloeber.

the class RegressionTest method closeProjectRemovesPropertiesSloeber.

@Test
public void closeProjectRemovesPropertiesSloeber() throws Exception {
    String DummyData = "a object";
    String projectName = "closeProjectRemovesPropertiesSloeber";
    QualifiedName qualifiedName = new QualifiedName("io.sloebertest", projectName);
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    CodeDescription codeDescriptor = new CodeDescription(CodeDescription.CodeTypes.defaultCPP);
    CompileDescription inCompileDescription = getBunkersCompileDescription();
    IProject project = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, inCompileDescription, new NullProgressMonitor());
    // Read the data we want to test
    // for the indexer
    Shared.waitForAllJobsToFinish();
    // project.open(null);
    project.setSessionProperty(qualifiedName, DummyData);
    project.close(null);
    project.open(null);
    Object projData = project.getSessionProperty(qualifiedName);
    if (projData != null) {
        fail("non persistent projectdescription properties behave persistent during project close open in Sloeber");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) QualifiedName(org.eclipse.core.runtime.QualifiedName) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 20 with CompileDescription

use of io.sloeber.core.api.CompileDescription in project arduino-eclipse-plugin by Sloeber.

the class CompileProperties method getFromScreen.

@Override
protected Object getFromScreen() {
    CompileDescription compDesc = (CompileDescription) getDescription(getConfdesc());
    WarningLevels warningLevel = WarningLevels.valueOf(myWarningLevel.getText());
    warningLevel.setCustomWarningLevel(myCustomWarningLevel.getText());
    SizeCommands sizeCommand = SizeCommands.valueOf(mySizeCommand.getText());
    sizeCommand.setCustomSizeCommand(myCustomSizeCommand.getText());
    compDesc.setWarningLevel(warningLevel);
    compDesc.setSizeCommand(sizeCommand);
    compDesc.set_C_andCPP_CompileOptions(this.myCAndCppCommand.getText());
    compDesc.set_C_CompileOptions(this.myCCommand.getText());
    compDesc.set_CPP_CompileOptions(this.myCppCommand.getText());
    compDesc.set_All_CompileOptions(this.myAllCommand.getText());
    compDesc.set_Archive_CompileOptions(this.myArchiveCommand.getText());
    compDesc.set_Assembly_CompileOptions(this.myAssemblyCommand.getText());
    compDesc.set_Link_CompileOptions(this.myLinkCommand.getText());
    return compDesc;
}
Also used : WarningLevels(io.sloeber.core.api.CompileDescription.WarningLevels) CompileDescription(io.sloeber.core.api.CompileDescription) SizeCommands(io.sloeber.core.api.CompileDescription.SizeCommands)

Aggregations

CompileDescription (io.sloeber.core.api.CompileDescription)21 CodeDescription (io.sloeber.core.api.CodeDescription)14 Test (org.junit.Test)14 BoardDescription (io.sloeber.core.api.BoardDescription)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 IProject (org.eclipse.core.resources.IProject)12 CoreException (org.eclipse.core.runtime.CoreException)7 IPath (org.eclipse.core.runtime.IPath)7 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 SloeberProject (io.sloeber.core.api.SloeberProject)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 MCUBoard (io.sloeber.providers.MCUBoard)2 TreeMap (java.util.TreeMap)2 SizeCommands (io.sloeber.core.api.CompileDescription.SizeCommands)1 WarningLevels (io.sloeber.core.api.CompileDescription.WarningLevels)1 OtherDescription (io.sloeber.core.api.OtherDescription)1 File (java.io.File)1 URI (java.net.URI)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 HashMap (java.util.HashMap)1