~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2005, 2007 Intel Corporation and others.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 * Intel Corporation - Initial API and implementation
10
 
 *******************************************************************************/
11
 
 
12
 
/**********************************************************************
13
 
 * These tests are for a 3.0 style tool integration.
14
 
 **********************************************************************/
15
 
 
16
 
package org.eclipse.cdt.managedbuilder.core.tests;
17
 
 
18
 
import java.io.File;
19
 
import java.io.FileFilter;
20
 
import java.util.ArrayList;
21
 
import java.util.Iterator;
22
 
 
23
 
import junit.framework.Test;
24
 
import junit.framework.TestCase;
25
 
import junit.framework.TestSuite;
26
 
 
27
 
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
28
 
import org.eclipse.cdt.managedbuilder.core.IInputType;
29
 
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
30
 
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
31
 
import org.eclipse.cdt.managedbuilder.core.IOutputType;
32
 
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
33
 
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
34
 
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
35
 
import org.eclipse.cdt.managedbuilder.core.ITool;
36
 
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
37
 
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
38
 
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
39
 
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
40
 
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
41
 
import org.eclipse.core.resources.*;
42
 
import org.eclipse.core.runtime.CoreException;
43
 
import org.eclipse.core.runtime.IPath;
44
 
import org.eclipse.core.runtime.IProgressMonitor;
45
 
import org.eclipse.core.runtime.NullProgressMonitor;
46
 
import org.eclipse.core.runtime.OperationCanceledException;
47
 
import org.eclipse.core.runtime.Path;
48
 
import org.eclipse.ui.dialogs.IOverwriteQuery;
49
 
 
50
 
public class ManagedProject30MakefileTests extends TestCase {
51
 
        public static final String MBS_TEMP_DIR = "MBSTemp";
52
 
 
53
 
        static boolean pathVariableCreated = false;
54
 
        
55
 
        public ManagedProject30MakefileTests(String name) {
56
 
                super(name);
57
 
        }
58
 
        
59
 
        public static Test suite() {
60
 
                TestSuite suite = new TestSuite(ManagedProject30MakefileTests.class.getName());
61
 
                
62
 
                suite.addTest(new ManagedProject30MakefileTests("test30SingleFileExe"));
63
 
                suite.addTest(new ManagedProject30MakefileTests("test30TwoFileSO"));
64
 
                suite.addTest(new ManagedProject30MakefileTests("test30MultiResConfig"));
65
 
                suite.addTest(new ManagedProject30MakefileTests("test30LinkedLib"));
66
 
                //  TODO: testLinkedFolder fails intermittently saying that it cannot find
67
 
                //        the makefiles to compare.  This appears to be a test set issue,
68
 
                //        rather than an MBS functionality issue
69
 
                //suite.addTest(new ManagedProject30MakefileTests("test30LinkedFolder"));
70
 
                suite.addTest(new ManagedProject30MakefileTests("test30CopyandDeploy"));
71
 
                suite.addTest(new ManagedProject30MakefileTests("test30DeleteFile"));
72
 
                suite.addTest(new ManagedProject30MakefileTests("test30NoFilesToBuild"));
73
 
                suite.addTest(new ManagedProject30MakefileTests("testFileWithNoExtension"));
74
 
                suite.addTest(new ManagedProject30MakefileTests("testPreAndPostProcessBuildSteps"));
75
 
                suite.addTest(new ManagedProject30MakefileTests("testResourceCustomBuildStep"));
76
 
                suite.addTest(new ManagedProject30MakefileTests("test30_1"));
77
 
                suite.addTest(new ManagedProject30MakefileTests("test30_2"));
78
 
                suite.addTest(new ManagedProject30MakefileTests("testTopTC"));
79
 
                suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest1"));
80
 
                suite.addTest(new ManagedProject30MakefileTests("CDTFortranTest2"));
81
 
                suite.addTest(new ManagedProject30MakefileTests("TestATO"));
82
 
                suite.addTest(new ManagedProject30MakefileTests("testMacroSupportInBuildDefinitions"));
83
 
                suite.addTest(new ManagedProject30MakefileTests("testSpaces"));
84
 
                if(File.separatorChar == '\\'){
85
 
                        //the test is valid for windows because it is using windows-specific paths with devices and assumes they are absolute
86
 
                        //FIXME: make the test run on linux
87
 
                        suite.addTest(new ManagedProject30MakefileTests("testInputTypeOption"));
88
 
                }
89
 
                return suite;
90
 
        }
91
 
 
92
 
        private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
93
 
                ArrayList projectList = null;
94
 
                if (containsZip) {
95
 
                        File testDir = CTestPlugin.getFileInPlugin(new Path("resources/test30Projects/" + projName));
96
 
                        if(testDir == null) {
97
 
                                fail("Test project directory " + projName + " is missing.");
98
 
                                return null;
99
 
                        }
100
 
 
101
 
                        File projectZips[] = testDir.listFiles(new FileFilter(){
102
 
                                public boolean accept(File pathname){
103
 
                                        if(pathname.isDirectory())
104
 
                                                return false;
105
 
                                        return true;
106
 
                                }
107
 
                        });
108
 
                        
109
 
                        projectList = new ArrayList(projectZips.length);
110
 
                        for(int i = 0; i < projectZips.length; i++){
111
 
                                try{
112
 
                                        String projectName = projectZips[i].getName();
113
 
                                        if(!projectName.endsWith(".zip"))
114
 
                                                continue;
115
 
                                        
116
 
                                        projectName = projectName.substring(0,projectName.length()-".zip".length());
117
 
                                        if(projectName.length() == 0)
118
 
                                                continue;
119
 
                                        IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
120
 
                                        if(project != null)
121
 
                                                projectList.add(project);
122
 
                                }
123
 
                                catch(Exception e){
124
 
                                }
125
 
                        }
126
 
                        if(projectList.size() == 0) {
127
 
                                fail("No projects found in test project directory " + testDir.getName() + ".  The .zip file may be missing or corrupt.");
128
 
                                return null;
129
 
                        }
130
 
                } else {
131
 
                        try{
132
 
                                IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
133
 
                                if(project != null)
134
 
                                        projectList = new ArrayList(1);
135
 
                                        projectList.add(project);
136
 
                        } catch(Exception e){}
137
 
                }
138
 
                
139
 
                return (IProject[])projectList.toArray(new IProject[projectList.size()]);
140
 
        }
141
 
        
142
 
        private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
143
 
                
144
 
                //  In case the projects need to be updated...
145
 
                IOverwriteQuery queryALL = new IOverwriteQuery(){
146
 
                        public String queryOverwrite(String file) {
147
 
                                return ALL;
148
 
                        }};
149
 
                IOverwriteQuery queryNOALL = new IOverwriteQuery(){
150
 
                        public String queryOverwrite(String file) {
151
 
                                return NO_ALL;
152
 
                        }};
153
 
                
154
 
                UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
155
 
                UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
156
 
                
157
 
                IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
158
 
                return projects;
159
 
        }
160
 
                
161
 
        private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {        
162
 
                if(projects == null || projects.length == 0)
163
 
                        return;
164
 
                                
165
 
                boolean succeeded = true;
166
 
                for (int i = 0; i < projects.length; i++){
167
 
                        IProject curProject = projects[i];
168
 
                        
169
 
                        IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
170
 
                        
171
 
                        //check whether the managed build info is converted
172
 
                        boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
173
 
                        assertTrue(isCompatible);
174
 
                        
175
 
                        if (isCompatible){
176
 
                                // Build the project in order to generate the makefiles 
177
 
                                try{
178
 
                                        curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
179
 
                                }
180
 
                                catch(CoreException e){
181
 
                                        fail(e.getStatus().getMessage());
182
 
                                }
183
 
                                catch(OperationCanceledException e){
184
 
                                        fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
185
 
                                }
186
 
                                
187
 
                                //compare the generated makefiles to their benchmarks
188
 
                                if (files != null && files.length > 0) {
189
 
                                        if (i == 0) {
190
 
                                                String configName = info.getDefaultConfiguration().getName();
191
 
                                                IPath buildDir = Path.fromOSString(configName);
192
 
                                                if (compareBenchmark)
193
 
                                                    succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
194
 
                                                else
195
 
                                                        succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
196
 
                                        }
197
 
                                }
198
 
                        }
199
 
                }
200
 
                
201
 
                if (succeeded) {        //  Otherwise leave the projects around for comparison
202
 
                        for (int i = 0; i < projects.length; i++)
203
 
                                ManagedBuildTestHelper.removeProject(projects[i].getName());
204
 
                }
205
 
        }
206
 
 
207
 
        // Build projects and compare benchmarks
208
 
        private void buildProjects(IProject projects[], IPath[] files) {
209
 
                buildProjectsWorker(projects, files, true);
210
 
        }
211
 
        
212
 
        // Build projects but don't compare benchmarks because there should be not build files generated
213
 
        private void buildDegenerativeProjects(IProject projects[], IPath[] files) {    
214
 
                buildProjectsWorker(projects, files, false);
215
 
        }
216
 
                
217
 
        private void createPathVariable(IPath tmpDir) {
218
 
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
219
 
                workspace = ResourcesPlugin.getWorkspace();
220
 
                IPathVariableManager pathMan = workspace.getPathVariableManager();
221
 
                String name = MBS_TEMP_DIR;
222
 
                try {
223
 
                        if (pathMan.validateName(name).isOK() && pathMan.validateValue(tmpDir).isOK()) {
224
 
                            pathMan.setValue(name, tmpDir);
225
 
                                assertTrue(pathMan.isDefined(name));
226
 
                        } else {
227
 
                                fail("could not create the path variable " + name);
228
 
                        }
229
 
                } catch (Exception e) {fail("could not create the path variable " + name);}
230
 
        }
231
 
        
232
 
        private void createFileLink(IProject project, IPath tmpDir, String linkName, String fileName) {
233
 
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
234
 
                String name = MBS_TEMP_DIR;
235
 
                if (!pathVariableCreated) {
236
 
                        createPathVariable(tmpDir);
237
 
                        pathVariableCreated = true;
238
 
                }
239
 
                        
240
 
                try {   
241
 
                        // Now we can create a linked resource relative to the defined path variable: 
242
 
                        IFile linkF1 = project.getFile(linkName);
243
 
                        IPath location = new Path("MBSTemp/" + fileName);
244
 
                        if (workspace.validateLinkLocation(linkF1, location).isOK()) {
245
 
                            linkF1.createLink(location, IResource.NONE, null);
246
 
                        } else {
247
 
                                fail("could not create the link to " + name);
248
 
                        }
249
 
                } catch (Exception e) {fail("could not create the link to " + name);}           
250
 
        }
251
 
        
252
 
        /* (non-Javadoc)
253
 
         * tests 3.0 style tool integration for a single file executable
254
 
         */
255
 
        public void test30SingleFileExe(){
256
 
                IPath[] makefiles = {
257
 
                                 Path.fromOSString("makefile"), 
258
 
                                 Path.fromOSString("objects.mk"), 
259
 
                                 Path.fromOSString("sources.mk"), 
260
 
                                 Path.fromOSString("subdir.mk")};
261
 
                IProject[] projects = createProjects("singleFileExe", null, null, true);
262
 
                buildProjects(projects, makefiles);
263
 
        }
264
 
        
265
 
        /* (non-Javadoc)
266
 
         * tests 3.0 style tool integration for a two file SO
267
 
         */
268
 
        public void test30TwoFileSO(){
269
 
                IPath[] makefiles = {
270
 
                                 Path.fromOSString("makefile"), 
271
 
                                 Path.fromOSString("objects.mk"), 
272
 
                                 Path.fromOSString("sources.mk"), 
273
 
                                 Path.fromOSString("subdir.mk")};
274
 
                IProject[] projects = createProjects("twoFileSO", null, null, true);
275
 
                buildProjects(projects, makefiles);
276
 
        }
277
 
 
278
 
        /* (non-Javadoc)
279
 
         * tests 3.0 style tool integration for multiple source files & a resource configuration
280
 
         */
281
 
        public void test30MultiResConfig(){
282
 
                IPath[] makefiles = {
283
 
                                 Path.fromOSString("makefile"), 
284
 
                                 Path.fromOSString("objects.mk"), 
285
 
                                 Path.fromOSString("sources.mk"), 
286
 
                                 Path.fromOSString("subdir.mk"),
287
 
                                 Path.fromOSString("main.d"),
288
 
                                 Path.fromOSString("source1/subdir.mk"),
289
 
                                 Path.fromOSString("source1/Class1.d"),
290
 
                                 Path.fromOSString("source2/subdir.mk"),
291
 
                                 Path.fromOSString("source2/Class2.d"),
292
 
                                 Path.fromOSString("source2/source21/Class21.d"),
293
 
                                 Path.fromOSString("source2/source21/subdir.mk")};
294
 
                IProject[] projects = createProjects("multiResConfig", null, null, true);
295
 
                buildProjects(projects, makefiles);
296
 
        }
297
 
        
298
 
        /* (non-Javadoc)
299
 
         * tests 3.0 style tool integration for linked files
300
 
         */
301
 
        public void test30LinkedLib(){
302
 
                IPath[] makefiles = {
303
 
                                 Path.fromOSString("makefile"), 
304
 
                                 Path.fromOSString("objects.mk"), 
305
 
                                 //Path.fromOSString("subdir.mk")   // Can't compare this yet since it contains absolute paths!
306
 
                                 Path.fromOSString("sources.mk")}; 
307
 
                IPath[] linkedFiles = {
308
 
                                 Path.fromOSString("f1_30.c"), 
309
 
                                 Path.fromOSString("f2_30.c"), 
310
 
                                 Path.fromOSString("test_ar_30.h")};
311
 
                File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test30Projects/linkedLib30/"));
312
 
                IPath srcDir = Path.fromOSString(srcDirFile.toString());
313
 
                IPath tmpSubDir = Path.fromOSString("CDTMBSTest");
314
 
                IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles);
315
 
                try {
316
 
                        IProject[] projects = createProjects("linkedLib30", null, "cdt.managedbuild.target.gnu30.lib", true);
317
 
                        //  There should be only one project.  Add our linked files to it.
318
 
                        IProject project = projects[0];
319
 
                        createFileLink(project, tmpDir, "f1_30.c", "f1_30.c");
320
 
                        createFileLink(project, tmpDir, "f2link_30.c", "f2_30.c");
321
 
                        createFileLink(project, tmpDir, "test_ar_30.h", "test_ar_30.h");
322
 
                        //  Build the project
323
 
                        buildProjects(projects, makefiles);
324
 
                } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);}
325
 
        }
326
 
        
327
 
        /* (non-Javadoc)
328
 
         * tests 3.0 style tool integration for a linked folder
329
 
         */
330
 
        public void test30LinkedFolder(){
331
 
                IPath[] makefiles = {
332
 
                                 Path.fromOSString("makefile"), 
333
 
                                 Path.fromOSString("objects.mk"), 
334
 
                                 Path.fromOSString("subdir.mk"),
335
 
                                 Path.fromOSString("sources.mk")}; 
336
 
                IPath[] linkedFiles = {
337
 
                                 Path.fromOSString("f1.c"), 
338
 
                                 Path.fromOSString("f2.c"), 
339
 
                                 Path.fromOSString("test_ar.h"),
340
 
                                 Path.fromOSString("Benchmarks/makefile"), 
341
 
                                 Path.fromOSString("Benchmarks/objects.mk"), 
342
 
                                 Path.fromOSString("Benchmarks/subdir.mk"),
343
 
                                 Path.fromOSString("Benchmarks/sources.mk")}; 
344
 
                File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test30Projects/linkedFolder/"));
345
 
                IPath srcDir = Path.fromOSString(srcDirFile.toString());
346
 
                IPath tmpSubDir = Path.fromOSString("CDTMBSTest");
347
 
                IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles);
348
 
                if (!pathVariableCreated) {
349
 
                        createPathVariable(tmpDir);
350
 
                        pathVariableCreated = true;
351
 
                }
352
 
                try {
353
 
                        IPath location = Path.fromOSString(MBS_TEMP_DIR);
354
 
                        IProject[] projects = createProjects("linkedFolder", location, "cdt.managedbuild.target.gnu30.lib", false);
355
 
                        //  Build the project
356
 
                        buildProjects(projects, makefiles);
357
 
                } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);}
358
 
        }
359
 
 
360
 
        /* (non-Javadoc)
361
 
         * tests 3.0 style tool integration with pre and post process steps added to typical compile & link
362
 
         */
363
 
        public void test30CopyandDeploy(){
364
 
                IPath[] makefiles = {
365
 
                                 Path.fromOSString("makefile"), 
366
 
                                 Path.fromOSString("objects.mk"), 
367
 
                                 Path.fromOSString("sources.mk"), 
368
 
                                 Path.fromOSString("subdir.mk"), 
369
 
                                 Path.fromOSString("main.d"), 
370
 
                                 Path.fromOSString("Functions/subdir.mk"),
371
 
                                 Path.fromOSString("Functions/Func1.d")};
372
 
                IProject[] projects = createProjects("copyandDeploy", null, null, true);
373
 
                buildProjects(projects, makefiles);
374
 
        }
375
 
        
376
 
        /* (non-Javadoc)
377
 
         * tests 3.0 style tool integration in the context of deleting a file, to see if the proper behavior
378
 
         * occurs in the managedbuild system
379
 
         */
380
 
        public void test30DeleteFile(){
381
 
                IPath[] makefiles = {
382
 
                                 Path.fromOSString("makefile"), 
383
 
                                 Path.fromOSString("objects.mk"), 
384
 
                                 Path.fromOSString("subdir.mk"),
385
 
                                 Path.fromOSString("sources.mk")};              
386
 
 
387
 
                IProject[] projects = createProjects("deleteFile", null, null, true);
388
 
                final IWorkspace workspace = ResourcesPlugin.getWorkspace();
389
 
                ArrayList resourceList = new ArrayList(1);
390
 
                IProject project = projects[0];
391
 
                IFile projfile = project.getFile("filetobedeleted.cxx");
392
 
                resourceList.add(projfile);
393
 
                final IResource[] fileResource = (IResource[])resourceList.toArray(new IResource[resourceList.size()]);
394
 
                IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
395
 
                        public void run(IProgressMonitor monitor) throws CoreException {
396
 
                            workspace.delete(fileResource, false, null);
397
 
                        }
398
 
                };
399
 
                try {
400
 
                        NullProgressMonitor monitor = new NullProgressMonitor();
401
 
                        workspace.run(runnable, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
402
 
                } catch (Exception e) { 
403
 
                    fail("could not delete file in project " + project.getName());
404
 
                }
405
 
                buildProjects(projects, makefiles);
406
 
        }
407
 
 
408
 
        /* (non-Javadoc)
409
 
         * tests 3.0 managed build system with a project which has only a single source file that is marked as 
410
 
         * "excluded from build" to see that this degenerative case is handled gracefully
411
 
         */
412
 
        public void test30NoFilesToBuild(){
413
 
                IPath[] makefiles = {
414
 
                                 Path.fromOSString("makefile"), 
415
 
                                 Path.fromOSString("objects.mk"), 
416
 
                                 Path.fromOSString("subdir.mk"),
417
 
                                 Path.fromOSString("sources.mk")};              
418
 
 
419
 
                IProject[] projects = createProjects("noFilesToBuild", null, null, true);
420
 
                IProject project = projects[0];
421
 
                IFile projfile = project.getFile("filetobeexcluded.cxx");
422
 
                IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
423
 
                IConfiguration config = info.getDefaultConfiguration();
424
 
                IResourceConfiguration rconfig = config.createResourceConfiguration(projfile);
425
 
                rconfig.setExclude(true);
426
 
                buildDegenerativeProjects(projects, makefiles);                 
427
 
        }
428
 
 
429
 
        /**
430
 
         * (non-Javadoc)
431
 
         * tests 3.0 managed build system with a project which has a file with no file extesnion
432
 
         */
433
 
        public void testFileWithNoExtension()
434
 
        {
435
 
                IPath[] makefiles = {
436
 
                                 Path.fromOSString("makefile"), 
437
 
                                 Path.fromOSString("objects.mk"), 
438
 
                                 Path.fromOSString("sources.mk"), 
439
 
                                 Path.fromOSString("subdir.mk")};
440
 
                IProject[] projects = createProjects("testFileWithNoExtension", null, null, true);
441
 
                buildProjects(projects, makefiles);
442
 
        }
443
 
        
444
 
        
445
 
        /* (non-Javadoc)
446
 
         * tests 3.0 style tool integration: create pre-build and post-build steps and verify that 
447
 
         * the proper commands are generated in the makefile which is created by the managedbuild system
448
 
         */
449
 
        public void testPreAndPostProcessBuildSteps(){
450
 
                IPath[] makefiles = {
451
 
                                 Path.fromOSString("makefile"), 
452
 
                                 Path.fromOSString("objects.mk"), 
453
 
                                 Path.fromOSString("subdir.mk"),
454
 
                                 Path.fromOSString("sources.mk")};              
455
 
 
456
 
                IProject[] projects = createProjects("preAndPostBuildSteps", null, null, true);                         
457
 
                IProject project = projects[0];
458
 
                IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
459
 
                IConfiguration config = info.getDefaultConfiguration();
460
 
                IFile projfile = project.getFile("main.cxx");
461
 
                config.setPreannouncebuildStep("Pre-announce Build Step");
462
 
                config.setPrebuildStep("echo 'executing Pre-Build Step' ");
463
 
                config.setPostannouncebuildStep("Post-announce Build Step");
464
 
                config.setPostbuildStep("echo 'executing Post-Build Step' ");
465
 
                buildProjects(projects, makefiles);
466
 
        }
467
 
 
468
 
 
469
 
        /* (non-Javadoc)
470
 
         * tests 3.0 style tool integration: create resource custom build step and verify that 
471
 
         * the proper commands are generated in the makefile which is created by the managedbuild system
472
 
         */
473
 
        public void testResourceCustomBuildStep(){
474
 
                IPath[] makefiles = {
475
 
                                 Path.fromOSString("makefile"), 
476
 
                                 Path.fromOSString("objects.mk"), 
477
 
                                 Path.fromOSString("subdir.mk"),
478
 
                                 Path.fromOSString("sources.mk")};              
479
 
                ITool rcbsTool;
480
 
                IInputType rcbsToolInputType;
481
 
                IAdditionalInput rcbsToolInputTypeAdditionalInput;
482
 
                IOutputType rcbsToolOutputType;
483
 
 
484
 
                IProject[] projects = createProjects("rcbsBasicTest", null, null, true);                                
485
 
                IProject project = projects[0];
486
 
                IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
487
 
                IConfiguration config = info.getDefaultConfiguration();
488
 
                IFile projfile = project.getFile("rcbsBasicTest.c");
489
 
                IResourceConfiguration rconfig = config.createResourceConfiguration(projfile);
490
 
                rcbsTool = rconfig.createTool(null,"rcbsBasicTestTool","rcbs Basic Test Tool",false);
491
 
                rcbsToolInputType = rcbsTool.createInputType(null,"rcbsToolInputTypeId","rcbsToolInputTypeName",false);
492
 
                rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput("");
493
 
                rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY);
494
 
                rcbsToolOutputType = rcbsTool.createOutputType(null,"rcbsToolOutputTypeId","rcbsToolOutputTypeName",false);
495
 
                rcbsToolOutputType.setOutputNames("rcbsBasicTest.o");
496
 
                rcbsTool.setCustomBuildStep(true);
497
 
                rcbsTool.setToolCommand("gcc -g -c ../rcbsBasicTest.c -o ./rcbsBasicTest.o");
498
 
                rcbsTool.setAnnouncement("Now executing custom build step for rcbsBasicTest debug config");
499
 
                rconfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE);
500
 
                buildProjects(projects, makefiles);
501
 
        }
502
 
 
503
 
        
504
 
        /* (non-Javadoc)
505
 
         * tests 3.0 style tool integration with pre and post process steps added to typical compile & link
506
 
         */
507
 
        public void test30_1(){
508
 
                IPath[] makefiles = {
509
 
                                 Path.fromOSString("makefile"), 
510
 
                                 Path.fromOSString("objects.mk"), 
511
 
                                 Path.fromOSString("sources.mk"), 
512
 
                                 Path.fromOSString("subdir.mk")};
513
 
                IProject[] projects = createProjects("test30_1", null, null, true);
514
 
                buildProjects(projects, makefiles);
515
 
        }
516
 
 
517
 
        /* (non-Javadoc)
518
 
         * tests 3.0 style tool integration with multiple input types use Eclipse content types
519
 
         */
520
 
        public void test30_2(){
521
 
                IPath[] makefiles = {
522
 
                                 Path.fromOSString("makefile"), 
523
 
                                 Path.fromOSString("objects.mk"), 
524
 
                                 Path.fromOSString("sources.mk"), 
525
 
                                 Path.fromOSString("subdir.mk")};
526
 
                IProject[] projects = createProjects("test30_2", null, null, true);
527
 
                buildProjects(projects, makefiles);
528
 
        }
529
 
        
530
 
        /* (non-Javadoc)
531
 
         * tests 3.0 top-level tool-chain definition
532
 
         */
533
 
        public void testTopTC(){
534
 
                IProject[] projects = createProjects("TopTC", null, "TopTC.target.exe", false);
535
 
                //  There should be only one project.
536
 
                assertNotNull(projects);
537
 
                assertEquals(1, projects.length);
538
 
                IProject project = projects[0];
539
 
                //  Verify a number of other attributes
540
 
                IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
541
 
                assertNotNull(info);
542
 
                IManagedProject managedProj = info.getManagedProject();
543
 
                assertNotNull(managedProj);
544
 
                IConfiguration[] configs = managedProj.getConfigurations();
545
 
                assertNotNull(configs);
546
 
                assertEquals(2, configs.length);
547
 
                //  Make sure that each configuration has a tool-chain with all 5 tools
548
 
                for (int i=0; i<configs.length; i++) {
549
 
                        IConfiguration config = configs[i];
550
 
                        ToolChain tc = (ToolChain)config.getToolChain();
551
 
                        Iterator iter = tc.getToolList().listIterator();
552
 
                        int j = 0;
553
 
                        while (iter.hasNext()) {
554
 
                                Tool toolChild = (Tool) iter.next();
555
 
                                j++;
556
 
                        }
557
 
                        assertEquals(5, j);
558
 
                }
559
 
                buildDegenerativeProjects(projects, null);
560
 
        }
561
 
 
562
 
        /* (non-Javadoc)
563
 
         * tests external dependency calculation using Fortran modules
564
 
         */
565
 
        public void CDTFortranTest1(){
566
 
                IPath[] makefiles = {
567
 
                                 Path.fromOSString("makefile"), 
568
 
                                 Path.fromOSString("objects.mk"), 
569
 
                                 Path.fromOSString("sources.mk"), 
570
 
                                 Path.fromOSString("subdir.mk")};
571
 
                IProject[] projects = createProjects("CDTFortranTest1", null, null, true);
572
 
                buildProjects(projects, makefiles);
573
 
        }
574
 
 
575
 
        /* (non-Javadoc)
576
 
         * tests external dependency calculation using Fortran modules
577
 
         */
578
 
        public void CDTFortranTest2(){
579
 
                IPath[] makefiles = {
580
 
                                 Path.fromOSString("makefile"), 
581
 
                                 Path.fromOSString("objects.mk"), 
582
 
                                 Path.fromOSString("sources.mk"), 
583
 
                                 Path.fromOSString("module/subdir.mk"),
584
 
                                 Path.fromOSString("Sources/subdir.mk")};
585
 
                IProject[] projects = createProjects("CDTFortranTest2", null, null, true);
586
 
                buildProjects(projects, makefiles);
587
 
        }
588
 
 
589
 
        /* (non-Javadoc)
590
 
         * tests the InputType assignToOption attribute
591
 
         */
592
 
        public void TestATO(){
593
 
                IPath[] makefiles = {
594
 
                                 Path.fromOSString("makefile"), 
595
 
                                 Path.fromOSString("objects.mk"), 
596
 
                                 Path.fromOSString("sources.mk"), 
597
 
                                 Path.fromOSString("subdir.mk")};
598
 
                IProject[] projects = createProjects("TestATO", null, null, true);
599
 
                buildProjects(projects, makefiles);
600
 
        }
601
 
        
602
 
        public void testMacroSupportInBuildDefinitions() {
603
 
                IPath[] makefiles = {
604
 
                                 Path.fromOSString("makefile"), 
605
 
                                 Path.fromOSString("objects.mk"), 
606
 
                                 Path.fromOSString("sources.mk"), 
607
 
                                 Path.fromOSString("subdir.mk")};
608
 
                IProject[] projects = createProjects("testMacroSupportInBuildDefinitions", null, null, true);
609
 
                buildProjects(projects, makefiles);
610
 
        }
611
 
        
612
 
        /**
613
 
         * (non-Javadoc)
614
 
         * tests managed build system with a project which has resources with spaces in their paths
615
 
         */
616
 
        public void testSpaces()
617
 
        {
618
 
                IPath[] makefiles = {
619
 
                                 Path.fromOSString("makefile"), 
620
 
                                 Path.fromOSString("objects.mk"), 
621
 
                                 Path.fromOSString("sources.mk"), 
622
 
                                 Path.fromOSString("subdir.mk"),
623
 
                                 Path.fromOSString("main with spaces.d"),
624
 
                                 Path.fromOSString("sub folder with spaces/subdir.mk"),
625
 
                                 Path.fromOSString("sub folder with spaces/foo with spaces.d")};
626
 
                IProject[] projects = createProjects("test with spaces", null, null, true);
627
 
                buildProjects(projects, makefiles);
628
 
        }
629
 
        
630
 
        /**
631
 
         * (non-Javadoc)
632
 
         * tests managed build system with a project which has resources with spaces in their paths
633
 
         */
634
 
        public void testInputTypeOption()
635
 
        {
636
 
                IPath[] makefiles = {
637
 
                                 Path.fromOSString("makefile"), 
638
 
                                 Path.fromOSString("objects.mk"), 
639
 
                                 Path.fromOSString("sources.mk"), 
640
 
                                 Path.fromOSString("subdir.mk"),
641
 
                };
642
 
                IProject[] projects = createProjects("inputTypeOption", null, null, true);
643
 
                buildProjects(projects, makefiles);
644
 
        }
645
 
}