mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Convert to JUnit5 and cleanup resources
Also stop catching exceptions and discarding stacktraces Part of #117
This commit is contained in:
parent
c650c25b85
commit
05322ac206
2 changed files with 92 additions and 114 deletions
|
@ -14,16 +14,21 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
@ -48,42 +53,16 @@ import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import junit.framework.Test;
|
public class MultiVersionSupportTests extends BaseTestCase5 {
|
||||||
import junit.framework.TestCase;
|
private IProject proj = null;
|
||||||
import junit.framework.TestSuite;
|
private IManagedProject mproj = null;
|
||||||
|
|
||||||
public class MultiVersionSupportTests extends TestCase {
|
private IConfiguration[] cfgs = null;
|
||||||
static IProject proj = null;
|
|
||||||
static IManagedProject mproj = null;
|
|
||||||
|
|
||||||
IConfiguration[] cfgs = null;
|
|
||||||
private IWorkspace worksp;
|
private IWorkspace worksp;
|
||||||
|
|
||||||
public MultiVersionSupportTests() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultiVersionSupportTests(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
TestSuite suite = new TestSuite(MultiVersionSupportTests.class.getName());
|
|
||||||
//$JUnit-BEGIN$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testProjectConverterConvenienceRoutines")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testConfigurationNameProvider")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testConfigurationDescription")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testVersionInfo")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testVersionsSupportedAttribute")); //$NON-NLS-1$
|
|
||||||
//the test is invalid, disabling for now (see bug# 193831)
|
|
||||||
// suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT20")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT21")); //$NON-NLS-1$
|
|
||||||
suite.addTest(new MultiVersionSupportTests("testProjectConversion")); //$NON-NLS-1$
|
|
||||||
//$JUnit-END$
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function tests the functionality of Project converter convenience routines
|
* This function tests the functionality of Project converter convenience routines
|
||||||
* defined in ManagedBuildManager class. These convenience routines are generic routines
|
* defined in ManagedBuildManager class. These convenience routines are generic routines
|
||||||
|
@ -93,6 +72,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* iii) To convert a Build Object
|
* iii) To convert a Build Object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testProjectConverterConvenienceRoutines() throws Exception {
|
public void testProjectConverterConvenienceRoutines() throws Exception {
|
||||||
String projectName = "TestProjectConverterConvenienceRoutines"; //$NON-NLS-1$
|
String projectName = "TestProjectConverterConvenienceRoutines"; //$NON-NLS-1$
|
||||||
String projectTypeId = "testProjectConverterConvenienceRoutines.exe"; //$NON-NLS-1$
|
String projectTypeId = "testProjectConverterConvenienceRoutines.exe"; //$NON-NLS-1$
|
||||||
|
@ -130,6 +110,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* configuration names as "Debug", "Release", "Debug_ia64" and "Release_ia64" while creating a project.
|
* configuration names as "Debug", "Release", "Debug_ia64" and "Release_ia64" while creating a project.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testConfigurationNameProvider() throws Exception {
|
public void testConfigurationNameProvider() throws Exception {
|
||||||
String[] expectedConfigNames = { "Debug", "Release", "Debug_ia64", "Release_ia64" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
String[] expectedConfigNames = { "Debug", "Release", "Debug_ia64", "Release_ia64" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
String[] actualConfigNames = new String[4];
|
String[] actualConfigNames = new String[4];
|
||||||
|
@ -160,6 +141,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* expected description after creating a project.
|
* expected description after creating a project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testConfigurationDescription() throws Exception {
|
public void testConfigurationDescription() throws Exception {
|
||||||
String[] expectedConfigDescriptions = { "debug configuration for IA32 windows", //$NON-NLS-1$
|
String[] expectedConfigDescriptions = { "debug configuration for IA32 windows", //$NON-NLS-1$
|
||||||
"release configuration for IA32 windows", "debug configuration for IA64 windows",
|
"release configuration for IA32 windows", "debug configuration for IA64 windows",
|
||||||
|
@ -191,6 +173,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* is retrived from plugin manifest file correctly or not.
|
* is retrived from plugin manifest file correctly or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testVersionInfo() throws Exception {
|
public void testVersionInfo() throws Exception {
|
||||||
|
|
||||||
String projectName = "TestVersionInfo"; //$NON-NLS-1$
|
String projectName = "TestVersionInfo"; //$NON-NLS-1$
|
||||||
|
@ -276,6 +259,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* ToolChain/Tool/Builder elements is retrived from plugin manifest file correctly or not.
|
* ToolChain/Tool/Builder elements is retrived from plugin manifest file correctly or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testVersionsSupportedAttribute() throws Exception {
|
public void testVersionsSupportedAttribute() throws Exception {
|
||||||
// create managed project
|
// create managed project
|
||||||
String projectName = "TestVersionSupportAttribute"; //$NON-NLS-1$
|
String projectName = "TestVersionSupportAttribute"; //$NON-NLS-1$
|
||||||
|
@ -315,7 +299,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createManagedProject(String name, String projectTypeId) {
|
void createManagedProject(String name, String projectTypeId) throws CoreException, BuildException {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
proj = root.getProject(name);
|
proj = root.getProject(name);
|
||||||
|
|
||||||
|
@ -341,16 +325,13 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
|
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
|
||||||
desc.saveProjectData();
|
desc.saveProjectData();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fail("Cannot create project: " + e.getLocalizedMessage()); //$NON-NLS-1$
|
throw new AssertionError("Cannot create project: " + e.getLocalizedMessage(), e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Call this function just to avoid init problems in getProjectType();
|
// Call this function just to avoid init problems in getProjectType();
|
||||||
ManagedBuildManager.getDefinedProjectTypes();
|
ManagedBuildManager.getDefinedProjectTypes();
|
||||||
IProjectType projType = ManagedBuildManager.getProjectType(projectTypeId);
|
IProjectType projType = ManagedBuildManager.getProjectType(projectTypeId);
|
||||||
assertNotNull(projType);
|
assertNotNull(projType);
|
||||||
try {
|
mproj = ManagedBuildManager.createManagedProject(proj, projType);
|
||||||
mproj = ManagedBuildManager.createManagedProject(proj, projType);
|
|
||||||
} catch (BuildException e) {
|
|
||||||
}
|
|
||||||
ManagedBuildManager.setNewProjectVersion(proj);
|
ManagedBuildManager.setNewProjectVersion(proj);
|
||||||
IConfiguration[] cfgs = projType.getConfigurations();
|
IConfiguration[] cfgs = projType.getConfigurations();
|
||||||
|
|
||||||
|
@ -363,10 +344,8 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
ManagedBuildManager.setDefaultConfiguration(proj, null);
|
ManagedBuildManager.setDefaultConfiguration(proj, null);
|
||||||
}
|
}
|
||||||
// open project w/o progress monitor; no action performed if it's opened
|
// open project w/o progress monitor; no action performed if it's opened
|
||||||
try {
|
proj.open(null);
|
||||||
proj.open(null);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -387,7 +366,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
* doInit() - call it at the beginning of every test
|
* doInit() - call it at the beginning of every test
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void doInit(String projectName, String projectTypeId) {
|
private void doInit(String projectName, String projectTypeId) throws Exception {
|
||||||
createManagedProject(projectName, projectTypeId);
|
createManagedProject(projectName, projectTypeId);
|
||||||
assertNotNull(proj);
|
assertNotNull(proj);
|
||||||
assertNotNull(mproj);
|
assertNotNull(mproj);
|
||||||
|
@ -397,6 +376,8 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
assertNotNull(cfgs);
|
assertNotNull(cfgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled("See Bug 193831")
|
||||||
public void testToolChainConversion_CDT20() throws Exception {
|
public void testToolChainConversion_CDT20() throws Exception {
|
||||||
// Pass projDirName as 'test20', and 'true' to update Project
|
// Pass projDirName as 'test20', and 'true' to update Project
|
||||||
doTestProjectUpdate("test20", true); //$NON-NLS-1$
|
doTestProjectUpdate("test20", true); //$NON-NLS-1$
|
||||||
|
@ -404,25 +385,21 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
File inputFile = new File(tmpDir + "/converterOutput20.txt"); //$NON-NLS-1$
|
File inputFile = new File(tmpDir + "/converterOutput20.txt"); //$NON-NLS-1$
|
||||||
try {
|
assertTrue(inputFile.exists());
|
||||||
assertTrue(inputFile.exists());
|
|
||||||
|
|
||||||
String expectedContent = "Converter for CDT 2.0 Project is invoked"; //$NON-NLS-1$
|
String expectedContent = "Converter for CDT 2.0 Project is invoked"; //$NON-NLS-1$
|
||||||
|
|
||||||
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
||||||
String actualContent;
|
String actualContent;
|
||||||
|
|
||||||
if ((actualContent = data.readLine()) != null) {
|
if ((actualContent = data.readLine()) != null) {
|
||||||
assertEquals(actualContent, expectedContent);
|
assertEquals(actualContent, expectedContent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToolChainConversion_CDT21() throws Exception {
|
public void testToolChainConversion_CDT21() throws Exception {
|
||||||
// Pass projDirName as 'test21', and 'true' to update Project
|
// Pass projDirName as 'test21', and 'true' to update Project
|
||||||
doTestProjectUpdate("test21", true); //$NON-NLS-1$
|
doTestProjectUpdate("test21", true); //$NON-NLS-1$
|
||||||
|
@ -430,25 +407,21 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
File inputFile = new File(tmpDir + "/converterOutput21.txt"); //$NON-NLS-1$
|
File inputFile = new File(tmpDir + "/converterOutput21.txt"); //$NON-NLS-1$
|
||||||
try {
|
assertTrue(inputFile.exists());
|
||||||
assertTrue(inputFile.exists());
|
|
||||||
|
|
||||||
String expectedContent = "Converter for CDT 2.1 Project is invoked"; //$NON-NLS-1$
|
String expectedContent = "Converter for CDT 2.1 Project is invoked"; //$NON-NLS-1$
|
||||||
|
|
||||||
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
||||||
String actualContent;
|
String actualContent;
|
||||||
|
|
||||||
if ((actualContent = data.readLine()) != null) {
|
if ((actualContent = data.readLine()) != null) {
|
||||||
assertEquals(actualContent, expectedContent);
|
assertEquals(actualContent, expectedContent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testProjectConversion() throws Exception {
|
public void testProjectConversion() throws Exception {
|
||||||
// Pass the 'projDirName' as 'testProjectConversion', and 'true' to update Project
|
// Pass the 'projDirName' as 'testProjectConversion', and 'true' to update Project
|
||||||
doTestProjectUpdate("testProjectConversion", true); //$NON-NLS-1$
|
doTestProjectUpdate("testProjectConversion", true); //$NON-NLS-1$
|
||||||
|
@ -456,26 +429,21 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
File inputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$
|
File inputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$
|
||||||
try {
|
assertTrue(inputFile.exists());
|
||||||
assertTrue(inputFile.exists());
|
|
||||||
|
|
||||||
String expectedContent = "The converter for the projectType testProject_1.0.0 is invoked"; //$NON-NLS-1$
|
String expectedContent = "The converter for the projectType testProject_1.0.0 is invoked"; //$NON-NLS-1$
|
||||||
|
|
||||||
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
try (BufferedReader data = new BufferedReader(new FileReader(inputFile))) {
|
||||||
String actualContent;
|
String actualContent;
|
||||||
|
|
||||||
if ((actualContent = data.readLine()) != null) {
|
if ((actualContent = data.readLine()) != null) {
|
||||||
assertEquals(actualContent, expectedContent);
|
assertEquals(actualContent, expectedContent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProject getCDT_TestProject(String projDirName) {
|
private IProject getCDT_TestProject(String projDirName) throws Exception {
|
||||||
|
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
File file = null;
|
File file = null;
|
||||||
|
@ -506,25 +474,21 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
ArrayList<IProject> projectList = new ArrayList<>(projectZips.length);
|
ArrayList<IProject> projectList = new ArrayList<>(projectZips.length);
|
||||||
assertEquals(projectZips.length, 1);
|
assertEquals(projectZips.length, 1);
|
||||||
|
|
||||||
try {
|
String projectName = projectZips[0].getName();
|
||||||
String projectName = projectZips[0].getName();
|
if (!projectName.endsWith(".zip"))
|
||||||
if (!projectName.endsWith(".zip"))
|
fail("No projects found in test 'toolChainConversionProjects' project directory " //$NON-NLS-1$
|
||||||
fail("No projects found in test 'toolChainConversionProjects' project directory " //$NON-NLS-1$
|
+ file.getName() + ". The .zip file may be missing or corrupt."); //$NON-NLS-1$
|
||||||
+ file.getName() + ". The .zip file may be missing or corrupt."); //$NON-NLS-1$
|
|
||||||
|
|
||||||
projectName = projectName.substring(0, projectName.length() - ".zip".length()); //$NON-NLS-1$
|
projectName = projectName.substring(0, projectName.length() - ".zip".length()); //$NON-NLS-1$
|
||||||
if (projectName.length() == 0)
|
if (projectName.length() == 0)
|
||||||
fail("No projects found in test 'toolChainConversionProjects' project directory " //$NON-NLS-1$
|
fail("No projects found in test 'toolChainConversionProjects' project directory " //$NON-NLS-1$
|
||||||
+ file.getName() + ". The .zip file may be missing or corrupt."); //$NON-NLS-1$
|
+ file.getName() + ". The .zip file may be missing or corrupt."); //$NON-NLS-1$
|
||||||
// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
// Path path = (Path) root.getLocation();
|
// Path path = (Path) root.getLocation();
|
||||||
// IPath location = new Path( root.getLocation().toString() );
|
// IPath location = new Path( root.getLocation().toString() );
|
||||||
project = ManagedBuildTestHelper.createProject(projectName, projectZips[0], null, null);
|
project = ManagedBuildTestHelper.createProject(projectName, projectZips[0], null, null);
|
||||||
if (project != null)
|
if (project != null)
|
||||||
projectList.add(project);
|
projectList.add(project);
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Exception Occured."); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
if (projectList.size() == 0) {
|
if (projectList.size() == 0) {
|
||||||
fail("No projects found in test project directory " //$NON-NLS-1$
|
fail("No projects found in test project directory " //$NON-NLS-1$
|
||||||
|
@ -534,7 +498,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestProjectUpdate(String projDirName, boolean updateProject) {
|
private void doTestProjectUpdate(String projDirName, boolean updateProject) throws Exception {
|
||||||
IOverwriteQuery queryALL = new IOverwriteQuery() {
|
IOverwriteQuery queryALL = new IOverwriteQuery() {
|
||||||
@Override
|
@Override
|
||||||
public String queryOverwrite(String file) {
|
public String queryOverwrite(String file) {
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.language.settings.providers.tests;
|
package org.eclipse.cdt.managedbuilder.language.settings.providers.tests;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -30,7 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||||
import org.eclipse.cdt.internal.core.Cygwin;
|
import org.eclipse.cdt.internal.core.Cygwin;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
@ -43,11 +48,12 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases to test GCC built-in specs detector.
|
* Test cases to test GCC built-in specs detector.
|
||||||
*/
|
*/
|
||||||
public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
public class GCCBuiltinSpecsDetectorTest extends BaseTestCase5 {
|
||||||
private static final String LANGUAGE_ID_C = GCCLanguage.ID;
|
private static final String LANGUAGE_ID_C = GCCLanguage.ID;
|
||||||
private static final String SAMPLE_COMMAND = "NEW_COMMAND";
|
private static final String SAMPLE_COMMAND = "NEW_COMMAND";
|
||||||
private static final String PROJECT_TYPE_EXECUTABLE_GNU = "cdt.managedbuild.target.gnu.exe";
|
private static final String PROJECT_TYPE_EXECUTABLE_GNU = "cdt.managedbuild.target.gnu.exe";
|
||||||
|
@ -99,16 +105,6 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tearDown() throws Exception {
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to fetch configuration descriptions.
|
* Helper method to fetch configuration descriptions.
|
||||||
*/
|
*/
|
||||||
|
@ -127,6 +123,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test expansion of variables in build command.
|
* Test expansion of variables in build command.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_ResolvedCommand() throws Exception {
|
public void testGCCBuiltinSpecsDetector_ResolvedCommand() throws Exception {
|
||||||
{
|
{
|
||||||
// check ${COMMAND} and ${INPUTS}
|
// check ${COMMAND} and ${INPUTS}
|
||||||
|
@ -197,6 +194,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test expansion of relevant tool options in build command.
|
* Test expansion of relevant tool options in build command.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_ResolvedCommand_Flags() throws Exception {
|
public void testGCCBuiltinSpecsDetector_ResolvedCommand_Flags() throws Exception {
|
||||||
// check ${FLAGS}
|
// check ${FLAGS}
|
||||||
MockLspToolchainBuiltinSpecsDetectorCommandResolver detector = new MockLspToolchainBuiltinSpecsDetectorCommandResolver();
|
MockLspToolchainBuiltinSpecsDetectorCommandResolver detector = new MockLspToolchainBuiltinSpecsDetectorCommandResolver();
|
||||||
|
@ -215,6 +213,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro without value.
|
* Test parsing of macro without value.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -232,6 +231,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro with ordinary value.
|
* Test parsing of macro with ordinary value.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Simple() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Simple() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -250,6 +250,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro with value in round brackets.
|
* Test parsing of macro with value in round brackets.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Const() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Const() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -267,6 +268,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition with tabs.
|
* Test parsing of macro definition with tabs.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_WhiteSpaces() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -295,6 +297,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition with empty argument list.
|
* Test parsing of macro definition with empty argument list.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_EmptyArgList() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_EmptyArgList() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -313,6 +316,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition with unused parameter.
|
* Test parsing of macro definition with unused parameter.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ParamUnused() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ParamUnused() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -331,6 +335,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition with multiple parameters.
|
* Test parsing of macro definition with multiple parameters.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ParamSpace() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ParamSpace() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -350,6 +355,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition with multiple parameters and no value.
|
* Test parsing of macro definition with multiple parameters and no value.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ArgsNoValue() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ArgsNoValue() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -368,6 +374,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition having white spaces in various places.
|
* Test parsing of macro definition having white spaces in various places.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Args_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Args_WhiteSpaces() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -396,6 +403,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of include directives.
|
* Test parsing of include directives.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Includes() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes() throws Exception {
|
||||||
// Create model project and folders to test
|
// Create model project and folders to test
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -461,6 +469,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of macro definition of include directives having white spaces.
|
* Test parsing of macro definition of include directives having white spaces.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Includes_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes_WhiteSpaces() throws Exception {
|
||||||
String loc = ResourceHelper.createTemporaryFolder().toString();
|
String loc = ResourceHelper.createTemporaryFolder().toString();
|
||||||
|
|
||||||
|
@ -500,6 +509,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of include directives incorporating symbolic links.
|
* Test parsing of include directives incorporating symbolic links.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Includes_SymbolicLinkUp() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes_SymbolicLinkUp() throws Exception {
|
||||||
// do not test on systems where symbolic links are not supported
|
// do not test on systems where symbolic links are not supported
|
||||||
if (!ResourceHelper.isSymbolicLinkSupported()) {
|
if (!ResourceHelper.isSymbolicLinkSupported()) {
|
||||||
|
@ -537,6 +547,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of include directives included multiple times.
|
* Test parsing of include directives included multiple times.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Includes_Duplicates() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes_Duplicates() throws Exception {
|
||||||
// Create model project and folders to test
|
// Create model project and folders to test
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -568,6 +579,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of include directives for Cygwin for global provider.
|
* Test parsing of include directives for Cygwin for global provider.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
|
||||||
if (!Cygwin.isAvailable()) {
|
if (!Cygwin.isAvailable()) {
|
||||||
// Skip the test if Cygwin is not available.
|
// Skip the test if Cygwin is not available.
|
||||||
|
@ -576,7 +588,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
|
|
||||||
String cygwinLocation = "/usr/include";
|
String cygwinLocation = "/usr/include";
|
||||||
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
||||||
assertTrue("windowsLocation=[" + windowsLocation + "]", new Path(windowsLocation).getDevice() != null);
|
assertTrue(new Path(windowsLocation).getDevice() != null, "windowsLocation=[" + windowsLocation + "]");
|
||||||
|
|
||||||
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
|
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
|
||||||
|
|
||||||
|
@ -598,6 +610,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test parsing of include directives for Cygwin for provider running for a configuration.
|
* Test parsing of include directives for Cygwin for provider running for a configuration.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
|
||||||
if (!Cygwin.isAvailable()) {
|
if (!Cygwin.isAvailable()) {
|
||||||
// Skip the test if Cygwin is not available.
|
// Skip the test if Cygwin is not available.
|
||||||
|
@ -606,7 +619,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
|
|
||||||
String cygwinLocation = "/usr/include";
|
String cygwinLocation = "/usr/include";
|
||||||
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
||||||
assertTrue("windowsLocation=[" + windowsLocation + "]", new Path(windowsLocation).getDevice() != null);
|
assertTrue(new Path(windowsLocation).getDevice() != null, "windowsLocation=[" + windowsLocation + "]");
|
||||||
|
|
||||||
// Create model project and folders to test
|
// Create model project and folders to test
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -634,6 +647,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test expansion of variable ${COMMAND} for case when the command was modified in tool-chain.
|
* Test expansion of variable ${COMMAND} for case when the command was modified in tool-chain.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void test_GCCBuiltinSpecsDetector_ResolveModifiedCommand() throws Exception {
|
public void test_GCCBuiltinSpecsDetector_ResolveModifiedCommand() throws Exception {
|
||||||
// create a new project
|
// create a new project
|
||||||
IProject project = ManagedBuildTestHelper.createProject(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
IProject project = ManagedBuildTestHelper.createProject(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||||
|
|
Loading…
Add table
Reference in a new issue