Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2012-03-16 14:54:06 +0000
committerMikhail Khodjaiants2012-03-16 14:54:06 +0000
commitf9e1d4526467707d5f57559247b215da2b75023b (patch)
tree28d50cd08b5fa77fd30e2e6d534a5206a61ab46f /core/org.eclipse.cdt.core.tests
parentd64f97835e7d948910eaee9577b778c9e94004a6 (diff)
parent21377164562efab742036a08ba3890dead6a98c8 (diff)
downloadorg.eclipse.cdt-f9e1d4526467707d5f57559247b215da2b75023b.tar.gz
org.eclipse.cdt-f9e1d4526467707d5f57559247b215da2b75023b.tar.xz
org.eclipse.cdt-f9e1d4526467707d5f57559247b215da2b75023b.zip
Merge branch 'master' of ssh://mkhodjai@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java77
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java297
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java39
4 files changed, 247 insertions, 175 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
index 617eea5d12e..0f7b4c86998 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
@@ -27,6 +27,7 @@ import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
+import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -903,7 +904,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
String windowsFileName = fProject.getLocation().append(fileName).toOSString();
String cygwinFileName;
try {
- cygwinFileName = ResourceHelper.windowsToCygwinPath(windowsFileName);
+ cygwinFileName = Cygwin.windowsToCygwinPath(windowsFileName);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
@@ -931,7 +932,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
String usrIncludeWindowsPath;
try {
- usrIncludeWindowsPath = ResourceHelper.cygwinToWindowsPath(cygwinFolder);
+ usrIncludeWindowsPath = Cygwin.cygwinToWindowsPath(cygwinFolder);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
@@ -961,7 +962,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
String windowsFileName = anotherProject.getLocation().append(fileName).toOSString();
String cygwinFileName;
try {
- cygwinFileName = ResourceHelper.windowsToCygwinPath(windowsFileName);
+ cygwinFileName = Cygwin.windowsToCygwinPath(windowsFileName);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
@@ -1010,7 +1011,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
String windowsFileName = fProject.getLocation().append(fileName).toOSString();
String cygwinFileName;
try {
- cygwinFileName = ResourceHelper.windowsToCygwinPath(windowsFileName);
+ cygwinFileName = Cygwin.windowsToCygwinPath(windowsFileName);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
@@ -1021,7 +1022,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
String lines = "make[0]: Entering directory `dir'\n"
+ cygwinFileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
@@ -1273,21 +1274,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make -j2\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1298,21 +1299,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make -j 2\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1323,21 +1324,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make -j1\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1348,21 +1349,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make -j 1\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1373,21 +1374,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make --jobs=2\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1398,21 +1399,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "make --jobs=1\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1423,21 +1424,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
-
+
String lines = "gmake384 -k -j all\n"
+ "make[0]: Entering directory `Folder'\n"
+ fileName+":1:error\n";
-
+
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
@@ -1447,10 +1448,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFolder(fProject, "Folder/AbsoluteRemoteFolder");
IFile file = ResourceHelper.createFile(fProject, "Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h");
-
+
parseOutput("/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h:1:error");
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h",problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
@@ -1469,16 +1470,16 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(anotherProject, "Folder");
ResourceHelper.createFolder(anotherProject, "Folder/AbsoluteRemoteFolder");
IFile file = ResourceHelper.createFile(anotherProject, "Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h");
-
+
parseOutput("/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h:1:error");
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/ProjectMappedRemoteAbsolutePathAnotherProject/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h",problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
-
+
/**
* Checks if a file from error output can be found.
*
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
index 7a6384022c1..77b493ea867 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@ package org.eclipse.cdt.core.resources.tests;
import java.io.File;
import java.io.IOException;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -54,6 +55,7 @@ public class RefreshScopeTests extends TestCase {
private IFolder fFolder4;
private IFolder fFolder5;
private IFolder fFolder6;
+ private String config1,config2;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
@@ -74,6 +76,9 @@ public class RefreshScopeTests extends TestCase {
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
IProject project = root.getProject("testRefreshScope");
+ config1 = "Debug";
+ config2 = "Release";
+
// create some folders
// structure is:
/*
@@ -123,56 +128,80 @@ public class RefreshScopeTests extends TestCase {
}
public void testAddDeleteResource() throws CoreException {
-
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
- manager.addResourceToRefresh(fProject, fFolder1);
-
- IResource[] resources = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resources.length, 1);
- assertEquals(fFolder1, resources[0]);
-
- manager.addResourceToRefresh(fProject, fFolder2);
- resources = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resources.length, 2);
- assertEquals(fFolder1, resources[0]);
- assertEquals(fFolder2, resources[1]);
-
- // first try deleting a resource that was never added... the project
- manager.deleteResourceToRefresh(fProject, fProject);
- IResource[] resourcesAfterDelete = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resourcesAfterDelete.length, 2);
- assertEquals(fFolder1, resources[0]);
- assertEquals(fFolder2, resources[1]);
-
+ // TEST 1:
+ // add resource "folder1" under config1.
+ manager.addResourceToRefresh(fProject, config1, fFolder1);
+ // now, check that it was added.
+ IResource[] config1_resources = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resources.length, 2);
+ assertEquals(fFolder1, config1_resources[1]);
+
+ // TEST 2:
+ // add resource "folder2" under config1
+ manager.addResourceToRefresh(fProject, config1, fFolder2);
+ // now check to see that it and "folder1" are still there.
+ config1_resources = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resources.length, 3); // 3 because by default the project is always there.
+ assertEquals(fFolder2, config1_resources[0]);
+ assertEquals(fFolder1, config1_resources[2]);
+ // make sure it wasn't added under "Release", which should be empty now.
+ IResource[] config2_resources = manager.getResourcesToRefresh(fProject, config2).toArray(new IResource[0]);
+ assertEquals(config2_resources.length,1); // 1 because project is there by default.
+ assertEquals(fProject,config2_resources[0]);
+ // and add one under config 2.
+ manager.addResourceToRefresh(fProject, config2, fFolder1);
+ config2_resources = manager.getResourcesToRefresh(fProject, config2).toArray(new IResource[0]);
+ assertEquals(config2_resources.length,2);
+ assertEquals(fFolder1, config2_resources[1]);
+
+ // TEST 3:
+ // first try deleting a resource that was never added... folder5
+ manager.deleteResourceToRefresh(fProject, config1, fFolder5);
+ IResource[] config1_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resourcesAfterDelete.length, 3);
+ assertEquals(fFolder2, config1_resources[0]);
+ assertEquals(fFolder1, config1_resources[2]);
+ // ditto for config2, but this time we did add the resource, to make sure fFolder1 wasn't added.
+ manager.deleteResourceToRefresh(fProject, config2, fFolder5);
+ IResource[] config2_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config2).toArray(new IResource[0]);
+ assertEquals(config2_resourcesAfterDelete.length, 2);
+
+ // TEST 4:
// now delete the resources from the manager one by one
- manager.deleteResourceToRefresh(fProject, resources[1]);
- resourcesAfterDelete = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resourcesAfterDelete.length, 1);
- assertEquals(resourcesAfterDelete[0], resources[0]);
-
- manager.deleteResourceToRefresh(fProject, resources[0]);
- resourcesAfterDelete = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resourcesAfterDelete.length, 0);
-
+ manager.deleteResourceToRefresh(fProject, config1, config1_resources[2]);
+ config1_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resourcesAfterDelete.length, 2);
+ assertEquals(config1_resourcesAfterDelete[1], config1_resources[1]);
+
+ manager.deleteResourceToRefresh(fProject, config1, config1_resources[0]);
+ config1_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resourcesAfterDelete.length, 1);
+
+ // and ditto for config2
+ manager.deleteResourceToRefresh(fProject, config2, config2_resources[0]);
+ config2_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config2).toArray(new IResource[0]);
+ assertEquals(config2_resourcesAfterDelete.length, 1);
}
- public void testSetResourcesToRefresh() {
+
+ public void testSetResourcesToExclusionsMapRefresh() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
- List<IResource> resources = new LinkedList<IResource>();
- resources.add(fFolder1);
- resources.add(fFolder2);
- manager.setResourcesToRefresh(fProject, resources);
+ HashMap<IResource, List<RefreshExclusion>> config1_resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
+ config1_resourceMap.put(fFolder1,new LinkedList<RefreshExclusion>());
+ config1_resourceMap.put(fFolder2,new LinkedList<RefreshExclusion>());
+ manager.setResourcesToExclusionsMap(fProject, config1, config1_resourceMap);
- IResource[] resourcesAfterSet = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
- assertEquals(resourcesAfterSet.length, 2);
- assertEquals(fFolder1, resourcesAfterSet[0]);
- assertEquals(fFolder2, resourcesAfterSet[1]);
+ IResource[] config1_resourcesAfterSet = manager.getResourcesToRefresh(fProject, config1).toArray(new IResource[0]);
+ assertEquals(config1_resourcesAfterSet.length, 2);
+ assertEquals(fFolder2, config1_resourcesAfterSet[0]);
+ assertEquals(fFolder1, config1_resourcesAfterSet[1]);
manager.clearResourcesToRefresh(fProject);
@@ -182,28 +211,31 @@ public class RefreshScopeTests extends TestCase {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
- manager.addResourceToRefresh(fProject, fProject);
- RefreshExclusion exclusion1 = new TestExclusion();
- manager.addExclusion(fProject, exclusion1);
- RefreshExclusion exclusion2 = new TestExclusion();
- manager.addExclusion(fProject, exclusion2);
+ IResource config1_resource = fProject;
+
+
+ manager.addResourceToRefresh(fProject, config1, config1_resource);
+ RefreshExclusion config1_exclusion1 = new TestExclusion();
+ manager.addExclusion(fProject, config1, config1_resource, config1_exclusion1);
+ RefreshExclusion config1_exclusion2 = new TestExclusion();
+ manager.addExclusion(fProject, config1, config1_resource, config1_exclusion2);
// make sure the exclusions are there
- List<RefreshExclusion> exclusionsList = manager.getExclusions(fProject);
+ List<RefreshExclusion> exclusionsList = manager.getExclusions(fProject, config1, config1_resource);
RefreshExclusion[] exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 2);
- assertEquals(exclusionsArray[0], exclusion1);
- assertEquals(exclusionsArray[1], exclusion2);
+ assertEquals(exclusionsArray[0], config1_exclusion1);
+ assertEquals(exclusionsArray[1], config1_exclusion2);
// remove the exclusions one by one
- manager.removeExclusion(fProject, exclusion2);
- exclusionsList = manager.getExclusions(fProject);
+ manager.removeExclusion(fProject, config1, config1_resource, config1_exclusion2);
+ exclusionsList = manager.getExclusions(fProject,config1,config1_resource);
exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 1);
- assertEquals(exclusionsArray[0], exclusion1);
+ assertEquals(exclusionsArray[0], config1_exclusion1);
- manager.removeExclusion(fProject, exclusion1);
- exclusionsList = manager.getExclusions(fProject);
+ manager.removeExclusion(fProject, config1, config1_resource, config1_exclusion1);
+ exclusionsList = manager.getExclusions(fProject, config1,config1_resource);
exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 0);
@@ -213,24 +245,46 @@ public class RefreshScopeTests extends TestCase {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
- manager.addResourceToRefresh(fProject, fProject);
+ IResource config1_resource = fProject;
+ IResource config2_resource = fFolder1;
+
+ //add a resource and two exclusions for config1.
+ manager.addResourceToRefresh(fProject, config1, config1_resource);
+ RefreshExclusion config1_exclusion1 = new TestExclusion();
+ manager.addExclusion(fProject, config1, config1_resource, config1_exclusion1);
+ RefreshExclusion config1_exclusion2 = new TestExclusion();
+ manager.addExclusion(fProject, config1, config1_resource, config1_exclusion2);
- RefreshExclusion exclusion1 = new TestExclusion();
- manager.addExclusion(fProject, exclusion1);
- RefreshExclusion exclusion2 = new TestExclusion();
- manager.addExclusion(fProject, exclusion2);
+ // add a nested exclusion to the first exclusion
+ RefreshExclusion config1_exclusion3 = new TestExclusion();
+ config1_exclusion1.addNestedExclusion(config1_exclusion3);
+
+ // add an instance to the second exclusion
+ ExclusionInstance config1_instance = new ExclusionInstance();
+ config1_instance.setDisplayString("foo");
+ config1_instance.setResource(fFolder2);
+ config1_instance.setExclusionType(ExclusionType.RESOURCE);
+ config1_instance.setParentExclusion(config1_exclusion2);
+ config1_exclusion2.addExclusionInstance(config1_instance);
+
+ //add a resource and two exclusions for config2.
+ manager.addResourceToRefresh(fProject, config2, config2_resource);
+ RefreshExclusion config2_exclusion1 = new TestExclusion();
+ manager.addExclusion(fProject, config2, config2_resource, config2_exclusion1);
+ RefreshExclusion config2_exclusion2 = new TestExclusion();
+ manager.addExclusion(fProject, config2, config2_resource, config2_exclusion2);
// add a nested exclusion to the first exclusion
- RefreshExclusion exclusion3 = new TestExclusion();
- exclusion1.addNestedExclusion(exclusion3);
+ RefreshExclusion config2_exclusion3 = new TestExclusion();
+ config2_exclusion1.addNestedExclusion(config2_exclusion3);
// add an instance to the second exclusion
- ExclusionInstance instance = new ExclusionInstance();
- instance.setDisplayString("foo");
- instance.setResource(fFolder2);
- instance.setExclusionType(ExclusionType.RESOURCE);
- instance.setParentExclusion(exclusion2);
- exclusion2.addExclusionInstance(instance);
+ ExclusionInstance config2_instance = new ExclusionInstance();
+ config2_instance.setDisplayString("foo");
+ config2_instance.setResource(fFolder2);
+ config2_instance.setExclusionType(ExclusionType.RESOURCE);
+ config2_instance.setParentExclusion(config2_exclusion2);
+ config2_exclusion2.addExclusionInstance(config1_instance);
ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject, true);
@@ -251,53 +305,96 @@ public class RefreshScopeTests extends TestCase {
fail();
}
- // make sure we got the same stuff we saved
+ // make sure we got the same stuff we saved for config1
+
+ // the project should be set to refresh its root
+ List<IResource> config1_resources = manager.getResourcesToRefresh(fProject,config1);
+ assertEquals(config1_resources.size(), 1);
+ assertEquals(config1_resources.toArray(new IResource[0])[0], config1_resource);
+
+ // there should be 2 top-level exclusions
+ List<RefreshExclusion> config1_exclusions = manager.getExclusions(fProject, config1,config1_resource);
+ assertEquals(2, config1_exclusions.size());
+ RefreshExclusion[] config1_exclusionsArray = config1_exclusions.toArray(new RefreshExclusion[0]);
+
+ // both exclusions should have parent resource set to the project
+ assertEquals(config1_resource, config1_exclusionsArray[0].getParentResource());
+ assertEquals(config1_resource, config1_exclusionsArray[1].getParentResource());
+ // the first exclusion should have one nested exclusion
+ List<RefreshExclusion> config1_nestedExclusions1 = config1_exclusionsArray[0].getNestedExclusions();
+ assertEquals(config1_nestedExclusions1.size(), 1);
+ RefreshExclusion[] config1_nestedExclusionsArray = config1_nestedExclusions1.toArray(new RefreshExclusion[0]);
+ // the nested exclusion should have its parent exclusion set properly
+ assertEquals(config1_nestedExclusionsArray[0].getParentExclusion(), config1_exclusionsArray[0]);
+
+ // the second exclusion should have no nested exclusions
+ List<RefreshExclusion> config1_nestedExclusions2 = config1_exclusionsArray[1].getNestedExclusions();
+ assertEquals(config1_nestedExclusions2.size(), 0);
+
+ // the second exclusion should have an instance
+ List<ExclusionInstance> config1_instances = config1_exclusionsArray[1].getExclusionInstances();
+ assertEquals(1, config1_instances.size());
+ ExclusionInstance[] config1_instancesArray = config1_instances.toArray(new ExclusionInstance[0]);
+ ExclusionInstance config1_loadedInstance = config1_instancesArray[0];
+
+ // check the contents of the instance
+ assertEquals("foo", config1_loadedInstance.getDisplayString());
+ assertEquals(fFolder2, config1_loadedInstance.getResource());
+ assertEquals(ExclusionType.RESOURCE, config1_loadedInstance.getExclusionType());
+
+ // clear data for config1
+ manager.deleteResourceToRefresh(fProject, config1, config1_resource);
+
+ // make sure we got the same stuff we saved for config2
// the project should be set to refresh its root
- List<IResource> resources = manager.getResourcesToRefresh(fProject);
- assertEquals(resources.size(), 1);
- assertEquals(resources.toArray(new IResource[0])[0], fProject);
+ List<IResource> config2_resources = manager.getResourcesToRefresh(fProject,config2);
+ assertEquals(config2_resources.size(), 2);
+ assertEquals(config2_resources.toArray(new IResource[0])[1], config2_resource);
// there should be 2 top-level exclusions
- List<RefreshExclusion> exclusions = manager.getExclusions(fProject);
- assertEquals(2, exclusions.size());
- RefreshExclusion[] exclusionsArray = exclusions.toArray(new RefreshExclusion[0]);
+ List<RefreshExclusion> config2_exclusions = manager.getExclusions(fProject,config2,config2_resource);
+ assertEquals(2, config2_exclusions.size());
+ RefreshExclusion[] config2_exclusionsArray = config2_exclusions.toArray(new RefreshExclusion[0]);
// both exclusions should have parent resource set to the project
- assertEquals(fProject, exclusionsArray[0].getParentResource());
- assertEquals(fProject, exclusionsArray[1].getParentResource());
+ assertEquals(config2_resource, config2_exclusionsArray[0].getParentResource());
+ assertEquals(config2_resource, config2_exclusionsArray[1].getParentResource());
// the first exclusion should have one nested exclusion
- List<RefreshExclusion> nestedExclusions1 = exclusionsArray[0].getNestedExclusions();
- assertEquals(nestedExclusions1.size(), 1);
- RefreshExclusion[] nestedExclusionsArray = nestedExclusions1.toArray(new RefreshExclusion[0]);
+ List<RefreshExclusion> config2_nestedExclusions1 = config2_exclusionsArray[0].getNestedExclusions();
+ assertEquals(config2_nestedExclusions1.size(), 1);
+ RefreshExclusion[] config2_nestedExclusionsArray = config2_nestedExclusions1.toArray(new RefreshExclusion[0]);
// the nested exclusion should have its parent exclusion set properly
- assertEquals(nestedExclusionsArray[0].getParentExclusion(), exclusionsArray[0]);
+ assertEquals(config2_nestedExclusionsArray[0].getParentExclusion(), config2_exclusionsArray[0]);
// the second exclusion should have no nested exclusions
- List<RefreshExclusion> nestedExclusions2 = exclusionsArray[1].getNestedExclusions();
- assertEquals(nestedExclusions2.size(), 0);
+ List<RefreshExclusion> config2_nestedExclusions2 = config2_exclusionsArray[1].getNestedExclusions();
+ assertEquals(config2_nestedExclusions2.size(), 0);
// the second exclusion should have an instance
- List<ExclusionInstance> instances = exclusionsArray[1].getExclusionInstances();
- assertEquals(1, instances.size());
- ExclusionInstance[] instancesArray = instances.toArray(new ExclusionInstance[0]);
- ExclusionInstance loadedInstance = instancesArray[0];
+ List<ExclusionInstance> config2_instances = config2_exclusionsArray[1].getExclusionInstances();
+ assertEquals(1, config2_instances.size());
+ ExclusionInstance[] config2_instancesArray = config2_instances.toArray(new ExclusionInstance[0]);
+ ExclusionInstance config2_loadedInstance = config2_instancesArray[0];
// check the contents of the instance
- assertEquals("foo", loadedInstance.getDisplayString());
- assertEquals(fFolder2, loadedInstance.getResource());
- assertEquals(ExclusionType.RESOURCE, loadedInstance.getExclusionType());
+ assertEquals("foo", config2_loadedInstance.getDisplayString());
+ assertEquals(fFolder2, config2_loadedInstance.getResource());
+ assertEquals(ExclusionType.RESOURCE, config2_loadedInstance.getExclusionType());
// cleanup
manager.clearAllData();
}
+
public void testResourceExclusion() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
- manager.addResourceToRefresh(fProject, fProject);
+ IResource config1_resource = fProject;
+
+ manager.addResourceToRefresh(fProject, config1, config1_resource);
// create a series of nested exclusions that include/exclude certain folders
// will be included/excluded as follows
@@ -319,7 +416,7 @@ public class RefreshScopeTests extends TestCase {
ExclusionInstance instance2 = new ExclusionInstance();
instance2.setResource(fFolder2);
exclusion1.addExclusionInstance(instance2);
- manager.addExclusion(fProject, exclusion1);
+ manager.addExclusion(fProject, config1, config1_resource, exclusion1);
ResourceExclusion exclusion2 = new ResourceExclusion();
ExclusionInstance instance3 = new ExclusionInstance();
@@ -335,13 +432,13 @@ public class RefreshScopeTests extends TestCase {
// now check and see if the right folders are included/excluded
- assertEquals(true, manager.shouldResourceBeRefreshed(fProject));
- assertEquals(false, manager.shouldResourceBeRefreshed(fFolder1));
- assertEquals(false, manager.shouldResourceBeRefreshed(fFolder2));
- assertEquals(true, manager.shouldResourceBeRefreshed(fFolder3));
- assertEquals(false, manager.shouldResourceBeRefreshed(fFolder4));
- assertEquals(true, manager.shouldResourceBeRefreshed(fFolder5));
- assertEquals(false, manager.shouldResourceBeRefreshed(fFolder6));
+ assertEquals(true, manager.shouldResourceBeRefreshed(config1, config1_resource));
+ assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder1));
+ assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder2));
+ assertEquals(true, manager.shouldResourceBeRefreshed(config1, fFolder3));
+ assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder4));
+ assertEquals(true, manager.shouldResourceBeRefreshed(config1, fFolder5));
+ assertEquals(false, manager.shouldResourceBeRefreshed(config1, fFolder6));
// now let's create a bunch of files in these directories using java.io.File (so that we don't get
// resource deltas happening), and refresh the project according to the policy. We should only see the files
@@ -412,13 +509,13 @@ public class RefreshScopeTests extends TestCase {
manager.clearAllData();
// by default, a project should refresh its root
- List<IResource> resourcesToRefresh = manager.getResourcesToRefresh(fProject);
+ List<IResource> resourcesToRefresh = manager.getResourcesToRefresh(fProject, config1);
assertEquals(1, resourcesToRefresh.size());
IResource[] resourceArray = resourcesToRefresh.toArray(new IResource[0]);
assertEquals(fProject, resourceArray[0]);
// there should be no exclusions
- List<RefreshExclusion> exclusions = manager.getExclusions(fProject);
+ List<RefreshExclusion> exclusions = manager.getExclusions(fProject, config1, fProject);
assertEquals(0, exclusions.size());
ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject);
@@ -440,12 +537,12 @@ public class RefreshScopeTests extends TestCase {
// test the defaults again
// by default, a project should refresh its root
- resourcesToRefresh = manager.getResourcesToRefresh(fProject);
+ resourcesToRefresh = manager.getResourcesToRefresh(fProject, config1);
assertEquals(1, resourcesToRefresh.size());
resourceArray = resourcesToRefresh.toArray(new IResource[0]);
assertEquals(fProject, resourceArray[0]);
// there should be no exclusions
- exclusions = manager.getExclusions(fProject);
+ exclusions = manager.getExclusions(fProject, config1, fProject);
assertEquals(0, exclusions.size());
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
index 79a5ad5c83f..50505af5b51 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,4 +31,11 @@ public class TestExclusion extends RefreshExclusion {
public boolean supportsExclusionInstances() {
return false;
}
+
+ @Override
+ public Object clone() {
+ TestExclusion clone = new TestExclusion();
+ copyTo(clone);
+ return clone;
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
index 4b4e7361183..696dae3fbf2 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
@@ -35,6 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.TestCfgDataProvider;
+import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -629,24 +630,7 @@ public class ResourceHelper {
* @throws IOException on IO problem.
*/
public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
- if (!Platform.getOS().equals(Platform.OS_WIN32)) {
- // Don't run this on non-windows platforms
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable.");
- }
- String[] args = {"cygpath", "-u", windowsPath};
- Process cygpath;
- try {
- cygpath = Runtime.getRuntime().exec(args);
- } catch (IOException ioe) {
- throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path.");
- }
- BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream()));
-
- String cygwinPath = stdout.readLine();
- if (cygwinPath == null) {
- throw new UnsupportedOperationException("Cygwin utility cygpath is not available.");
- }
- return cygwinPath.trim();
+ return Cygwin.windowsToCygwinPath(windowsPath);
}
/**
@@ -658,24 +642,7 @@ public class ResourceHelper {
* @throws IOException on IO problem.
*/
public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException {
- if (!Platform.getOS().equals(Platform.OS_WIN32)) {
- // Don't run this on non-windows platforms
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable.");
- }
- String[] args = {"cygpath", "-w", cygwinPath};
- Process cygpath;
- try {
- cygpath = Runtime.getRuntime().exec(args);
- } catch (IOException ioe) {
- throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path.");
- }
- BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream()));
-
- String windowsPath = stdout.readLine();
- if (windowsPath == null) {
- throw new UnsupportedOperationException("Cygwin utility cygpath is not available.");
- }
- return windowsPath.trim();
+ return Cygwin.cygwinToWindowsPath(cygwinPath);
}
/**

Back to the top