Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking #108

Merged
merged 145 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
e735107
Descriptors generated for all terms. Working on MockDescriptor
ilma4 Sep 17, 2023
c599d79
Descriptors generated for all terms. Methods calls collected from ini…
ilma4 Sep 28, 2023
d69f106
Parameters: methods related to mocks. MockDescriptor: work in progress.
ilma4 Oct 8, 2023
5a21682
DescriptorWrapper.Mock WIP.
ilma4 Oct 14, 2023
c8e3757
TODOs and comments fixes
ilma4 Oct 14, 2023
9d9c299
DescriptorWrapper.Mock field wrapping
ilma4 Oct 14, 2023
c7a9e58
mockDescriptorSerialization test.
ilma4 Oct 15, 2023
9102bdc
UnimplementedInterfaceConcolicLongTest
ilma4 Oct 15, 2023
5495510
Merge changes from master
ilma4 Oct 15, 2023
6edd5cc
Better mockDescriptorSerializationTest: added self-reference
ilma4 Oct 15, 2023
1c7e52c
MockDescriptor serializer now registered
ilma4 Oct 15, 2023
a00a360
mockDescriptorSerializationTest: testing returnValues serialization
ilma4 Oct 16, 2023
932c83c
Fixed MockSequence mapping. Fixed tests
ilma4 Oct 23, 2023
e8c1a83
Mockito.mock printing
ilma4 Oct 31, 2023
c198f9f
Mockito.mock printing
ilma4 Nov 2, 2023
47dc697
Fixes
ilma4 Nov 2, 2023
f26cb5c
Add Mockito to deps, logback prints line and method
ilma4 Nov 9, 2023
b1a422c
Merge branch 'master' into ilma4-temp-to-master
ilma4 Nov 9, 2023
e317592
Fixed mockito issues in workers. Function filtering clauses in extens…
ilma4 Nov 10, 2023
c1a5f76
Remove MockitoMock part from "is ...$MockitoMock$" predicates.
ilma4 Nov 13, 2023
740e527
It's just works!
ilma4 Nov 13, 2023
f1da6f3
Fixes
ilma4 Nov 13, 2023
92f60e1
Merge branch 'master' into ilma4-temp-to-master
ilma4 Nov 13, 2023
aa01a1b
SMTConverter fix
ilma4 Nov 13, 2023
8f9d028
Fixes: generating MockDescriptors, printing mocks.
ilma4 Nov 13, 2023
1723a97
Fixed cycle links case in Mocks
ilma4 Nov 13, 2023
5ea9076
Lambda to local function
ilma4 Nov 13, 2023
ed8fc90
Cleaning dependencies
ilma4 Nov 13, 2023
821509e
Merge branch 'master' into ilma4-temp-to-master
ilma4 Nov 20, 2023
26fdfa2
More accurate printing of mocks. Trying to fix mocks when they are fi…
ilma4 Nov 20, 2023
8685c44
MockDescriptors creates only from ObjectDescriptors. UnknownGenerator…
ilma4 Nov 20, 2023
a10c33e
MockTests split into different classes. Fixed DescriptorGenerator, St…
ilma4 Nov 21, 2023
02c259c
Fixes. All changes before publishing
ilma4 Nov 27, 2023
d15b17c
mockito-core.jar
ilma4 Nov 27, 2023
5fcb970
Fixed instanceof predicates generation
ilma4 Nov 27, 2023
b702b9c
MockUtils. Work on fixing issue with $MockitoMock$ classes
ilma4 Dec 6, 2023
977206c
Fixes usage of private classes from dependencies
ilma4 Dec 8, 2023
c2085b6
MockUtilsPrinter
ilma4 Dec 8, 2023
bc83922
Merge branch 'master' into mocks
ilma4 Dec 27, 2023
8a8eacc
Removed method:line information from logs
ilma4 Jan 6, 2024
6aa4c6d
Trying to convert mockito-created classes to original interfaces in m…
ilma4 Jan 7, 2024
1ef7742
Merge branch 'master' into mocks
ilma4 Jan 7, 2024
b7df3f3
Logging information of creating mock descriptors
ilma4 Jan 8, 2024
acbd561
Merge branch 'master' into mocks
ilma4 Jan 9, 2024
261d11b
Removed duplicated tests from MockTests
ilma4 Jan 9, 2024
aad09c2
Avoid collecting mock setup information if no mocks created
ilma4 Jan 9, 2024
128655d
Remove unnecessary code
ilma4 Jan 10, 2024
5a82cf4
Excluding classes from InstantiationManager in config
ilma4 Jan 10, 2024
ef6b8b0
Increased heap size in kex.py, because mocks cause more memory usage
ilma4 Jan 10, 2024
60e07ce
Add comment about potential low coverage in MockListTests
ilma4 Jan 11, 2024
ceecd70
Merge branch 'master' into mocks
ilma4 Jan 11, 2024
16c371b
Preparing to generate additional descriptors only if mocks are requir…
ilma4 Jan 11, 2024
e6a0abc
Generating additional descriptors only if mocks appears
ilma4 Jan 12, 2024
13bdcfd
Merge branch 'master' into mocks
ilma4 Jan 18, 2024
9f55034
Missing include
ilma4 Jan 22, 2024
8464371
TODO for timeout
ilma4 Jan 22, 2024
8e0d518
mock section in config. Some settings
ilma4 Jan 22, 2024
acb62f5
MockUtilsPrinter fixes
ilma4 Jan 22, 2024
3eb2fea
Add mocking configuration to kex-test.ini
ilma4 Jan 22, 2024
8185c55
Refactoring, functions for reading mocking config
ilma4 Jan 22, 2024
8dbd361
Refactoring
ilma4 Jan 22, 2024
2ee0557
Update memory values filtering in AbstractGenerator and other classes
ilma4 Jan 22, 2024
381df05
Modify tolerances in mockStaticsTests and mockListTests
ilma4 Jan 22, 2024
dc7af30
Remove mention of full mock mode, because it's unimplemented
ilma4 Jan 22, 2024
b71c575
Changes from sbst-mocks
ilma4 Jan 24, 2024
6740597
Enabled mocks in symbolic mode. Tests for mock-symbolic
ilma4 Jan 26, 2024
059c10f
Mocking mode "full": mock everything
ilma4 Jan 30, 2024
63c5def
Fix $MockitoMock$ classes problem
ilma4 Jan 30, 2024
6129011
Reverted eps in tests
ilma4 Jan 30, 2024
1531efa
Merge branch 'symbolic-mocks' into mocks
ilma4 Jan 30, 2024
c86bbe0
Removed unused code
ilma4 Jan 30, 2024
59245b6
Merge branch 'all-mocks' into mocks
ilma4 Jan 30, 2024
0e3dbb2
Removed unnecessary logging
ilma4 Jan 30, 2024
edc0d9e
Removed old unnecessary MockitoMock workarounds
ilma4 Jan 30, 2024
85af0fe
MockitoMock fix refactoring, now caching fix results
ilma4 Jan 30, 2024
7922926
Unused import
ilma4 Jan 30, 2024
1b4485b
HashMap -> LRUCache in MockitoMock fix. Basic mocking mode by default.
ilma4 Jan 30, 2024
60460df
Updated MockitoMock fix, no more classLoader and cache usage.
ilma4 Jan 30, 2024
c363cee
Changes from sbst-mock
ilma4 Jan 31, 2024
44b051e
Refactoring
ilma4 Feb 1, 2024
ada7f1e
Fixed instance mocking
ilma4 Feb 8, 2024
15b8317
Refactoring
ilma4 Feb 10, 2024
439f1a7
Print import Mockito only when need
ilma4 Feb 12, 2024
fe4af9f
Print methods of MockDescriptor only if they contain return values
ilma4 Feb 13, 2024
1eee357
Methods in MockDescriptor now may be changed after construction
ilma4 Feb 13, 2024
cec9a3d
Fix done
ilma4 Feb 14, 2024
8ca1e71
Refactoring. Regression test
ilma4 Feb 14, 2024
30f65cd
Fixes
ilma4 Feb 14, 2024
1040d3f
MockUtils refactoring
ilma4 Feb 14, 2024
79f737a
Hack to fix mockito on java 8
ilma4 Feb 16, 2024
d07d03b
Removed unnecessary hack in TestExecutor
ilma4 Feb 17, 2024
e0a4582
Config entry to disable workaround in KfgClassLoader
ilma4 Feb 17, 2024
427631e
Merge branch 'mocks-fixed-methods-with-overrides' into mocks
ilma4 Feb 17, 2024
f95baa7
Test of lambda mocking
ilma4 Feb 17, 2024
fe54ba4
Fixed PathClassLoader like KfgClassLoader
ilma4 Feb 19, 2024
a7a6c2b
Merge branch 'master' into mocks
ilma4 Feb 23, 2024
6071658
broken
ilma4 Feb 23, 2024
915e5b5
Fix functionalExtensions
ilma4 Feb 23, 2024
33bd4ae
Exclude lambdas from easy-random. config entry
ilma4 Feb 23, 2024
e0678a4
Exclude lambdas from easy-random. config entry
ilma4 Feb 24, 2024
95ec4cd
Descriptor.map renamed to Descriptor. transform
ilma4 Feb 24, 2024
2874946
Refactoring
ilma4 Feb 24, 2024
a6de947
Fix config usage
ilma4 Feb 25, 2024
14b0dba
New MockDescriptor constructor
ilma4 Feb 25, 2024
f6c18ad
Mocking performs through `MockMaker`s
ilma4 Feb 25, 2024
49a3bd1
Imports optimized
ilma4 Feb 25, 2024
1e40c33
Refactoring
ilma4 Feb 25, 2024
eebc99d
Method.general(). Will fix issues with inheritance
ilma4 Feb 25, 2024
3b3bef2
Use Method (from kfg) instead of MockMethod in MockDescriptor. Fix in…
ilma4 Feb 25, 2024
d870178
Use Method.klass to perform cast
ilma4 Feb 25, 2024
10a8f31
Fixes, removed testing code
ilma4 Feb 25, 2024
f87fecd
Select multiple mocking rules instead of one mockingMode.
ilma4 Feb 26, 2024
b3804d5
MockDescriptor constructor/builder refactoring
ilma4 Feb 26, 2024
73f74d2
log.warn -> log.error
ilma4 Feb 26, 2024
5e92dc6
Merge branch 'master' into mocks
ilma4 Feb 28, 2024
67deb27
DescriptorBuilder improvement
ilma4 Mar 3, 2024
075260b
kfg 0.4.15
ilma4 Mar 5, 2024
0c423d3
mockito id (core/inline) as property
ilma4 Mar 5, 2024
78f93cd
Removed mockito from kex-test deps
ilma4 Mar 5, 2024
f2050fb
Removed mockito from kex-executor deps
ilma4 Mar 5, 2024
05eabe9
Lambda mocking improved
ilma4 Mar 12, 2024
0da4327
Updated tests and config. Fixed(?) ClassInstantiationManager
ilma4 Mar 13, 2024
9cacfab
Refactoring
ilma4 Mar 19, 2024
249a4ad
Fix
ilma4 Mar 19, 2024
289ae99
Renaming. Prepairing for BreakingMockMaker
ilma4 Mar 19, 2024
e762496
Refactoring, preparing to better Lambda mocking
ilma4 Mar 19, 2024
662be30
Should work
ilma4 Mar 19, 2024
a1c612e
Merge from master
ilma4 Mar 19, 2024
9680c9b
Finished better lambda mocking
ilma4 Mar 19, 2024
86a094e
All MockMaker subclasses are private. Public functions are used instead
ilma4 Mar 19, 2024
56ea817
MockMaker fixes
ilma4 Mar 20, 2024
da7f66a
LambdaMockMaker tries to preserve original class in mock
ilma4 Mar 20, 2024
9cf0d40
Config refactoring
ilma4 Mar 20, 2024
92cf2db
Don't mock methods mockito cant mock
ilma4 Mar 21, 2024
1d0f806
Don't mock classes/interfaces mockito can't mock
ilma4 Mar 21, 2024
f4c971f
UnimplementedMockMaker refactoring
ilma4 Mar 22, 2024
0979530
`finalizeDescriptors` -> `performMocking`,
ilma4 Apr 4, 2024
5c4eaf1
Refactoring
ilma4 Apr 4, 2024
716f9d8
Useful config entry for tests
ilma4 Apr 4, 2024
7f60cf5
fix
ilma4 Apr 4, 2024
c282375
Merge branch 'master' into mocks
ilma4 Apr 4, 2024
7885fa0
config fix
ilma4 Apr 4, 2024
35755dc
Better Descriptor.transform
ilma4 Apr 11, 2024
74ebec6
comment
ilma4 Apr 25, 2024
f172330
Merge branch 'master' into mocks
AbdullinAM Apr 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package org.vorpal.research.kex.asm.manager
import org.vorpal.research.kex.ExecutionContext
import org.vorpal.research.kex.asm.util.AccessModifier
import org.vorpal.research.kex.asm.util.accessModifier
import org.vorpal.research.kex.config.kexConfig
import org.vorpal.research.kex.ktype.KexClass
import org.vorpal.research.kex.ktype.KexReference
import org.vorpal.research.kex.ktype.KexRtManager.rtMapped
import org.vorpal.research.kex.ktype.KexType
import org.vorpal.research.kex.ktype.kexType
import org.vorpal.research.kex.util.KfgTargetFilter
import org.vorpal.research.kex.util.isSubtypeOfCached
import org.vorpal.research.kfg.ClassManager
import org.vorpal.research.kfg.ir.Class
Expand All @@ -24,7 +26,7 @@ import kotlin.random.Random

val instantiationManager: ClassInstantiationManager get() = StringClassInstantiationManagerImpl

class NoConcreteInstanceException(val klass: Class) : Exception()
class NoConcreteInstanceException(val klass: Class) : Exception("No concrete instance for $klass")

interface ClassInstantiationManager {
fun isDirectlyInstantiable(klass: Class, accessLevel: AccessModifier): Boolean
Expand Down Expand Up @@ -287,6 +289,15 @@ private object StringClassInstantiationManagerImpl : ClassInstantiationManager {
}
}


private val ignoredInstantiations: Set<KfgTargetFilter> by lazy {
kexConfig.getMultipleStringValue("testGen", "ignoreInstantiation").flatMapTo(mutableSetOf()) {
val filter = KfgTargetFilter.parse(it)
listOf(filter, filter.rtMapped)
}
}


class ClassInstantiationDetector(
private val ctx: ExecutionContext,
private val baseAccessLevel: AccessModifier = AccessModifier.Private
Expand All @@ -296,6 +307,11 @@ class ClassInstantiationDetector(
override fun cleanup() {}

override fun visit(klass: Class) {
if (ignoredInstantiations.any { it.matches(klass) }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an ignore option here? What kind of classes do we want to filter out?

super.visit(klass)
return
}

if (StringClassInstantiationManagerImpl.isDirectlyInstantiable(klass, baseAccessLevel))
addInstantiableClass(klass, klass)
super.visit(klass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import org.vorpal.research.kex.ktype.KexShort
import org.vorpal.research.kex.ktype.KexString
import org.vorpal.research.kex.ktype.KexType
import org.vorpal.research.kex.ktype.asArray
import org.vorpal.research.kex.util.allFields
import org.vorpal.research.kex.util.isStatic
import org.vorpal.research.kex.util.kex
import org.vorpal.research.kex.util.*
import org.vorpal.research.kfg.type.SystemTypeNames
import org.vorpal.research.kthelper.assert.unreachable
import org.vorpal.research.kthelper.logging.log
Expand Down Expand Up @@ -66,13 +64,21 @@ class Object2DescriptorConverter : DescriptorBuilder() {
is LongArray -> KexLong.asArray()
is FloatArray -> KexFloat.asArray()
is DoubleArray -> KexDouble.asArray()
is Array<*> -> any.javaClass.componentType.kex.asArray()
is Array<*> -> any.javaClass.componentType.kexTypeMockitoMockFixed.asArray()
is String -> KexString()
else -> any.javaClass.kex
else -> any.javaClass.kexTypeMockitoMockFixed
}
}
}

private val Class<*>.kexTypeMockitoMockFixed: KexType
get() = when {
!kexConfig.isMockingEnabled || !kexConfig.isMockitoClassesWorkaroundEnabled -> this.kex

!this.name.containsMockitoMock -> this.kex
else -> KexClass(this.kex.name.removeMockitoMockSuffix())
}

fun convert(any: Any?, depth: Int = 0): Descriptor {
if (any == null) return `null`
if (any in objectToDescriptor) return objectToDescriptor[any]!!
Expand Down
Loading