Search in sources :

Example 6 with BoardDescriptor

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

the class CreateAndCompileLibraryExamplesTest method testExamples.

@Test
public void testExamples() {
    if (myTotalFails > maxFails) {
        // failing is annoying when doing fixing
        return;
    }
    if (skipAtStart >= myCounter++) {
        // skip these
        return;
    }
    if (!myBoardID.isExampleSupported(myExample)) {
        fail("Trying to run a test on unsoprted board");
        return;
    }
    ArrayList<IPath> paths = new ArrayList<>();
    paths.add(myExample.getPath());
    CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
    Map<String, String> boardOptions = myBoardID.getBoardOptions(myExample);
    BoardDescriptor boardDescriptor = myBoardID.getBoardDescriptor();
    boardDescriptor.setOptions(boardOptions);
    BuildAndVerify(myBoardID.getBoardDescriptor(), codeDescriptor);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) Test(org.junit.Test)

Example 7 with BoardDescriptor

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

the class CreateAndCompileTest method boards.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0} ")
public static Collection boards() {
    // build the Arduino way
    Preferences.setUseArduinoToolSelection(true);
    installAdditionalBoards();
    List<BoardDescriptor> boards = new ArrayList<>();
    for (String curBoardFile : PackageManager.getAllBoardsFiles()) {
        // TOFIX these options should not be set here but in IBoard.getOptions
        Map<String, String> options = null;
        if (curBoardFile.contains("Jantje")) {
            // for jantjes boards as unit testing does not make a exe without the gdb lib
            options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
            options.put("type", "debug");
        } else if (curBoardFile.contains("avr_boot")) {
            // for avr_boot avr_boot_atmega328 to have variant
            options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
            options.put("pinout", "avrdevelopers");
        } else if (curBoardFile.contains("/tiny/hardware")) {
            // do not use ATtiny85 @ 128 KHz (watchdog oscillator; 1.8 V BOD)
            // fails in arduino IDE as well
            options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
            options.put("cpu", "attiny25at1");
        }
        boards.addAll(BoardDescriptor.makeBoardDescriptors(new File(curBoardFile), options));
    }
    // to avoid warnings set the upload port to some value
    for (BoardDescriptor curBoard : boards) {
        curBoard.setUploadPort("none");
    }
    ;
    HashSet<String> boardsToIgnoreList = new HashSet<>(Arrays.asList(boardsToIgnoreOnAllOses));
    if (SystemUtils.IS_OS_LINUX) {
        boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnLinux));
    }
    if (SystemUtils.IS_OS_WINDOWS) {
        boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnWindows));
    }
    List<BoardDescriptor> ignoreBoards = new ArrayList<>();
    for (BoardDescriptor curBoard : boards) {
        if (boardsToIgnoreList.contains(curBoard.getBoardName())) {
            ignoreBoards.add(curBoard);
        }
    }
    boards.removeAll(ignoreBoards);
    return boards;
}
Also used : ArrayList(java.util.ArrayList) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) TreeMap(java.util.TreeMap) File(java.io.File) HashSet(java.util.HashSet) Parameters(org.junit.runners.Parameterized.Parameters)

Example 8 with BoardDescriptor

use of io.sloeber.core.api.BoardDescriptor 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
 */
@SuppressWarnings("static-method")
@Test
public void are_jantjes_options_taken_into_account() throws Exception {
    PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
    Map<String, String> unoOptions = new HashMap<>();
    BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
    IProject theTestProject = null;
    String projectName = "are_defines_found";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        CompileOptions compileOptions = new CompileOptions(null);
        compileOptions.set_C_andCPP_CompileOptions("-DTEST_C_CPP");
        compileOptions.set_C_CompileOptions("-DTEST_C");
        compileOptions.set_CPP_CompileOptions("-DTEST_CPP");
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, compileOptions, monitor);
        ICProjectDescription prjCDesc = CoreModel.getDefault().getProjectDescription(theTestProject);
        CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(theTestProject, prjCDesc, true, null);
        // 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) ICProjectDescription(org.eclipse.cdt.core.settings.model.ICProjectDescription) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 9 with BoardDescriptor

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

the class RegressionTest method are_defines_before_includes_taken_into_account.

/**
 * If a .ino file is including a include using extern C is this handled
 * properly by the ino to cpp parser
 * @throws Exception
 */
@SuppressWarnings("static-method")
@Test
public void are_defines_before_includes_taken_into_account() throws Exception {
    PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
    Map<String, String> unoOptions = new HashMap<>();
    BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
    IProject theTestProject = null;
    String projectName = "externc";
    IPath templateFolder = Shared.getTemplateFolder(projectName);
    CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
    NullProgressMonitor monitor = new NullProgressMonitor();
    try {
        theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
        // for the indexer
        Shared.waitForAllJobsToFinish();
        theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
        if (Shared.hasBuildErrors(theTestProject)) {
            fail("Failed to compile the project:" + projectName + " extern \"C\" has 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) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) CompileOptions(io.sloeber.core.api.CompileOptions) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) CodeDescriptor(io.sloeber.core.api.CodeDescriptor) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 10 with BoardDescriptor

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

the class RegressionTest method redirectedJson.

/**
 * Test wether a platform json redirect is handled properly
 * https://github.com/jantje/arduino-eclipse-plugin/issues/393
 */
@SuppressWarnings("static-method")
@Test
public void redirectedJson() {
    // this board references to arduino avr so install that one to
    PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
    PackageManager.installLatestPlatform("package_talk2.wisen.com_index.json", "Talk2", "Talk2 AVR Boards");
    Map<String, String> options = new HashMap<>();
    options.put("mhz", "16MHz");
    BoardDescriptor boardid = PackageManager.getBoardDescriptor("package_talk2.wisen.com_index.json", "Talk2", "Talk2 AVR Boards", "whispernode", options);
    if (boardid == null) {
        fail("redirect Json ");
        return;
    }
    Shared.BuildAndVerify(boardid, CodeDescriptor.createDefaultIno());
}
Also used : HashMap(java.util.HashMap) BoardDescriptor(io.sloeber.core.api.BoardDescriptor) Test(org.junit.Test)

Aggregations

BoardDescriptor (io.sloeber.core.api.BoardDescriptor)16 CodeDescriptor (io.sloeber.core.api.CodeDescriptor)8 HashMap (java.util.HashMap)7 CoreException (org.eclipse.core.runtime.CoreException)7 IPath (org.eclipse.core.runtime.IPath)7 Test (org.junit.Test)7 CompileOptions (io.sloeber.core.api.CompileOptions)6 IProject (org.eclipse.core.resources.IProject)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 ArrayList (java.util.ArrayList)3 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)3 TreeMap (java.util.TreeMap)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Parameters (org.junit.runners.Parameterized.Parameters)2 InternalBoardDescriptor (io.sloeber.core.InternalBoardDescriptor)1 MCUBoard (io.sloeber.providers.MCUBoard)1 File (java.io.File)1 IOException (java.io.IOException)1