Both suggest a mixup of versions, combining a wrong version of libswipl.so, jpl.so and/or jpl.jar. Maybe some environment variable leading to an old version, an old file copied to place where it is first found by the dynamic linker or Java, etc.
Of course it can be something else. So far these tests passed for the most recent build on all platforms.
Thanks, the jpl submodule had not updated properly. Now I am getting a new error:
ctest -j 8 -V -R '.*java.*'  07:02:31  ✔ 0
UpdateCTestConfiguration from :/home/u/tmp/swipl-devel/build.release/DartConfiguration.tcl
UpdateCTestConfiguration from :/home/u/tmp/swipl-devel/build.release/DartConfiguration.tcl
Test project /home/u/tmp/swipl-devel/build.release
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 64
Start 64: jpl:prolog_in_java
64: Test command: /usr/sbin/env "SWI_HOME_DIR=../../home" "SWIPL_BOOT_FILE=../../home/boot.prc" "TEST_JPL=../../../packages/jpl/test_jpl.pl" "/usr/sbin/java" "-Djava.library.path=." "-classpath" "/usr/share/java/junit.jar:src/java/jpl.jar:src/java/jpltest.jar" "org.jpl7.test.TestJUnit4"
64: Test timeout computed to be: 10000000
test 65
Start 65: jpl:java_in_prolog
65: Test command: /home/u/tmp/swipl-devel/build.release/src/swipl "-p" "foreign=:/home/u/tmp/swipl-devel/build.release/packages/plunit" "-f" "none" "--no-packs" "-s" "/home/u/tmp/swipl-devel/packages/jpl/test_jpl.pl" "-g" "test_jpl" "-t" "halt"
65: Test timeout computed to be: 10000000
64: JUnit version 4.12
64: Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
64: at java.base/java.lang.ClassLoader.defineClass1(Native Method)
64: at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
64: at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
64: at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
64: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
64: at org.junit.runner.Computer.getSuite(Computer.java:28)
64: at org.junit.runner.Request.classes(Request.java:75)
64: at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:118)
64: at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
64: at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
64: at org.jpl7.test.TestJUnit4.main(TestJUnit4.java:37)
64: Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
64: at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
64: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
64: ... 15 more
1/2 Test #64: jpl:prolog_in_java ...............***Failed 0.11 sec
65: % PL-Unit: jpl .......................................................................................... done
65: % 3 tests are blocked:
65: % /home/u/tmp/swipl-devel/packages/jpl/test_jpl.pl:610:
65: test method_static_echo_float_4: we do not yet widen unbounded integers to floats or doubles
65: % /home/u/tmp/swipl-devel/packages/jpl/test_jpl.pl:914:
65: test set_field_static_shadow_1: we do not yet resolve same-named shadowed fields
65: % /home/u/tmp/swipl-devel/packages/jpl/test_jpl.pl:1193:
65: test throw_java_exception_1: part of the error term is nondeterministic: we need to match with _
65: % 90 tests passed
2/2 Test #65: jpl:java_in_prolog ............... Passed 0.55 sec
The following tests passed:
jpl:java_in_prolog
50% tests passed, 1 tests failed out of 2
Total Test time (real) = 0.56 sec
The following tests FAILED:
64 - jpl:prolog_in_java (Failed)
Errors while running CTest
It happens because JUnit 4.11 and above require hamcrest-core.jar in the class path, as shown in this stackoverflow question. I do have it:
$ ls -al /usr/share/java/hamcrest-core.jar
lrwxrwxrwx 21 root 5 Jun 2018 /usr/share/java/hamcrest-core.jar -> hamcrest/core-1.3.jar
but it is not included in the classpath (from the error above):
Thanks for pointing this out; I recently updated JPL and migrated JUnit from v3 to v4, and also clean that up a lot (still a much bigger clean-up and restructuring is in a branch)
You are right that JUnit4 seems to require hamcrest-core.jar, and I do have it in my system as you but the test passes well (or any individual call via Java) without that being in the classpath…
Need to investigate, I have re-opened issue #40 related to this transition:
JUnit4 needs hamcrest-core.jar and I have them both in /usr/share/java.
What I find strange in your trace is that it is looking for /usr/share/java/junit.jar which is not correct as that is v3. It should look for /usr/share/java/junit4.jar and then it will pick up the dependency automatically.
I did modify the framework to look for junit4.jar and not junit.jar, not sure why your system is picking that one up instead:
Since you seem to have a development version of SWI-JPL, maybe you want to try the latest junit4 branch which has the tests in better shape? I am curious if it also picks up junit.jar
$ ls -al /usr/share/java/junit.jar
lrwxrwxrwx 14 root 4 Jun 2018 /usr/share/java/junit.jar -> junit-4.12.jar
As you can see junit.jar is a symlink to junit-4.12.jar. This is done automatically by the archlinux package management system.
Perhaps you could modify the cmake script to find any file with the regex patern junit.?4.*\.jar
This would match both junit4.jar and junit-4.12.jar, I’ll be happy to test that.
ahh I see, great stuff you gave me. OK I have followed your advice and now search for those patters for junit. Unfortunately GLOB for CMAKE does not find files by regexp so it was a bit more explicit but should work.
Would you be able to test branch enhacement/junit4 to see if it works? It also contains all the tests much better organized in test suites (and additional tests that were standalone tests), so don’t be alarmed if you see a much verbose output when you run the test!
Let me know how it goes. And if it works I will make a PR to go into master.
With that branch, jpl does not build, I am getting this error:
$ ninja
[882/2399] Building Java objects for jpl_jar.jar
Note: org/jpl7/fli/atom_t.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[889/2399] Building Java objects for jpltest.jar
FAILED: packages/jpl/src/java/CMakeFiles/jpltest.dir/java_compiled_jpltest
cd /home/u1/tmp/swipl-devel/packages/jpl/src/java && /usr/sbin/javac -classpath :/home/u1/tmp/swipl-devel/packages/jpl/src/java:/home/u1/tmp/swipl-devel/build.release/packages/jpl/src/java:/usr/share/java/junit-4.12.jar -d /home/u1/tmp/swipl-devel/build.release/packages/jpl/src/java/CMakeFiles/jpltest.dir @/home/u1/tmp/swipl-devel/build.release/packages/jpl/src/java/CMakeFiles/jpltest.dir/java_sources && /usr/bin/cmake -E touch /home/u1/tmp/swipl-devel/build.release/packages/jpl/src/java/CMakeFiles/jpltest.dir/java_compiled_jpltest
org/jpl7/test/JPLTestSuite.java:21: error: cannot find symbol
org.jpl7.test.junit.RationalTest.class,
^
symbol: class RationalTest
location: package org.jpl7.test.junit
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
[898/2399] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/pqConsole.cpp.o
ninja: build stopped: subcommand failed.
ctest -j 8 -V -R '.*java.*'
UpdateCTestConfiguration from :/home/u1/tmp/swipl-devel/build.release/DartConfiguration.tcl
UpdateCTestConfiguration from :/home/u1/tmp/swipl-devel/build.release/DartConfiguration.tcl
Test project /home/u1/tmp/swipl-devel/build.release
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 64
Start 64: jpl:prolog_in_java
64: Test command: /usr/sbin/env "CLASSPATH=src/java/jpl.jar" "SWI_HOME_DIR=../../home" "SWIPL_BOOT_FILE=../../home/boot.prc" "TEST_FILE=/home/u1/tmp/swipl-devel/packages/jpl/../../packages/jpl/src/java/org/jpl7/test/test_jpl.pl" "TEST_DIR=/home/u1/tmp/swipl-devel/packages/jpl/../../packages/jpl/src/java/org/jpl7/test" "/usr/sbin/java" "-Djava.library.path=." "-classpath" "/usr/share/java/junit-4.12.jar:src/java/jpl.jar:src/java/jpltest.jar" "org.jpl7.test.JPLTestSuiteRunner"
64: Test timeout computed to be: 10000000
test 65
Start 65: jpl:java_in_prolog
65: Test command: /home/u1/tmp/swipl-devel/build.release/src/swipl "-p" "foreign=:/home/u1/tmp/swipl-devel/build.release/packages/plunit" "-f" "none" "--no-packs" "-s" "/home/u1/tmp/swipl-devel/packages/jpl/test_jpl.pl" "-g" "test_jpl" "-t" "halt"
65: Test timeout computed to be: 10000000
65: ERROR: Prolog initialisation failed:
65: ERROR: script_file `'/home/u1/tmp/swipl-devel/packages/jpl/test_jpl.pl'' does not exist
1/2 Test #65: jpl:java_in_prolog ...............***Failed 0.02 sec
64: Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
64: at java.base/java.lang.ClassLoader.defineClass1(Native Method)
64: at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
64: at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
64: at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
64: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
64: at org.junit.runner.Computer.getSuite(Computer.java:28)
64: at org.junit.runner.Request.classes(Request.java:75)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:62)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:49)
64: at org.jpl7.test.JPLTestSuiteRunner.main(JPLTestSuiteRunner.java:10)
64: Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
64: at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
64: at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
64: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
64: ... 15 more
2/2 Test #64: jpl:prolog_in_java ...............***Failed 0.10 sec
0% tests passed, 2 tests failed out of 2
Total Test time (real) = 0.10 sec
The following tests FAILED:
64 - jpl:prolog_in_java (Failed)
65 - jpl:java_in_prolog (Failed)
Errors while running CTest
As you can see it does recognize the junit-4.12.jar - so your fix for that is working; but it does not add the hamcrest-core.jar file to the class path.
My hamcrest-core.jar is in /usr/share/java (it is a symlink):
$ ls /usr/share/java/hamcrest-core.jar
/usr/share/java/hamcrest-core.jar
Thanks! It found the hamcrest jar now. Now I get this error:
[...]
test 64
Start 64: jpl:prolog_in_java
64: Test command: /usr/sbin/env "CLASSPATH=src/java/jpl.jar" "SWI_HOME_DIR=../../home" "SWIPL_BOOT_FILE=../../home/boot.prc" "TEST_FILE=/home/u1/tmp/swipl-devel/packages/jpl/../../packages/jpl/src/java/org/jpl7/test/test_jpl.pl" "TEST_DIR=/home/u1/tmp/swipl-devel/packages/jpl/../../packages/jpl/src/java/org/jpl7/test" "/usr/sbin/java" "-Djava.library.path=." "-classpath" "/usr/share/java/junit-4.12.jar:/usr/share/java/hamcrest-core.jar:src/java/jpl.jar:src/java/jpltest.jar" "org.jpl7.test.JPLTestSuiteRunner"
64: Test timeout computed to be: 10000000
65: ERROR: Prolog initialisation failed:
65: ERROR: script_file '/home/u1/tmp/swipl-devel/packages/jpl/test_jpl.pl' does not exist
1/2 Test #65: jpl:java_in_prolog ...............***Failed 0.02 sec
[...]
2/2 Test #64: jpl:prolog_in_java ............... Passed 0.58 sec
The following tests passed:
jpl:prolog_in_java
50% tests passed, 1 tests failed out of 2
Total Test time (real) = 0.59 sec
The following tests FAILED:
65 - jpl:java_in_prolog (Failed)
Errors while running CTest
It seems it can’t find test_jpl.pl. The file does not exist in the cmake build directory, but it is found in the original src directory:
Hi. Thanks for running it quickly, it helps me a lot.
Yes test_jpl.pl is in the original source dir. I have fixed and simplified the dir and TEST_FILE was not needed. Strange why it didn’t give me error here, but the path is anyways way too complicated as it is.
can you pull and try? Seems we are making together prioress step-by-step! THANKS!
Note that the test_lib CMake function from SWI-Prolog does not use the TEST_DIR parameter, it uses the following to figure out the prolog source file for testing:
So it was not a good idea to move test_jpl.pl inside the source tree, as it does not follow the “standard” for test_xxx.pl on all the other packages.
I reverted that back and adapted all tests. Hopefully this will work on both tests for you, let me know! Thanks!
The following tests passed:
jpl:prolog_in_java
jpl:java_in_prolog
100% tests passed, 0 tests failed out of 2
Although some exceptions are thrown:
[...]
64: Starting test: testOpenGetClose1 (Tests)
64: Starting test: testOpenGetClose2 (Tests)
64: org.jpl7.test.junit.JRef: PrologException: error(existence_error(source_sink, 'test_jpl.pl'), _83)
64: org.jpl7.PrologException: PrologException: error(existence_error(source_sink, 'test_jpl.pl'), _83)
64: at org.jpl7.Query.fetchNextSolution(Query.java:437)
64: at org.jpl7.Query.hasMoreSolutions(Query.java:341)
64: at org.jpl7.Query.oneSolution(Query.java:815)
64: at org.jpl7.Query.hasSolution(Query.java:893)
64: at org.jpl7.test.junit.JPLTest.consultTestFile(JPLTest.java:77)
64: at org.jpl7.test.junit.JRef.setUp(JRef.java:36)
64: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
64: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
64: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
64: at java.base/java.lang.reflect.Method.invoke(Method.java:567)
64: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
64: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
64: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
64: at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runners.Suite.runChild(Suite.java:128)
64: at org.junit.runners.Suite.runChild(Suite.java:27)
64: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
64: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
64: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
64: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
64: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runners.Suite.runChild(Suite.java:128)
64: at org.junit.runners.Suite.runChild(Suite.java:27)
64: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
64: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
64: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
64: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
64: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:62)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:49)
64: at org.jpl7.test.JPLTestSuiteRunner.main(JPLTestSuiteRunner.java:10)
64: org.jpl7.test.junit.MutualRecursion: PrologException: error(existence_error(source_sink, 'test_jpl.pl'), _87)
64: org.jpl7.PrologException: PrologException: error(existence_error(source_sink, 'test_jpl.pl'), _87)
64: at org.jpl7.Query.fetchNextSolution(Query.java:437)
64: at org.jpl7.Query.hasMoreSolutions(Query.java:341)
64: at org.jpl7.Query.oneSolution(Query.java:815)
64: at org.jpl7.Query.hasSolution(Query.java:893)
64: at org.jpl7.test.junit.JPLTest.consultTestFile(JPLTest.java:77)
64: at org.jpl7.test.junit.MutualRecursion.setUp(MutualRecursion.java:35)
64: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
64: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
64: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
64: at java.base/java.lang.reflect.Method.invoke(Method.java:567)
64: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
64: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
64: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
64: at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runners.Suite.runChild(Suite.java:128)
64: at org.junit.runners.Suite.runChild(Suite.java:27)
64: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
64: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
64: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
64: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
64: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runners.Suite.runChild(Suite.java:128)
64: at org.junit.runners.Suite.runChild(Suite.java:27)
64: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
64: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
64: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
64: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
64: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
64: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
64: at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:62)
64: at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:49)
64: at org.jpl7.test.JPLTestSuiteRunner.main(JPLTestSuiteRunner.java:10)
64: ********* Test successful? false