Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
13fe4cd
Move `ApplicationContext` and `SpringApplicationContext` to `utbot-fr…
IlyaMuravjov Jul 13, 2023
bf63dd2
Merge `avoidSpeculativeNotNullChecks` and `speculativelyCannotProduce…
IlyaMuravjov Jul 13, 2023
eae27de
Extract `ApplicationContext` interface
IlyaMuravjov Jul 13, 2023
a3677cc
Extract `MockerContext` interface
IlyaMuravjov Jul 13, 2023
dca31f1
Configure default `ApplicationContext` for `TestCaseGenerator`
IlyaMuravjov Jul 13, 2023
444212a
Group contexts in packages by their kind (simple and Spring)
IlyaMuravjov Jul 13, 2023
810d2c8
Extract `TypeReplacer` and `NonNullSpeculator`, replace `shouldUseImp…
IlyaMuravjov Jul 13, 2023
c7f0753
Extract `ConcreteExecutionContext`
IlyaMuravjov Jul 13, 2023
b794b9f
Make naming of `SpringApplicationContext` properties more consistent
IlyaMuravjov Jul 13, 2023
351c0a1
Pass `Instrumentation.Factory` via Kryo instead of `Instrumentation` …
IlyaMuravjov Jul 17, 2023
452a495
Refactor `ConcreteExecutionContext` interface, to avoid `when`s by `A…
IlyaMuravjov Jul 17, 2023
48d3586
Remove unused imports
IlyaMuravjov Jul 17, 2023
10f5b65
Fix compilation after rebase
IlyaMuravjov Jul 18, 2023
fbbddbf
Avoid when by `projectType` when choosing `CgVariableConstructor`
IlyaMuravjov Jul 18, 2023
8ce1980
Introduce `CodeGeneratorParams` data class, to avoid repeating same p…
IlyaMuravjov Jul 18, 2023
5f3902b
Make `ApplicationContext` be responsible for creating appropriate cod…
IlyaMuravjov Jul 18, 2023
fb4e31f
Improve equals overrides for `Instrumentation.Factory` implementations
IlyaMuravjov Jul 19, 2023
c8dffff
Move `SimpleUtExecutionInstrumentation` to a separate file
IlyaMuravjov Jul 19, 2023
6b70514
Fix compilation after rebase and decouple Spring tests
IlyaMuravjov Jul 19, 2023
dbf4da7
Remove unused and outdated imports left after rebase
IlyaMuravjov Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge avoidSpeculativeNotNullChecks and `speculativelyCannotProduce…
…NullPointerException` into one method
  • Loading branch information
IlyaMuravjov committed Jul 20, 2023
commit bf63dd2d39e3228d9cc0cf5b30f6005644b67f6a
8 changes: 2 additions & 6 deletions utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2336,12 +2336,8 @@ class Traverser(
* See more detailed documentation in [ApplicationContext] mentioned methods.
*/
private fun checkAndMarkLibraryFieldSpeculativelyNotNull(field: SootField, createdField: SymbolicValue) {
if (applicationContext.avoidSpeculativeNotNullChecks(field) ||
!applicationContext.speculativelyCannotProduceNullPointerException(field, methodUnderTest.classId)) {
return
}

markAsSpeculativelyNotNull(createdField.addr)
if (applicationContext.speculativelyCannotProduceNullPointerException(field, methodUnderTest.classId))
markAsSpeculativelyNotNull(createdField.addr)
}

private fun createArray(pName: String, type: ArrayType): ArrayValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ open class ApplicationContext(
*/
open fun replaceTypeIfNeeded(type: RefType): ClassId? = null

/**
* Sets the restrictions on speculative not null
* constraints in current application context.
*
* @see docs/SpeculativeFieldNonNullability.md for more information.
*/
open fun avoidSpeculativeNotNullChecks(field: SootField): Boolean =
UtSettings.maximizeCoverageUsingReflection || !field.declaringClass.isFromTrustedLibrary()

/**
* Checks whether accessing [field] (with a method invocation or field access) speculatively
* cannot produce [NullPointerException] (according to its finality or accessibility).
Expand All @@ -67,7 +58,10 @@ open class ApplicationContext(
open fun speculativelyCannotProduceNullPointerException(
field: SootField,
classUnderTest: ClassId,
): Boolean = field.isFinal || !field.isPublic
): Boolean =
!UtSettings.maximizeCoverageUsingReflection &&
field.declaringClass.isFromTrustedLibrary() &&
(field.isFinal || !field.isPublic)

open fun preventsFurtherTestGeneration(): Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class SpringApplicationContext(
null
}

override fun avoidSpeculativeNotNullChecks(field: SootField): Boolean = false

/**
* In Spring applications we can mark as speculatively not null
* fields if they are mocked and injecting into class under test so on.
Expand Down