1 |
|
# Copyright 1999-2022 Gentoo Authors
|
|
1 |
# Copyright 1999-2023 Gentoo Authors
|
2 |
2 |
# Distributed under the terms of the GNU General Public License v2
|
3 |
3 |
|
4 |
4 |
EAPI=8
|
5 |
5 |
|
6 |
|
JAVA_PKG_IUSE="doc source"
|
7 |
|
MAVEN_ID="org.mockito:mockito-core:1.9.5"
|
|
6 |
JAVA_PKG_IUSE="doc source test"
|
|
7 |
MAVEN_ID="org.mockito:mockito-core:${PV}"
|
|
8 |
JAVA_TESTING_FRAMEWORKS="junit-4"
|
8 |
9 |
|
9 |
10 |
inherit java-pkg-2 java-pkg-simple
|
10 |
11 |
|
11 |
|
DESCRIPTION="A mocking framework for Java"
|
|
12 |
DESCRIPTION="Mockito mock objects library core API and implementation"
|
12 |
13 |
HOMEPAGE="https://github.com/mockito/mockito"
|
13 |
|
SRC_URI="https://repo1.maven.org/maven2/org/mockito/mockito-core/${PV}/mockito-core-${PV}-sources.jar"
|
|
14 |
SRC_URI="https://github.com/mockito/mockito/archive/v${PV}.tar.gz -> ${P}.tar.gz"
|
|
15 |
S="${WORKDIR}/${P}"
|
14 |
16 |
|
15 |
17 |
LICENSE="MIT"
|
16 |
|
SLOT="0"
|
17 |
|
KEYWORDS="amd64 ~arm arm64 ppc64 x86"
|
|
18 |
SLOT="2"
|
|
19 |
KEYWORDS="amd64 ~arm ~arm64 ppc64 x86"
|
18 |
20 |
|
19 |
21 |
CP_DEPEND="
|
20 |
|
dev-java/ant-core:0
|
21 |
|
dev-java/hamcrest-core:0
|
22 |
|
dev-java/junit:4
|
|
22 |
dev-java/asm:9
|
|
23 |
dev-java/byte-buddy:0
|
23 |
24 |
dev-java/objenesis:0
|
24 |
25 |
"
|
25 |
|
DEPEND=">=virtual/jdk-1.8:*
|
26 |
|
${CP_DEPEND}"
|
27 |
|
RDEPEND=">=virtual/jre-1.8:*
|
28 |
|
${CP_DEPEND}"
|
29 |
|
BDEPEND="app-arch/unzip"
|
30 |
26 |
|
31 |
|
JAVADOC_ARGS="-source 8"
|
|
27 |
DEPEND="
|
|
28 |
dev-java/junit:4
|
|
29 |
dev-java/opentest4j:0
|
|
30 |
>=virtual/jdk-1.8:*
|
|
31 |
${CP_DEPEND}
|
|
32 |
test? ( dev-java/assertj-core:3 )
|
|
33 |
"
|
|
34 |
|
|
35 |
RDEPEND="
|
|
36 |
>=virtual/jre-1.8:*
|
|
37 |
${CP_DEPEND}
|
|
38 |
"
|
|
39 |
|
|
40 |
# see https://bugs.gentoo.org/903897
|
|
41 |
PATCHES=( "${FILESDIR}/mockito-2.28.2-skip-failing-tests.patch" )
|
|
42 |
|
|
43 |
JAVA_AUTOMATIC_MODULE_NAME="org.mockito"
|
|
44 |
JAVA_CLASSPATH_EXTRA="junit-4 opentest4j"
|
|
45 |
JAVA_SRC_DIR="src/main/java"
|
|
46 |
|
|
47 |
JAVA_TEST_EXCLUDES=(
|
|
48 |
org.mockito.internal.junit.JUnitRuleTest # We run it in JAVA_TEST_RUN_ONLY
|
|
49 |
org.mockito.internal.util.reflection.DummyClassForTests # No runnable methods
|
|
50 |
org.mockito.internal.util.reflection.DummyParentClassForTests # No runnable methods
|
|
51 |
org.mockito.junit.TestableJUnitRunner # No runnable methods
|
|
52 |
org.mockitoutil.TestBase # No runnable methods
|
|
53 |
)
|
|
54 |
JAVA_TEST_GENTOO_CLASSPATH="assertj-core-3,junit-4"
|
|
55 |
JAVA_TEST_RUN_ONLY=(
|
|
56 |
# This needs to run separately, otherwise one of its 4 tests would fail.
|
|
57 |
org.mockito.internal.junit.JUnitRuleTest
|
|
58 |
)
|
|
59 |
JAVA_TEST_SRC_DIR="src/test/java"
|
|
60 |
|
|
61 |
src_prepare() {
|
|
62 |
java-pkg-2_src_prepare
|
|
63 |
default
|
|
64 |
# dev-java/byte-buddy is built from byte-buddy-dep without shaded stuff.
|
|
65 |
sed \
|
|
66 |
-e 's:net.bytebuddy.jar.asm:org.objectweb.asm:' \
|
|
67 |
-i src/main/java/org/mockito/internal/creation/bytebuddy/MockMethodAdvice.java \
|
|
68 |
-i src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java || die
|
|
69 |
}
|
|
70 |
|
|
71 |
src_compile() {
|
|
72 |
java-pkg-simple_src_compile
|
|
73 |
mv target/classes/org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.{class,raw} || die
|
|
74 |
jar ufv mockito.jar -C target/classes org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.raw || die
|
|
75 |
}
|
|
76 |
|
|
77 |
src_test() {
|
|
78 |
# Increasing number of test failures with higher Java versions
|
|
79 |
# Test failures are documented in https://bugs.gentoo.org/903897
|
|
80 |
local vm_version="$(java-config -g PROVIDES_VERSION)"
|
|
81 |
if ver_test "${vm_version}" -ge 11; then
|
|
82 |
JAVA_TEST_EXCLUDES+=(
|
|
83 |
org.mockito.internal.stubbing.defaultanswers.ReturnsMocksTest
|
|
84 |
org.mockitousage.bugs.GenericsMockitoAnnotationsTest
|
|
85 |
)
|
|
86 |
fi
|
|
87 |
if ver_test "${vm_version}" -ge 17; then
|
|
88 |
JAVA_TEST_EXCLUDES+=(
|
|
89 |
org.concurrentmockito.ThreadsRunAllTestsHalfManualTest
|
|
90 |
org.mockitousage.matchers.InvalidUseOfMatchersTest
|
|
91 |
org.mockitousage.serialization.DeepStubsSerializableTest
|
|
92 |
org.mockitousage.stubbing.StubbingWithDelegateTest
|
|
93 |
)
|
|
94 |
JAVA_TEST_EXTRA_ARGS+=( --add-opens=java.base/java.io=ALL-UNNAMED )
|
|
95 |
JAVA_TEST_EXTRA_ARGS+=( --add-opens=java.base/java.lang=ALL-UNNAMED )
|
|
96 |
JAVA_TEST_EXTRA_ARGS+=( --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED )
|
|
97 |
fi
|
|
98 |
# First run what needs to run separately
|
|
99 |
java-pkg-simple_src_test
|
|
100 |
# And then the other tests
|
|
101 |
JAVA_TEST_RUN_ONLY=""
|
|
102 |
java-pkg-simple_src_test
|
|
103 |
}
|