Search in sources :

Example 1 with CodeDescription

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

the class CompileAndUpload method testExamples.

@Test
public void testExamples() throws Exception {
    IPath templateFolder = Shared.getTemplateFolder("fastBlink");
    CompileDescription compileOptions = new CompileDescription();
    DateTimeFormatter df = DateTimeFormatter.ofPattern("YYYY/MM/dd-HH-mm-ss");
    String SerialDumpContent = myName + '-' + df.format(LocalDateTime.now());
    compileOptions.set_C_andCPP_CompileOptions("-DINTERVAL=" + interval + " -DSERIAlDUMP=" + SerialDumpContent);
    CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
    Map<String, String> replacers = new TreeMap<>();
    replacers.put("{SerialMonitorSerial}", myBoard.mySerialPort);
    codeDescriptor.setReplacers(replacers);
    Build_Verify_upload(codeDescriptor, compileOptions, SerialDumpContent);
}
Also used : IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) TreeMap(java.util.TreeMap) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 2 with CodeDescription

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

the class CreateAndCompileArduinoIDEExamplesOnTeensyTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{0}")
public static Collection examples() {
    installAdditionalBoards();
    Shared.waitForAllJobsToFinish();
    Preferences.setUseBonjour(false);
    LinkedList<Object[]> examples = new LinkedList<>();
    List<MCUBoard> allBoards = Teensy.getAllBoards();
    TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
    for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
        String fqn = curexample.getKey().trim();
        IPath examplePath = curexample.getValue();
        Example example = new Example(fqn, examplePath);
        if (!skipExample(example)) {
            ArrayList<IPath> paths = new ArrayList<>();
            paths.add(examplePath);
            CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
            for (MCUBoard curBoard : allBoards) {
                if (curBoard.isExampleSupported(example)) {
                    String projectName = Shared.getProjectName(codeDescriptor, example, curBoard);
                    Map<String, String> boardOptions = curBoard.getBoardOptions(example);
                    BoardDescription boardDescriptor = curBoard.getBoardDescriptor();
                    boardDescriptor.setOptions(boardOptions);
                    Object[] theData = new Object[] { projectName, codeDescriptor, boardDescriptor };
                    examples.add(theData);
                }
            }
        }
    }
    return examples;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) MCUBoard(io.sloeber.providers.MCUBoard) TreeMap(java.util.TreeMap) Map(java.util.Map) Parameters(org.junit.runners.Parameterized.Parameters)

Example 3 with CodeDescription

use of io.sloeber.core.api.CodeDescription 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 4 with CodeDescription

use of io.sloeber.core.api.CodeDescription 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 5 with CodeDescription

use of io.sloeber.core.api.CodeDescription 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)

Aggregations

CodeDescription (io.sloeber.core.api.CodeDescription)20 BoardDescription (io.sloeber.core.api.BoardDescription)16 Test (org.junit.Test)15 CompileDescription (io.sloeber.core.api.CompileDescription)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 IProject (org.eclipse.core.resources.IProject)12 IPath (org.eclipse.core.runtime.IPath)12 CoreException (org.eclipse.core.runtime.CoreException)7 ArrayList (java.util.ArrayList)6 MCUBoard (io.sloeber.providers.MCUBoard)5 TreeMap (java.util.TreeMap)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 Parameters (org.junit.runners.Parameterized.Parameters)4 SloeberProject (io.sloeber.core.api.SloeberProject)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 OtherDescription (io.sloeber.core.api.OtherDescription)1 File (java.io.File)1 URI (java.net.URI)1