unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#56112] [PATCH] gnu: Add java-lambdatest
@ 2022-06-20 19:26 Artyom V. Poptsov
  2022-07-03 12:42 ` Julien Lepiller
  2024-01-24 12:49 ` Sharlatan Hellseher
  0 siblings, 2 replies; 4+ messages in thread
From: Artyom V. Poptsov @ 2022-06-20 19:26 UTC (permalink / raw)
  To: 56112


[-- Attachment #1.1: Type: text/plain, Size: 157 bytes --]

Hello,

this patch adds "LambdaTest" under the name "java-lambdatest". [1]

"LambdaTest" package is required to pack "java-cmdoption" [2] package
properly.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-java-lambdatest.patch --]
[-- Type: text/x-diff, Size: 5785 bytes --]

From 2eff8e7fc79336f6eb7795fd942daeb07da63f00 Mon Sep 17 00:00:00 2001
From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
Date: Mon, 20 Jun 2022 22:06:28 +0300
Subject: [PATCH] gnu: Add java-lambdatest

* gnu/packages/java.scm (java-lambdatest): New variable.
* gnu/packages/patches/java-lambdatest-fix.patch: Add to the repository.
* gnu/local.mk (dist_patch_DATA): Add 'java-lambdatest-fix.patch'.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/java.scm                         | 56 +++++++++++++++++++
 .../patches/java-lambdatest-fix.patch         | 29 ++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 gnu/packages/patches/java-lambdatest-fix.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 197c8679eb..2f0a187125 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1321,6 +1321,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/java-commons-collections-fix-java8.patch \
   %D%/packages/patches/java-commons-lang-fix-dependency.patch \
   %D%/packages/patches/java-jeromq-fix-tests.patch		\
+  %D%/packages/patches/java-lambdatest-fix.patch		\
   %D%/packages/patches/java-openjfx-build-jdk_version.patch     \
   %D%/packages/patches/java-powermock-fix-java-files.patch		\
   %D%/packages/patches/java-simple-xml-fix-tests.patch		\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 7b0507d93c..794ccf22f7 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -14282,3 +14282,59 @@ The following TLA+ tools are available in this distribution:
 @item The PlusCal translator.
 @end itemize")
       (license license:expat))))
+
+(define-public java-lambdatest
+  (package
+    (name "java-lambdatest")
+    (version "0.7.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/lefou/LambdaTest")
+                    (commit version)))
+              (patches
+               (search-patches "java-lambdatest-fix.patch"))
+              (sha256
+               (base32
+                "172wz2cxrwganx0xwx395z627ph9b20hj8mw21fygq8hwcvmy94m"))))
+    (build-system ant-build-system)
+    (native-inputs (list openjdk11 java-logback-classic java-logback-core))
+    (inputs (list java-junit
+                  java-slf4j-api
+                  java-testng))
+    (arguments
+     `(#:jar-name "lambdatest.jar"
+       #:source-dir "src/main"
+       #:test-dir   "src/test"
+       #:jdk ,openjdk11
+       #:phases (modify-phases %standard-phases
+                  (replace 'check
+                    (lambda _
+                      (invoke "ant" "compile-tests")
+                      (let ((tests (filter
+                                    (lambda (file-name)
+                                      ;; Remove non-working tests.
+                                      (not (string-contains file-name
+                                                            "RuntimeTest")))
+                                    (find-files "build" ".*Test.class")))
+                            (classpath (string-append
+                                        (getenv "CLASSPATH")
+                                        ":build/classes"
+                                        ":build/test-classes")))
+                        (catch #t
+                          (lambda _
+                            (invoke "java"
+                                    "-cp" classpath
+                                    "org.testng.TestNG" "-testclass"
+                                    (string-join tests ",")))
+                          (lambda (exception c)
+                            ;; XXX: TestNG exits with exit code 2 when some
+                            ;; tests are skipped.  Just ignore this.
+                            (unless (= (invoke-error-exit-status c) 2)
+                              (throw exception c))
+                            #t))))))))
+    (home-page "https://github.com/lefou/LambdaTest")
+    (synopsis "Functional testing API on top of JUnit and TestNG")
+    (description "Lambda-enabled functional testing on top of JUnit and
+TestNG.")
+    (license license:asl2.0)))
diff --git a/gnu/packages/patches/java-lambdatest-fix.patch b/gnu/packages/patches/java-lambdatest-fix.patch
new file mode 100644
index 0000000000..e04ff0471f
--- /dev/null
+++ b/gnu/packages/patches/java-lambdatest-fix.patch
@@ -0,0 +1,29 @@
+From 49645c94fc8bdbea342d6f96d46e0405b81b874c Mon Sep 17 00:00:00 2001
+From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
+Date: Sun, 19 Jun 2022 23:11:42 +0300
+Subject: [PATCH] test: Fix tests
+
+* src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
+  (testAssertEqualsInteger): Fix a regex so it will match the actual test
+  output.
+
+---
+ src/test/java/de/tobiasroeser/lambdatest/AssertTest.java | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java b/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
+index fe2db12..5ef5ab3 100644
+--- a/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
++++ b/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
+@@ -51,7 +51,7 @@ public class AssertTest {
+ 		Assert.assertEquals(0, 0);
+ 		Assert.assertEquals(Integer.valueOf(0), 0);
+ 		Assert.assertEquals(0, Integer.valueOf(0));
+-		intercept(AssertionError.class, "\\QActual 0 is not equal to 1.\\E", () -> {
++		intercept(AssertionError.class, "\\QActual false is not equal to true\\E", () -> {
+ 			Assert.assertEquals(0, 1);
+ 		});
+ 		intercept(AssertionError.class, "\\QActual 0 is not equal to 1.\\E", () -> {
+-- 
+2.25.1
+
-- 
2.25.1


[-- Attachment #1.3: Type: text/plain, Size: 557 bytes --]


Thanks,

- Artyom

References:
1. LambdaTest - Lambda-enabled functional testing API on top of JUnit
   and TestNG
   <https://github.com/lefou/LambdaTest>
2. CmdOption is a simple annotation-driven command line parser toolkit
   for Java 6+ applications that is configured through annotations.
   <https://github.com/ToToTec/CmdOption>

-- 
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
Home page: https://memory-heap.org/~avp/
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE  B57C E9C5 A2D9 0898 A02F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#56112] [PATCH] gnu: Add java-lambdatest
  2022-06-20 19:26 [bug#56112] [PATCH] gnu: Add java-lambdatest Artyom V. Poptsov
@ 2022-07-03 12:42 ` Julien Lepiller
  2022-07-24  8:22   ` Artyom V. Poptsov
  2024-01-24 12:49 ` Sharlatan Hellseher
  1 sibling, 1 reply; 4+ messages in thread
From: Julien Lepiller @ 2022-07-03 12:42 UTC (permalink / raw)
  To: Artyom V. Poptsov; +Cc: 56112

Thanks for the patch, and sorry for the late reply.

Here are a few remarks:

Le Mon, 20 Jun 2022 22:26:10 +0300,
"Artyom V. Poptsov" <poptsov.artyom@gmail.com> a écrit :

> From 2eff8e7fc79336f6eb7795fd942daeb07da63f00 Mon Sep 17 00:00:00 2001
> From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
> Date: Mon, 20 Jun 2022 22:06:28 +0300
> Subject: [PATCH] gnu: Add java-lambdatest
> 
> * gnu/packages/java.scm (java-lambdatest): New variable.
> * gnu/packages/patches/java-lambdatest-fix.patch: Add to the
> repository.

that should be "New file."

> * gnu/local.mk (dist_patch_DATA): Add 'java-lambdatest-fix.patch'.

and here: "Add it."

> ---
>  gnu/local.mk                                  |  1 +
>  gnu/packages/java.scm                         | 56
> +++++++++++++++++++ .../patches/java-lambdatest-fix.patch         |
> 29 ++++++++++ 3 files changed, 86 insertions(+)
>  create mode 100644 gnu/packages/patches/java-lambdatest-fix.patch
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 197c8679eb..2f0a187125 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1321,6 +1321,7 @@ dist_patch_DATA =
> 			\
> %D%/packages/patches/java-commons-collections-fix-java8.patch \
> %D%/packages/patches/java-commons-lang-fix-dependency.patch \
> %D%/packages/patches/java-jeromq-fix-tests.patch		\
> +  %D%/packages/patches/java-lambdatest-fix.patch		\
>    %D%/packages/patches/java-openjfx-build-jdk_version.patch     \
>    %D%/packages/patches/java-powermock-fix-java-files.patch
> 	\ %D%/packages/patches/java-simple-xml-fix-tests.patch
> 	\ diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
> index 7b0507d93c..794ccf22f7 100644
> --- a/gnu/packages/java.scm
> +++ b/gnu/packages/java.scm
> @@ -14282,3 +14282,59 @@ The following TLA+ tools are available in
> this distribution: @item The PlusCal translator.
>  @end itemize")
>        (license license:expat))))
> +
> +(define-public java-lambdatest
> +  (package
> +    (name "java-lambdatest")
> +    (version "0.7.1")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/lefou/LambdaTest")
> +                    (commit version)))

When adding a git source, you need to add this from to the origin
record:

(file-name (git-file-name name version))

This ensures that the source name is correlated with the package. So
when you change the version and forget to update the hash, it will fail
instead of successfully using the old version's source.

> +              (patches
> +               (search-patches "java-lambdatest-fix.patch"))
> +              (sha256
> +               (base32
> +
> "172wz2cxrwganx0xwx395z627ph9b20hj8mw21fygq8hwcvmy94m"))))
> +    (build-system ant-build-system)
> +    (native-inputs (list openjdk11 java-logback-classic
> java-logback-core))

You don't need openjdk11 here. It's already added implicitely by #:jdk
below, and openjdk11 contains only the Java runtime, not the compiler.
You'd need (list openjdk11 "jdk").

> +    (inputs (list java-junit
> +                  java-slf4j-api
> +                  java-testng))
> +    (arguments
> +     `(#:jar-name "lambdatest.jar"
> +       #:source-dir "src/main"
> +       #:test-dir   "src/test"
> +       #:jdk ,openjdk11

Using openjdk11 here will create warnings in dependents I think. Are
you sure we really need to use it?

> +       #:phases (modify-phases %standard-phases
> +                  (replace 'check
> +                    (lambda _
> +                      (invoke "ant" "compile-tests")
> +                      (let ((tests (filter
> +                                    (lambda (file-name)
> +                                      ;; Remove non-working tests.
> +                                      (not (string-contains file-name
> +
> "RuntimeTest")))
> +                                    (find-files "build"
> ".*Test.class")))

This is not very encouraging. We're supposed to build the runtimes, yet
we remove all runtime tests? Do you know what's happening and why they
are failing? Did you still manage to run tests that use this package?

> +                            (classpath (string-append
> +                                        (getenv "CLASSPATH")
> +                                        ":build/classes"
> +                                        ":build/test-classes")))
> +                        (catch #t
> +                          (lambda _
> +                            (invoke "java"
> +                                    "-cp" classpath
> +                                    "org.testng.TestNG" "-testclass"
> +                                    (string-join tests ",")))

I think TestNG will use an xml file if you provide it, though I don't
see one in the repo. Do you know how upstream runs their tests?

> +                          (lambda (exception c)
> +                            ;; XXX: TestNG exits with exit code 2
> when some
> +                            ;; tests are skipped.  Just ignore this.
> +                            (unless (= (invoke-error-exit-status c)
> 2)
> +                              (throw exception c))
> +                            #t))))))))

No need to end the phase in #t.

> +    (home-page "https://github.com/lefou/LambdaTest")
> +    (synopsis "Functional testing API on top of JUnit and TestNG")
> +    (description "Lambda-enabled functional testing on top of JUnit
> and +TestNG.")

Description should contain full sentences.

> +    (license license:asl2.0)))
> diff --git a/gnu/packages/patches/java-lambdatest-fix.patch
> b/gnu/packages/patches/java-lambdatest-fix.patch new file mode 100644
> index 0000000000..e04ff0471f
> --- /dev/null
> +++ b/gnu/packages/patches/java-lambdatest-fix.patch
> @@ -0,0 +1,29 @@
> +From 49645c94fc8bdbea342d6f96d46e0405b81b874c Mon Sep 17 00:00:00
> 2001 +From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
> +Date: Sun, 19 Jun 2022 23:11:42 +0300
> +Subject: [PATCH] test: Fix tests
> +
> +* src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
> +  (testAssertEqualsInteger): Fix a regex so it will match the actual
> test
> +  output.
> +
> +---
> + src/test/java/de/tobiasroeser/lambdatest/AssertTest.java | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git
> a/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java
> b/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java +index
> fe2db12..5ef5ab3 100644 +---
> a/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java ++++
> b/src/test/java/de/tobiasroeser/lambdatest/AssertTest.java +@@ -51,7
> +51,7 @@ public class AssertTest {
> + 		Assert.assertEquals(0, 0);
> + 		Assert.assertEquals(Integer.valueOf(0), 0);
> + 		Assert.assertEquals(0, Integer.valueOf(0));
> +-		intercept(AssertionError.class, "\\QActual 0 is not
> equal to 1.\\E", () -> { ++
> intercept(AssertionError.class, "\\QActual false is not equal to
> true\\E", () -> {
> + 			Assert.assertEquals(0, 1);
> + 		});
> + 		intercept(AssertionError.class, "\\QActual 0 is not
> equal to 1.\\E", () -> { +-- 
> +2.25.1
> +





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#56112] [PATCH] gnu: Add java-lambdatest
  2022-07-03 12:42 ` Julien Lepiller
@ 2022-07-24  8:22   ` Artyom V. Poptsov
  0 siblings, 0 replies; 4+ messages in thread
From: Artyom V. Poptsov @ 2022-07-24  8:22 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: 56112

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

Hello.

> Using openjdk11 here will create warnings in dependents I think. Are
> you sure we really need to use it?

Unfortunately when the JDK version is not specified I get errors like
this one during the "check" phase:

--8<---------------cut here---------------start------------->8---
starting phase `check'
Buildfile: /tmp/guix-build-java-lambdatest-0.7.1.drv-0/source/build.xml

compile-tests:
    [mkdir] Created dir: /tmp/guix-build-java-lambdatest-0.7.1.drv-0/source/build/test-classes
    [javac] Compiling 13 source files to /tmp/guix-build-java-lambdatest-0.7.1.drv-0/source/build/test-classes
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.

BUILD SUCCESSFUL
Total time: 0 seconds
[TestNG] [ERROR] 
An error occurred while instantiating class de.tobiasroeser.lambdatest.ExpectCollectionTest: org/slf4j/impl/StaticLoggerBinder has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
--8<---------------cut here---------------end--------------->8---

- Artyom

-- 
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
Home page: https://memory-heap.org/~avp/
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE  B57C E9C5 A2D9 0898 A02F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 519 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#56112] [PATCH] gnu: Add java-lambdatest
  2022-06-20 19:26 [bug#56112] [PATCH] gnu: Add java-lambdatest Artyom V. Poptsov
  2022-07-03 12:42 ` Julien Lepiller
@ 2024-01-24 12:49 ` Sharlatan Hellseher
  1 sibling, 0 replies; 4+ messages in thread
From: Sharlatan Hellseher @ 2024-01-24 12:49 UTC (permalink / raw)
  To: 56112

[-- Attachment #1: Type: text/plain, Size: 91 bytes --]


Hi Artyom,

Is it still actual, let's prepare v2 for the next review round?

Thanks,
Oleg

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-24 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 19:26 [bug#56112] [PATCH] gnu: Add java-lambdatest Artyom V. Poptsov
2022-07-03 12:42 ` Julien Lepiller
2022-07-24  8:22   ` Artyom V. Poptsov
2024-01-24 12:49 ` Sharlatan Hellseher

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).