Skip to content

Commit 9269b29

Browse files
committed
diable impact collection for string specializations
1 parent d91bd0f commit 9269b29

File tree

2 files changed

+44
-34
lines changed
  • core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/headerlocation
  • core/src/main/kotlin/org/evomaster/core/search/impact/impactinfocollection/value

2 files changed

+44
-34
lines changed

core-tests/jdk-8/spring-rest-openapi-v2-tests/src/test/java/org/evomaster/e2etests/spring/examples/headerlocation/HLEMTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import static org.junit.jupiter.api.Assertions.assertTrue;
1010

11-
//FIXME failing due EnumGeneImpact.countImpactWithMutatedGeneWithContext
12-
@Disabled
1311
public class HLEMTest extends HLTestBase {
1412

1513

core/src/main/kotlin/org/evomaster/core/search/impact/impactinfocollection/value/StringGeneImpact.kt

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ class StringGeneImpact (sharedImpactInfo: SharedImpactInfo,
3434

3535
constructor(id: String, gene : StringGene)
3636
: this(
37-
sharedImpactInfo = SharedImpactInfo(id),
38-
specificImpactInfo = SpecificImpactInfo(),
39-
hierarchySpecializationImpactInfo =
40-
if (gene.specializationGenes.isEmpty()) null
41-
else HierarchySpecializationImpactInfo(null, gene.specializationGenes.map { ImpactUtils.createGeneImpact(it, it.name) }.toMutableList()))
37+
sharedImpactInfo = SharedImpactInfo(id),
38+
specificImpactInfo = SpecificImpactInfo())
39+
40+
/*
41+
disable constructor with specialization gene
42+
we may resume it
43+
*/
44+
// constructor(id: String, gene : StringGene)
45+
// : this(
46+
// sharedImpactInfo = SharedImpactInfo(id),
47+
// specificImpactInfo = SpecificImpactInfo(),
48+
// hierarchySpecializationImpactInfo =
49+
// if (gene.specializationGenes.isEmpty()) null
50+
// else HierarchySpecializationImpactInfo(null, gene.specializationGenes.map { ImpactUtils.createGeneImpact(it, it.name) }.toMutableList()))
4251

4352
fun getSpecializationImpacts() = hierarchySpecializationImpactInfo?.flattenImpacts()?: listOf<Impact>()
4453

@@ -75,14 +84,13 @@ class StringGeneImpact (sharedImpactInfo: SharedImpactInfo,
7584

7685
if (gc.previous == null && impactTargets.isNotEmpty()) return
7786

78-
val allImpacts = hierarchySpecializationImpactInfo?.flattenImpacts()
79-
8087
val currentSelect = gc.current.selectedSpecialization
8188
employSpecialization.countImpactAndPerformance(noImpactTargets = noImpactTargets, impactTargets = impactTargets, improvedTargets = improvedTargets, onlyManipulation = onlyManipulation, num = gc.numOfMutatedGene)
8289
val taintImpact = if (currentSelect == NEVER_EMPLOY_SPECIALIZATION){ employSpecialization.falseValue }else employSpecialization.trueValue
8390
taintImpact.countImpactAndPerformance(noImpactTargets = noImpactTargets, impactTargets = impactTargets, improvedTargets = improvedTargets, onlyManipulation = onlyManipulation, num = 1)
8491

85-
if (currentSelect != NEVER_EMPLOY_SPECIALIZATION && allImpacts?.size == gc.current.specializationGenes.size){
92+
val allImpacts = hierarchySpecializationImpactInfo?.flattenImpacts()
93+
if (hierarchySpecializationImpactInfo != null && currentSelect != NEVER_EMPLOY_SPECIALIZATION && allImpacts?.size == gc.current.specializationGenes.size){
8694

8795
val sImpact = allImpacts[gc.current.selectedSpecialization]
8896
val previousSelect = (gc.previous as? StringGene)?.selectedSpecialization
@@ -125,29 +133,33 @@ class StringGeneImpact (sharedImpactInfo: SharedImpactInfo,
125133
return map
126134
}
127135

128-
override fun syncImpact(previous: Gene?, current: Gene) {
129-
check(previous, current)
130-
if (hierarchySpecializationImpactInfo == null){
131-
if ((current as StringGene).specializationGenes.isNotEmpty()){
132-
hierarchySpecializationImpactInfo = HierarchySpecializationImpactInfo(null, current.specializationGenes.map { ImpactUtils.createGeneImpact(it, it.name) }.toMutableList())
133-
if (current.specializationGenes.size != getSpecializationImpacts().size){
134-
log.warn("invalid initialization of specializationGenes of string gene")
135-
}
136-
}
137-
}else{
138-
val currentImpact = hierarchySpecializationImpactInfo!!.flattenImpacts().size
139-
if ((current as StringGene).specializationGenes.size > currentImpact){
140-
val added = current.specializationGenes.subList(currentImpact, current.specializationGenes.size)
141-
hierarchySpecializationImpactInfo = hierarchySpecializationImpactInfo!!.next(added.toMutableList())
142-
}else if (previous != null && current.specializationGenes.size < (previous as StringGene).specializationGenes.size){
143-
log.info("some specializations of StringGene are removed {},{}", current.specializationGenes.size, previous.specializationGenes.size)
144-
}else if(previous == null){
145-
log.info("the previous gene is null")
146-
if (current.specializationGenes.size != getSpecializationImpacts().size){
147-
log.warn("invalid initialization of specializationGenes of string gene")
148-
}
149-
}
150-
}
151-
}
136+
/*
137+
For now, disable impact collection for specialization gene
138+
TODO Man
139+
*/
140+
// override fun syncImpact(previous: Gene?, current: Gene) {
141+
// check(previous, current)
142+
// if (hierarchySpecializationImpactInfo == null){
143+
// if ((current as StringGene).specializationGenes.isNotEmpty()){
144+
// hierarchySpecializationImpactInfo = HierarchySpecializationImpactInfo(null, current.specializationGenes.map { ImpactUtils.createGeneImpact(it, it.name) }.toMutableList())
145+
// if (current.specializationGenes.size != getSpecializationImpacts().size){
146+
// log.warn("invalid initialization of specializationGenes of string gene")
147+
// }
148+
// }
149+
// }else{
150+
// val currentImpact = hierarchySpecializationImpactInfo!!.flattenImpacts().size
151+
// if ((current as StringGene).specializationGenes.size > currentImpact){
152+
// val added = current.specializationGenes.subList(currentImpact, current.specializationGenes.size)
153+
// hierarchySpecializationImpactInfo = hierarchySpecializationImpactInfo!!.next(added.toMutableList())
154+
// }else if (previous != null && current.specializationGenes.size < (previous as StringGene).specializationGenes.size){
155+
// log.info("some specializations of StringGene are removed {},{}", current.specializationGenes.size, previous.specializationGenes.size)
156+
// }else if(previous == null){
157+
// log.info("the previous gene is null")
158+
// if (current.specializationGenes.size != getSpecializationImpacts().size){
159+
// log.warn("invalid initialization of specializationGenes of string gene")
160+
// }
161+
// }
162+
// }
163+
// }
152164

153165
}

0 commit comments

Comments
 (0)