Search in sources :

Example 6 with BoardDescription

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

the class CreateAndCompileLibraryExamplesTest method testExamples.

@Test
public void testExamples() {
    Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
    Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
    if (!myBoard.isExampleSupported(myExample)) {
        fail("Trying to run a test on unsoprted board");
        myTotalFails++;
        return;
    }
    ArrayList<IPath> paths = new ArrayList<>();
    paths.add(myExample.getPath());
    CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
    Map<String, String> boardOptions = myBoard.getBoardOptions(myExample);
    BoardDescription boardDescriptor = myBoard.getBoardDescriptor();
    boardDescriptor.setOptions(boardOptions);
    if (!Shared.BuildAndVerify(boardDescriptor, codeDescriptor)) {
        myTotalFails++;
        fail(Shared.getLastFailMessage());
    }
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with BoardDescription

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

the class RegressionTest method are_jantjes_options_taken_into_account.

/**
 * This test will fail if the arduino compile option are not taken into account
 * To do sa a bunch of defines are added to the command line and the code checks
 * whether these defines are set properly
 *
 * @throws Exception
 */
@Test
public void are_jantjes_options_taken_into_account() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "are_defines_found";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        CompileDescription compileOptions = new CompileDescription();
        compileOptions.set_C_andCPP_CompileOptions("-DTEST_C_CPP");
        compileOptions.set_C_CompileOptions("-DTEST_C");
        compileOptions.set_CPP_CompileOptions("-DTEST_CPP");
        theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, compileOptions, new NullProgressMonitor());
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " The defines have not been taken into account properly");
        }
    } 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) IPath(org.eclipse.core.runtime.IPath) 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 8 with BoardDescription

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

the class RegressionTest method createDefaultInoProject.

@Test
public void createDefaultInoProject() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "createDefaultInoProject";
    CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
    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 + " INO 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 9 with BoardDescription

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

the class RegressionTest method issue555.

/**
 * make sure when switching between a board with variant file and without the
 * build still succeeds
 */
@Test
public void issue555() {
    if (MySystem.getTeensyPlatform().isEmpty()) {
        // skip test due to no teensy install folder provided
        // do not fail as this will always fail on travis
        System.out.println("skipping the test because teensy is not installed.");
        return;
    }
    System.out.println("Teensy is installed at " + MySystem.getTeensyPlatform());
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    BoardDescription teensyBoardid = Teensy.Teensy3_1().getBoardDescriptor();
    IProject theTestProject = null;
    CodeDescription codeDescriptor = CodeDescription.createDefaultIno();
    String projectName = "issue555";
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to create the project:" + projectName);
        return;
    }
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " as uno  build errors");
        }
    } catch (CoreException e) {
        e.printStackTrace();
        fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
    }
    SloeberProject arduinoProject = SloeberProject.getSloeberProject(theTestProject);
    ICProjectDescription cProjectDescription = CCorePlugin.getDefault().getProjectDescription(theTestProject);
    arduinoProject.setBoardDescription(cProjectDescription.getActiveConfiguration().getName(), teensyBoardid, true);
    Shared.waitForAllJobsToFinish();
    try {
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            Shared.waitForAllJobsToFinish();
            theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            if (Shared.hasBuildErrors(theTestProject)) {
                fail("Failed to compile the project:" + projectName + " as teensy");
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
        fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as teensy exception");
    }
}
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) CoreException(org.eclipse.core.runtime.CoreException) SloeberProject(io.sloeber.core.api.SloeberProject) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 10 with BoardDescription

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

the class RegressionTest method are_defines_before_includes_taken_into_account.

/**
 * If a .ino file is defining defines before including a include this should be
 * handled properly by the ino to cpp parser
 *
 * @throws Exception
 */
@Test
public void are_defines_before_includes_taken_into_account() throws Exception {
    BoardDescription unoBoardid = Arduino.uno().getBoardDescriptor();
    IProject theTestProject = null;
    String projectName = "defines_and_includes";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoardid, codeDescriptor, new CompileDescription(), new NullProgressMonitor());
    // for the indexer
    Shared.waitForAllJobsToFinish();
    theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    if (Shared.hasBuildErrors(theTestProject)) {
        fail("Failed to compile the project:" + projectName + " defines have not been taken into account properly.");
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

BoardDescription (io.sloeber.core.api.BoardDescription)30 CodeDescription (io.sloeber.core.api.CodeDescription)16 Test (org.junit.Test)15 CompileDescription (io.sloeber.core.api.CompileDescription)13 IProject (org.eclipse.core.resources.IProject)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)12 IPath (org.eclipse.core.runtime.IPath)10 CoreException (org.eclipse.core.runtime.CoreException)7 SloeberProject (io.sloeber.core.api.SloeberProject)6 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)4 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)4 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 File (java.io.File)3 Parameters (org.junit.runners.Parameterized.Parameters)3 ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)2 ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)2 ArduinoPlatformVersion (io.sloeber.core.api.Json.ArduinoPlatformVersion)2 MCUBoard (io.sloeber.providers.MCUBoard)2 URL (java.net.URL)2