diff options
author | V3n3RiX <venerix@koprulu.sector> | 2022-04-06 22:33:41 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2022-04-06 22:33:41 +0100 |
commit | e68d405c5d712af4387159df07e226217bdda049 (patch) | |
tree | 009ab0f3d427f0813e62930d71802cb054c07e30 /dev-java/antlr-runtime | |
parent | 401101f9c8077911929d3f2b60a37098460a5d89 (diff) |
gentoo resync : 06.04.2022
Diffstat (limited to 'dev-java/antlr-runtime')
-rw-r--r-- | dev-java/antlr-runtime/Manifest | 3 | ||||
-rw-r--r-- | dev-java/antlr-runtime/antlr-runtime-4.9.3.ebuild | 105 | ||||
-rw-r--r-- | dev-java/antlr-runtime/files/4.9.3-test-fixes.patch | 26 |
3 files changed, 127 insertions, 7 deletions
diff --git a/dev-java/antlr-runtime/Manifest b/dev-java/antlr-runtime/Manifest index c0cc4328b691..759873917d40 100644 --- a/dev-java/antlr-runtime/Manifest +++ b/dev-java/antlr-runtime/Manifest @@ -1,5 +1,6 @@ +AUX 4.9.3-test-fixes.patch 1399 BLAKE2B 719571607153951b6a44a7bed7c405b6e217f7a458667388d89ca15683342a5d9849155ad03771eb0f7d326af31fd0cf6e0ab9ddfbd385e189b33f0c842ab53e SHA512 b0aed6d54873ffd841ae5ac6ce1afb5d037fdde6e322903e250e46b38b84fd29ca87668f8b1f38a5c6b0ec4ad99953021d4260b67515158accbc37fd325e98eb DIST antlr-4.9.3.tar.gz 4640242 BLAKE2B fb58f5e533051cb2c439c32f0462c1d463c99df862ba7e1a37a1c61378ab36a9edb9525c2a342de5b517da6f02d8291de5976c550932314f3464aad1a778afb9 SHA512 61452404c9639b5a0908cda16605f17c0fed0c9adfc3278c7408f9971420e9d1fe8f9e974e0826c2e3e780fdd83324094c0246cd5b28fa63f5686b094ea08127 DIST antlr-runtime-3.5.2-sources.jar 206095 BLAKE2B 62b5ca08b13b80e1cdfe82d7354f75dcd3d82d7618bb2d20c4973c0b588d60cc034a8bc265d1cba6b3fc09f5583450a48948dc0beb86c4b13c6b9fdb32de37fd SHA512 fda8b0b1d6f779098c885360ea5f5e93eac5153f5bf761f3dbc954209b69b76edd21a8e4915bb9e567e5c095f1d173e19429bea34da9698bf241d17599858847 EBUILD antlr-runtime-3.5.2.ebuild 1012 BLAKE2B 4bca36c4491f8e88fd31a8c270737d868b30465e7068db823a354e9dd0d611b19799101cdf448581e4551740f88f70708451f92c93ee9443eb6aab5b6c75e8b7 SHA512 1517b4284e15876a4a4c6dde04ea45410bb20b95f6a5d86c49f6c545bf48d774fcba54ff65a41ed585f440fe2e1f30fc96ab1b29061740e18727f4fd7b35b7d6 -EBUILD antlr-runtime-4.9.3.ebuild 929 BLAKE2B af9f6572ff15703e27f59e03cf151c0dc4c06bcfbcb95cb6a75b7d3162e9d538c502adc03d0bcc148bd56d0b1b3d636c8ab94a22058b91b7467538fbb7093581 SHA512 a577027d78dd7b091187f018e39444db8083417cb8d9beb273ef03862c7fe26de2a1422b2caae9bb62d1bbda194146f67a61091a4ff279f8703cd061cfc353cc +EBUILD antlr-runtime-4.9.3.ebuild 3856 BLAKE2B be2c41758da73c5158d30a692361eae45f3a5de9a1272d55b85289e1e47e1b29ed7f96c85cb635a6ac38792b8cd497da6e25b53c3b4d9199034c4bfe58bdb1a0 SHA512 8c6287ac52501f41ea0c486f94f4eb17d5be6d4014518ad436be609488944c08bbcbedd20cc54395a7856432f9cd99848aced53b9b162a06caf0d012774c6484 MISC metadata.xml 402 BLAKE2B 8a48b0d50a6356a3bf1f8f2545269d5d21b75af4ba38b07dea53d5660216a8580f5c87b58dc6c235c79f7b5d15f7e4f6925105a2402f557413cf942d21153686 SHA512 26faab37f0c4c1c44000705ee08ec536c6503b70d972b353fcebbd48236688f3d7b5604b2db55753a9b38ac5b86a2d214a937cc68676e1356bec00045cacfe2b diff --git a/dev-java/antlr-runtime/antlr-runtime-4.9.3.ebuild b/dev-java/antlr-runtime/antlr-runtime-4.9.3.ebuild index 31d041e6a974..cf26c16eb71e 100644 --- a/dev-java/antlr-runtime/antlr-runtime-4.9.3.ebuild +++ b/dev-java/antlr-runtime/antlr-runtime-4.9.3.ebuild @@ -3,13 +3,9 @@ EAPI=8 -# Without annotation processing using runtime-testsuite/processors, -# the tests are bound to fail. However, the annotation processor -# has been dropped from the 'master' branch as of January 2022, so -# when updating this package to a new upstream version, please -# check if it is possible to enable the tests and pass them. -JAVA_PKG_IUSE="doc source" +JAVA_PKG_IUSE="doc source test" MAVEN_ID="org.antlr:antlr4-runtime:4.9.3" +JAVA_TESTING_FRAMEWORKS="junit-4" inherit java-pkg-2 java-pkg-simple @@ -26,6 +22,10 @@ KEYWORDS="amd64 ~arm arm64 ppc64 x86" DEPEND=" >=virtual/jdk-1.8:* + test? ( + ~dev-java/antlr-tool-${PV}:${SLOT} + dev-java/jol-core:0 + ) " RDEPEND=" @@ -35,3 +35,96 @@ RDEPEND=" S="${WORKDIR}/${MY_PN}4-${PV}" JAVA_SRC_DIR="runtime/Java/src" + +JAVA_TEST_GENTOO_CLASSPATH=" + junit-4 + antlr-tool-${SLOT} + jol-core +" +JAVA_TEST_SRC_DIR=( + runtime-testsuite/test + runtime-testsuite/annotations +) +JAVA_TEST_RESOURCE_DIRS=( + runtime-testsuite/resources +) + +src_prepare() { + java-pkg_clean + eapply "${FILESDIR}/${PV}-test-fixes.patch" + java-pkg-2_src_prepare +} + +src_test() { + # Build classpath for tests + # The JAR created during src_compile must appear in the classpath *before* + # any dependencies to ensure that *it* is the JAR being tested; otherwise, + # because the test suite depends on antlr-tool, which depends on this + # package, the copy of this package's JAR installed on the system would be + # tested instead when it appears earlier in the classpath, which might + # cause test failures when the version being built differs from the version + # already installed on the system, like https://bugs.gentoo.org/834138 + local CP="${S}/${JAVA_JAR_FILENAME}" + local test_dep res_dir + for test_dep in ${JAVA_TEST_GENTOO_CLASSPATH}; do + CP+=":$(java-pkg_getjars --with-dependencies "${test_dep}")" + done + for res_dir in "${JAVA_TEST_RESOURCE_DIRS[@]}"; do + CP+=":${res_dir}" + done + + pushd "${JAVA_TEST_SRC_DIR[0]}" > /dev/null || + die "Failed to enter test source directory for ${PN}" + + einfo "Removing tests for non-Java runtimes ..." + find org/antlr/v4/test/runtime/* -maxdepth 0 -type d \ + -not -name category -not -name descriptors -not -name java \ + -exec einfo " {}" \; -exec rm -r "{}" + || + die "Failed to remove tests for non-Java runtimes" + + einfo "Generating ANTLR 4 parsers for tests ..." + local java_exe="$(java-config -J)" + local g4_files=( $(find * -name "*.g4") ) + local file + for file in "${g4_files[@]}"; do + local java_pkg="${file%/*.g4}" + java_pkg="${java_pkg//\//.}" + "${java_exe}" -cp "${CP}" org.antlr.v4.Tool \ + -visitor -package "${java_pkg}" "${file}" || + die "Failed to generate ANTLR 4 parser from ${file}" + done + + # Create a list of tests to run + # https://github.com/antlr/antlr4/blob/4.9.3/runtime-testsuite/pom.xml#L100 + # Excluding classes with "No runnable methods" + local TESTS=$(find * -type f -name "Test*.java" \ + -not -name "TestContext.java" \ + -not -name "TestOutputReading.java" + ) + TESTS="${TESTS//.java}" + TESTS="${TESTS//\//.}" + + popd > /dev/null || die "Failed to leave test source directory for ${PN}" + + local classes="target/classes" + + # Compile the annotation processor of @CommentHasStringValue + # before the test sources (requires tools.jar) + ejavac -d "${classes}" -cp "${CP}:$(java-config -t)" \ + $(find runtime-testsuite/{annotations,processors} -name "*.java") + local processor_cp="${classes}:runtime-testsuite/processors/resources" + + # Compile Java test sources, and process @CommentHasStringValue + # annotations at the same time + local javac_extra_args=() + if ver_test "$(java-config -g PROVIDES_VERSION)" -ge 17; then + javac_extra_args+=( + -J--add-opens=jdk.compiler/com.sun.tools.javac.{main,model,tree,util}=ALL-UNNAMED + ) + fi + ejavac -d "${classes}" -cp "${CP}:${processor_cp}" \ + "${javac_extra_args[@]}" \ + $(find "${JAVA_TEST_SRC_DIR[@]}" -name "*.java") + + ejunit4 -classpath "${classes}:${CP}" ${TESTS} +} diff --git a/dev-java/antlr-runtime/files/4.9.3-test-fixes.patch b/dev-java/antlr-runtime/files/4.9.3-test-fixes.patch new file mode 100644 index 000000000000..9cb6884ba194 --- /dev/null +++ b/dev-java/antlr-runtime/files/4.9.3-test-fixes.patch @@ -0,0 +1,26 @@ +From 3eabbddff69dcbcaf9a59f407cc8bef4be8e215b Mon Sep 17 00:00:00 2001 +From: Yuan Liao <liaoyuan@gmail.com> +Date: Thu, 3 Feb 2022 11:51:53 -0800 +Subject: [PATCH] Use 1.8 as javac -source/-target for running tests on Java 17 + +Signed-off-by: Yuan Liao <liaoyuan@gmail.com> +--- + .../test/org/antlr/v4/test/runtime/java/BaseJavaTest.java | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/java/BaseJavaTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/java/BaseJavaTest.java +index cc03bdc11..82061135e 100644 +--- a/runtime-testsuite/test/org/antlr/v4/test/runtime/java/BaseJavaTest.java ++++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/java/BaseJavaTest.java +@@ -137,7 +137,7 @@ public class BaseJavaTest extends BaseRuntimeTestSupport implements RuntimeTestS + fileManager.getJavaFileObjectsFromFiles(files); + + Iterable<String> compileOptions = +- Arrays.asList("-g", "-source", "1.6", "-target", "1.6", "-implicit:class", "-Xlint:-options", "-d", getTempDirPath(), "-cp", getTempDirPath() + PATH_SEP + CLASSPATH); ++ Arrays.asList("-g", "-source", "1.8", "-target", "1.8", "-implicit:class", "-Xlint:-options", "-d", getTempDirPath(), "-cp", getTempDirPath() + PATH_SEP + CLASSPATH); + + JavaCompiler.CompilationTask task = + compiler.getTask(null, fileManager, null, compileOptions, null, +-- +2.34.1 + |