|
| 1 | +package io.sloeber.core; |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +import org.eclipse.cdt.core.CCorePlugin; |
| 7 | +import org.eclipse.cdt.core.model.CoreModel; |
| 8 | +import org.eclipse.cdt.core.model.ICProject; |
| 9 | +import org.eclipse.core.resources.IProject; |
| 10 | +import org.eclipse.core.resources.IncrementalProjectBuilder; |
| 11 | +import org.eclipse.core.runtime.IPath; |
| 12 | +import org.eclipse.core.runtime.IProgressMonitor; |
| 13 | +import org.eclipse.core.runtime.NullProgressMonitor; |
| 14 | +import org.junit.jupiter.api.BeforeAll; |
| 15 | +import org.junit.jupiter.api.Test; |
| 16 | +import static org.junit.jupiter.api.Assertions.*; |
| 17 | + |
| 18 | +import io.sloeber.arduinoFramework.api.LibraryManager; |
| 19 | +import io.sloeber.core.api.CodeDescription; |
| 20 | +import io.sloeber.core.api.CompileDescription; |
| 21 | +import io.sloeber.core.api.ConfigurationPreferences; |
| 22 | +import io.sloeber.core.api.SloeberProject; |
| 23 | +import io.sloeber.providers.Arduino; |
| 24 | +import io.sloeber.providers.MCUBoard; |
| 25 | + |
| 26 | +@SuppressWarnings({ "nls", "static-method"}) |
| 27 | +public class BuildTests_not_on_github { |
| 28 | + |
| 29 | + /* |
| 30 | + * In new new installations (of the Sloeber development environment) the |
| 31 | + * installer job will trigger downloads These must have finished before we can |
| 32 | + * start testing |
| 33 | + */ |
| 34 | + @BeforeAll |
| 35 | + public static void beforeClass() throws Exception { |
| 36 | + Shared.waitForBoardsManager(); |
| 37 | + Shared.setDeleteProjects(false); |
| 38 | + ConfigurationPreferences.setUseBonjour(false); |
| 39 | + } |
| 40 | + |
| 41 | + |
| 42 | + @Test |
| 43 | + public void onlyInstallLibraryWhenAllowed() throws Exception { |
| 44 | + String libName="SD"; |
| 45 | + |
| 46 | + //set option not to install lib |
| 47 | + ConfigurationPreferences.setInstallLibraries(false); |
| 48 | + |
| 49 | + //uninstall lib |
| 50 | + LibraryManager.uninstallLibrary( libName); |
| 51 | + |
| 52 | + // create a project that uses a the lib |
| 53 | + String testName = "onlyInstallLibraryWhenAllowed"; |
| 54 | + IProgressMonitor monitor=new NullProgressMonitor(); |
| 55 | + IPath templateFolder = Shared.getTemplateFolder(testName); |
| 56 | + CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder); |
| 57 | + MCUBoard unoboard = Arduino.uno(); |
| 58 | + IProject theTestProject = SloeberProject.createArduinoProject(testName, null, unoboard.getBoardDescriptor(), codeDescriptor, |
| 59 | + new CompileDescription(), monitor); |
| 60 | + //wait for indexer and so on |
| 61 | + Shared.waitForAllJobsToFinish(); |
| 62 | + |
| 63 | + |
| 64 | + //Building the project should fail |
| 65 | + assertNotNull( Shared.buildAndVerify(theTestProject,3,IncrementalProjectBuilder.FULL_BUILD ,monitor),"Sloeber wrongly installed lib "+libName); |
| 66 | + |
| 67 | + //set option to install libs |
| 68 | + ConfigurationPreferences.setInstallLibraries(true); |
| 69 | + |
| 70 | + //trigger the indexer |
| 71 | + ICProject cTestProject = CoreModel.getDefault().getCModel().getCProject(theTestProject.getName()); |
| 72 | + CCorePlugin.getIndexManager().reindex(cTestProject); |
| 73 | + Thread.sleep(5000); |
| 74 | + Shared.waitForIndexer(theTestProject); |
| 75 | + |
| 76 | + //build should not fail |
| 77 | + assertNull( Shared.buildAndVerify(theTestProject,3,IncrementalProjectBuilder.FULL_BUILD ,monitor),"Sloeber dit not install lib "+libName); |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + } |
| 82 | +} |
0 commit comments