|
Lines 60-65
Link Here
|
| 60 |
import org.eclipse.core.runtime.NullProgressMonitor; |
60 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 61 |
import org.eclipse.core.runtime.Path; |
61 |
import org.eclipse.core.runtime.Path; |
| 62 |
|
62 |
|
|
|
63 |
@SuppressWarnings("restriction") |
| 63 |
public class BuildDescriptionModelTests extends TestCase { |
64 |
public class BuildDescriptionModelTests extends TestCase { |
| 64 |
private static final String PREFIX = "BuildDescription_"; |
65 |
private static final String PREFIX = "BuildDescription_"; |
| 65 |
private static final String PROJ_PATH = "testBuildDescriptionProjects"; |
66 |
private static final String PROJ_PATH = "testBuildDescriptionProjects"; |
|
Lines 68-82
Link Here
|
| 68 |
private Runnable fCleaner = fCompositeCleaner; |
69 |
private Runnable fCleaner = fCompositeCleaner; |
| 69 |
|
70 |
|
| 70 |
private class CompositeCleaner implements Runnable{ |
71 |
private class CompositeCleaner implements Runnable{ |
| 71 |
private List fRunnables = new ArrayList(); |
72 |
private List<Runnable> fRunnables = new ArrayList<Runnable>(); |
| 72 |
|
73 |
|
| 73 |
public void addRunnable(Runnable r){ |
74 |
public void addRunnable(Runnable r){ |
| 74 |
fRunnables.add(r); |
75 |
fRunnables.add(r); |
| 75 |
} |
76 |
} |
| 76 |
|
77 |
|
| 77 |
public void run() { |
78 |
public void run() { |
| 78 |
for(Iterator iter = fRunnables.iterator(); iter.hasNext();){ |
79 |
for(Iterator<Runnable> iter = fRunnables.iterator(); iter.hasNext();){ |
| 79 |
Runnable r = (Runnable)iter.next(); |
80 |
Runnable r = iter.next(); |
| 80 |
r.run(); |
81 |
r.run(); |
| 81 |
} |
82 |
} |
| 82 |
fRunnables.clear(); |
83 |
fRunnables.clear(); |
|
Lines 84-90
Link Here
|
| 84 |
|
85 |
|
| 85 |
} |
86 |
} |
| 86 |
private class ProjectCleaner implements Runnable{ |
87 |
private class ProjectCleaner implements Runnable{ |
| 87 |
List fProjList = new ArrayList(); |
88 |
List<String> fProjList = new ArrayList<String>(); |
| 88 |
|
89 |
|
| 89 |
public ProjectCleaner(){ |
90 |
public ProjectCleaner(){ |
| 90 |
} |
91 |
} |
|
Lines 106-113
Link Here
|
| 106 |
} |
107 |
} |
| 107 |
|
108 |
|
| 108 |
public void run() { |
109 |
public void run() { |
| 109 |
for(Iterator iter = fProjList.iterator(); iter.hasNext();){ |
110 |
for(Iterator<String> iter = fProjList.iterator(); iter.hasNext();){ |
| 110 |
String name = (String)iter.next(); |
111 |
String name = iter.next(); |
| 111 |
ManagedBuildTestHelper.removeProject(name); |
112 |
ManagedBuildTestHelper.removeProject(name); |
| 112 |
} |
113 |
} |
| 113 |
fProjList.clear(); |
114 |
fProjList.clear(); |
|
Lines 143-149
Link Here
|
| 143 |
if(aAsmRc != des.createResource("a.asm")) |
144 |
if(aAsmRc != des.createResource("a.asm")) |
| 144 |
fail("new build resource created for the same resource"); |
145 |
fail("new build resource created for the same resource"); |
| 145 |
|
146 |
|
| 146 |
if(aAsmRc != des.createResource(aAsm.getLocation(), aAsm.getFullPath())) |
147 |
if(aAsmRc != des.createResource(aAsm.getLocation(), aAsm.getLocationURI())) |
| 147 |
fail("new build resource created for the same resource"); |
148 |
fail("new build resource created for the same resource"); |
| 148 |
|
149 |
|
| 149 |
assertEquals(aAsmRc.getProducerIOType(), null); |
150 |
assertEquals(aAsmRc.getProducerIOType(), null); |
|
Lines 157-162
Link Here
|
| 157 |
if(type == null) |
158 |
if(type == null) |
| 158 |
fail("failed to create output type"); |
159 |
fail("failed to create output type"); |
| 159 |
|
160 |
|
|
|
161 |
assertNotNull(type); |
| 160 |
assertEquals(type.getStep(), inStep); |
162 |
assertEquals(type.getStep(), inStep); |
| 161 |
|
163 |
|
| 162 |
type.addResource(aAsmRc); |
164 |
type.addResource(aAsmRc); |
|
Lines 558-578
Link Here
|
| 558 |
} |
560 |
} |
| 559 |
*/ |
561 |
*/ |
| 560 |
private void doTestStep(IBuildStep step, IBuildStep oStep, boolean up){ |
562 |
private void doTestStep(IBuildStep step, IBuildStep oStep, boolean up){ |
| 561 |
Map inMap = new HashMap(); |
563 |
Map<IBuildIOType, IBuildIOType> inMap = new HashMap<IBuildIOType, IBuildIOType>(); |
| 562 |
Map outMap = new HashMap(); |
564 |
Map<IBuildIOType, IBuildIOType> outMap = new HashMap<IBuildIOType, IBuildIOType>(); |
| 563 |
|
565 |
|
| 564 |
stepsMatch(step, oStep, inMap, outMap, true); |
566 |
stepsMatch(step, oStep, inMap, outMap, true); |
| 565 |
|
567 |
|
| 566 |
Map map = up ? outMap : inMap; |
568 |
Map<IBuildIOType, IBuildIOType> map = up ? outMap : inMap; |
| 567 |
|
569 |
|
| 568 |
for(Iterator iter = map.entrySet().iterator();iter.hasNext();){ |
570 |
for(Iterator<?> iter = map.entrySet().iterator();iter.hasNext();){ |
| 569 |
Map.Entry entry = (Map.Entry)iter.next(); |
571 |
Map.Entry entry = (Map.Entry)iter.next(); |
| 570 |
doTestType((IBuildIOType)entry.getKey(), (IBuildIOType)entry.getValue()); |
572 |
doTestType((IBuildIOType)entry.getKey(), (IBuildIOType)entry.getValue()); |
| 571 |
} |
573 |
} |
| 572 |
} |
574 |
} |
| 573 |
|
575 |
|
| 574 |
private void doTestType(IBuildIOType type, IBuildIOType oType){ |
576 |
private void doTestType(IBuildIOType type, IBuildIOType oType){ |
| 575 |
Map map = new HashMap(); |
577 |
Map<IBuildResource, IBuildResource> map = new HashMap<IBuildResource, IBuildResource>(); |
| 576 |
|
578 |
|
| 577 |
typesMatch(type, oType, map, true); |
579 |
typesMatch(type, oType, map, true); |
| 578 |
|
580 |
|
|
Lines 583-589
Link Here
|
| 583 |
} |
585 |
} |
| 584 |
|
586 |
|
| 585 |
private void doTestResource(IBuildResource rc, IBuildResource oRc, boolean up){ |
587 |
private void doTestResource(IBuildResource rc, IBuildResource oRc, boolean up){ |
| 586 |
Map outMap = new HashMap(); |
588 |
Map<IBuildIOType, IBuildIOType> outMap = new HashMap<IBuildIOType, IBuildIOType>(); |
| 587 |
|
589 |
|
| 588 |
doTestResourceMatch(rc, oRc, outMap); |
590 |
doTestResourceMatch(rc, oRc, outMap); |
| 589 |
|
591 |
|
|
Lines 591-597
Link Here
|
| 591 |
typesMatch(rc.getProducerIOType(), oRc.getProducerIOType(), null, true); |
593 |
typesMatch(rc.getProducerIOType(), oRc.getProducerIOType(), null, true); |
| 592 |
doTestStep(rc.getProducerIOType().getStep(), oRc.getProducerIOType().getStep(), up); |
594 |
doTestStep(rc.getProducerIOType().getStep(), oRc.getProducerIOType().getStep(), up); |
| 593 |
} else { |
595 |
} else { |
| 594 |
Set stepSet = new HashSet(); |
596 |
Set<IBuildStep> stepSet = new HashSet<IBuildStep>(); |
| 595 |
|
597 |
|
| 596 |
for(Iterator iter = outMap.entrySet().iterator(); iter.hasNext();){ |
598 |
for(Iterator iter = outMap.entrySet().iterator(); iter.hasNext();){ |
| 597 |
Map.Entry entry = (Map.Entry)iter.next(); |
599 |
Map.Entry entry = (Map.Entry)iter.next(); |
|
Lines 607-613
Link Here
|
| 607 |
} |
609 |
} |
| 608 |
} |
610 |
} |
| 609 |
|
611 |
|
| 610 |
private void doTestResourceMatch(IBuildResource rc, IBuildResource oRc, Map outTypeMap){ |
612 |
private void doTestResourceMatch(IBuildResource rc, IBuildResource oRc, Map<IBuildIOType, IBuildIOType> outTypeMap){ |
| 611 |
|
613 |
|
| 612 |
doTrace("matching resource " + DbgUtil.resourceName(rc)); |
614 |
doTrace("matching resource " + DbgUtil.resourceName(rc)); |
| 613 |
|
615 |
|
|
Lines 642-652
Link Here
|
| 642 |
} |
644 |
} |
| 643 |
|
645 |
|
| 644 |
|
646 |
|
| 645 |
private boolean stepsMatch(IBuildStep step, IBuildStep oStep, Map inTypeMap, Map outTypeMap, boolean failOnErr){ |
647 |
private boolean stepsMatch(IBuildStep step, IBuildStep oStep, Map<IBuildIOType, IBuildIOType> inTypeMap, Map<IBuildIOType, IBuildIOType> outTypeMap, boolean failOnErr){ |
| 646 |
return stepsMatch(step, oStep, inTypeMap, outTypeMap, true, failOnErr); |
648 |
return stepsMatch(step, oStep, inTypeMap, outTypeMap, true, failOnErr); |
| 647 |
} |
649 |
} |
| 648 |
|
650 |
|
| 649 |
private boolean stepsMatch(IBuildStep step, IBuildStep oStep, Map inTypeMap, Map outTypeMap, boolean checkSteps, boolean failOnErr){ |
651 |
private boolean stepsMatch(IBuildStep step, IBuildStep oStep, Map<IBuildIOType, IBuildIOType> inTypeMap, Map<IBuildIOType, IBuildIOType> outTypeMap, boolean checkSteps, boolean failOnErr){ |
| 650 |
IBuildIOType inTypes[] = step.getInputIOTypes(); |
652 |
IBuildIOType inTypes[] = step.getInputIOTypes(); |
| 651 |
IBuildIOType oInTypes[] = oStep.getInputIOTypes(); |
653 |
IBuildIOType oInTypes[] = oStep.getInputIOTypes(); |
| 652 |
|
654 |
|
|
Lines 709-715
Link Here
|
| 709 |
return getCorType(type, oTypes, null, true); |
711 |
return getCorType(type, oTypes, null, true); |
| 710 |
} |
712 |
} |
| 711 |
|
713 |
|
| 712 |
private IBuildIOType getCorType(IBuildIOType type, IBuildIOType oTypes[], Map rcMap, boolean checkSteps){ |
714 |
private IBuildIOType getCorType(IBuildIOType type, IBuildIOType oTypes[], Map<IBuildResource, IBuildResource> rcMap, boolean checkSteps){ |
| 713 |
for(int i = 0; i < oTypes.length; i++){ |
715 |
for(int i = 0; i < oTypes.length; i++){ |
| 714 |
if(typesMatch(type, oTypes[i], rcMap, checkSteps, false)) |
716 |
if(typesMatch(type, oTypes[i], rcMap, checkSteps, false)) |
| 715 |
return oTypes[i]; |
717 |
return oTypes[i]; |
|
Lines 746-756
Link Here
|
| 746 |
*/ |
748 |
*/ |
| 747 |
} |
749 |
} |
| 748 |
|
750 |
|
| 749 |
private boolean typesMatch(IBuildIOType type, IBuildIOType oType, Map rcMap, boolean failOnError){ |
751 |
private boolean typesMatch(IBuildIOType type, IBuildIOType oType, Map<IBuildResource, IBuildResource> rcMap, boolean failOnError){ |
| 750 |
return typesMatch(type, oType, rcMap, true, failOnError); |
752 |
return typesMatch(type, oType, rcMap, true, failOnError); |
| 751 |
} |
753 |
} |
| 752 |
|
754 |
|
| 753 |
private boolean typesMatch(IBuildIOType type, IBuildIOType oType, Map rcMap, boolean checkStep, boolean failOnError){ |
755 |
private boolean typesMatch(IBuildIOType type, IBuildIOType oType, Map<IBuildResource, IBuildResource> rcMap, boolean checkStep, boolean failOnError){ |
| 754 |
|
756 |
|
| 755 |
// doTrace("matching io type"); |
757 |
// doTrace("matching io type"); |
| 756 |
if(type.isInput() != oType.isInput()){ |
758 |
if(type.isInput() != oType.isInput()){ |
|
Lines 766-773
Link Here
|
| 766 |
return false; |
768 |
return false; |
| 767 |
|
769 |
|
| 768 |
if(resourcesMatch(rcs, oRcs, rcMap)){ |
770 |
if(resourcesMatch(rcs, oRcs, rcMap)){ |
| 769 |
Map inMap = new HashMap(); |
771 |
Map<IBuildIOType, IBuildIOType> inMap = new HashMap<IBuildIOType, IBuildIOType>(); |
| 770 |
Map outMap = new HashMap(); |
772 |
Map<IBuildIOType, IBuildIOType> outMap = new HashMap<IBuildIOType, IBuildIOType>(); |
| 771 |
if(!checkStep) |
773 |
if(!checkStep) |
| 772 |
return true; |
774 |
return true; |
| 773 |
return stepsMatch(type.getStep(), oType.getStep(), inMap, outMap, false, failOnError); |
775 |
return stepsMatch(type.getStep(), oType.getStep(), inMap, outMap, false, failOnError); |
|
Lines 779-785
Link Here
|
| 779 |
return false; |
781 |
return false; |
| 780 |
} |
782 |
} |
| 781 |
|
783 |
|
| 782 |
private boolean resourcesMatch(IBuildResource rcs[], IBuildResource oRcs[], Map rcMap){ |
784 |
private boolean resourcesMatch(IBuildResource rcs[], IBuildResource oRcs[], Map<IBuildResource, IBuildResource> rcMap){ |
| 783 |
if(rcs.length != oRcs.length) |
785 |
if(rcs.length != oRcs.length) |
| 784 |
return false; |
786 |
return false; |
| 785 |
|
787 |
|