Starlink / starjava

Java applications initially developed for the Starlink Project but now developed independently
Other
92 stars 24 forks source link

[util] test failure in testString #68

Open olebole opened 4 months ago

olebole commented 4 months ago

I just started to update the Debian packages to topcat-4.9.1 & co. (was delayed since Github removed the SVN access which I used to get individual starjava packages). In the "util" package, my build fails in the unit test step with

    [junit] Testcase: testString took 0.007 sec
    [junit]     FAILED
    [junit] expected:<$[?]?> but was:<$[]?>
    [junit] junit.framework.ComparisonFailure: expected:<$[?]?> but was:<$[]?>
    [junit]     at junit.framework.Assert.assertEquals(Assert.java:81)
    [junit]     at junit.framework.Assert.assertEquals(Assert.java:87)
    [junit]     at uk.ac.starlink.util.PrimitiveListTest.testString(PrimitiveListTest.java:150)
    [junit]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    [junit]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [junit]     at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    [junit]     at junit.framework.TestCase.runTest(TestCase.java:164)
    [junit]     at junit.framework.TestCase.runBare(TestCase.java:130)
    [junit]     at junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit]     at junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit]     at junit.framework.TestResult.run(TestResult.java:109)
    [junit]     at junit.framework.TestCase.run(TestCase.java:120)
    [junit]     at junit.framework.TestSuite.runTest(TestSuite.java:230)
    [junit]     at junit.framework.TestSuite.run(TestSuite.java:225)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:535)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1197)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:1042)
    [junit] 

BUILD FAILED
/build/starjava-util-1.0+2024.01.29/build.xml:932: Test uk.ac.starlink.util.PrimitiveListTest failed

which I do not fully understand. The test code here is https://github.com/Starlink/starjava/blob/a4447132ba0f5041f6cf95632575e39ae735e8fd/util/src/testcases/uk/ac/starlink/util/PrimitiveListTest.java#L146-L150

The used SDK is openjdk-17 (17.0.11) on Debian unstable.

mbtaylor commented 4 months ago

Hi @olebole, I don't understand it either. I can only imagine it's some kind of locale-related thing, though I really don't see how. I can't reproduce it using Oracle Java 17.0.6 with e.g. Locale.setDefault(Locale.GERMANY).

I've decorated the offending test method with some added some diagnostics to stdout. Could you try checking out branch issue68 from https://github.com/mbtaylor/starjava/ and telling me what the output looks like? What I see is this:

    [junit] ------------- Standard Output ---------------
    [junit] Locale: en_GB
    [junit] req: 
    [junit]     chr 0: 0x24     0x24    >$<
    [junit]     chr 1: 0xa3     0xa3    >£<
    [junit]     getBytes:       [36, -62, -93]
    [junit]     getBytes(UTF8)  [36, -62, -93]
    [junit] got: 
    [junit]     chr 0: 0x24     0x24    >$<
    [junit]     chr 1: 0xa3     0xa3    >£<
    [junit]     getBytes:       [36, -62, -93]
    [junit]     getBytes(UTF8)  [36, -62, -93]
    [junit] ------------- ---------------- ---------------

The getBytes: lines might differ, but the other three lines should be the same for req and got.