[Git][java-team/groovy][master] 6 commits: Fix FTBFS with JANSI 2.4.0

Markus Koschany (@apo) gitlab at salsa.debian.org
Sat Jun 25 22:10:31 BST 2022



Markus Koschany pushed to branch master at Debian Java Maintainers / groovy


Commits:
194decb7 by Markus Koschany at 2022-06-25T21:46:36+02:00
Fix FTBFS with JANSI 2.4.0

Closes: #1013355

- - - - -
82984072 by Markus Koschany at 2022-06-25T21:47:30+02:00
Switch to debhelper-compat = 13.

- - - - -
527165f3 by Markus Koschany at 2022-06-25T21:47:46+02:00
Declare compliance with Debian Policy 4.6.1.

- - - - -
421cbbd4 by Markus Koschany at 2022-06-25T21:48:03+02:00
Update changelog

- - - - -
869ae184 by Markus Koschany at 2022-06-25T22:38:12+02:00
Update to JLine2 >= 2.13

- - - - -
d6c532da by Markus Koschany at 2022-06-25T22:57:58+02:00
Disable the tests for now

- - - - -


7 changed files:

- debian/changelog
- − debian/compat
- debian/control
- + debian/patches/remove-GroovyDoc-JANSI-dependency.patch
- debian/patches/series
- + debian/patches/update-to-JLine2-2.13.patch
- debian/rules


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+groovy (2.4.21-2) unstable; urgency=medium
+
+  * Team upload.
+  * Fix FTBFS with JANSI 2.4.0. (Closes: #1013355)
+  * Switch to debhelper-compat = 13.
+  * Declare compliance with Debian Policy 4.6.1.
+
+ -- Markus Koschany <apo at debian.org>  Sat, 25 Jun 2022 21:47:51 +0200
+
 groovy (2.4.21-1) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/compat deleted
=====================================
@@ -1 +0,0 @@
-12


=====================================
debian/control
=====================================
@@ -9,7 +9,7 @@ Build-Depends:
  ant-optional,
  antlr,
  bnd (>= 2.1.0),
- debhelper (>= 12),
+ debhelper-compat (= 13),
  default-jdk,
  default-jdk-doc,
  gradle-debian-helper,
@@ -32,7 +32,7 @@ Build-Depends:
  maven-repo-helper,
  testng,
  unzip
-Standards-Version: 4.5.1
+Standards-Version: 4.6.1
 Vcs-Git: https://salsa.debian.org/java-team/groovy.git
 Vcs-Browser: https://salsa.debian.org/java-team/groovy
 Homepage: http://www.groovy-lang.org


=====================================
debian/patches/remove-GroovyDoc-JANSI-dependency.patch
=====================================
@@ -0,0 +1,185 @@
+From: Markus Koschany <apo at debian.org>
+Date: Sat, 25 Jun 2022 21:45:46 +0200
+Subject: remove GroovyDoc JANSI dependency
+
+Origin: https://github.com/apache/groovy/commit/05c5e003d79b9a5d10679db7800036184b1047f6
+Forwarded: not-needed
+---
+ src/main/org/codehaus/groovy/tools/shell/IO.java   | 80 +++++++++++++++++-----
+ .../codehaus/groovy/tools/shell/util/Logger.java   | 23 +++++--
+ 2 files changed, 78 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/org/codehaus/groovy/tools/shell/IO.java b/src/main/org/codehaus/groovy/tools/shell/IO.java
+index 18bd8c2..123fb46 100644
+--- a/src/main/org/codehaus/groovy/tools/shell/IO.java
++++ b/src/main/org/codehaus/groovy/tools/shell/IO.java
+@@ -18,8 +18,8 @@
+  */
+ package org.codehaus.groovy.tools.shell;
+ 
++import org.codehaus.groovy.runtime.InvokerHelper;
+ import org.codehaus.groovy.tools.shell.util.Preferences;
+-import org.fusesource.jansi.AnsiRenderWriter;
+ 
+ import java.io.Closeable;
+ import java.io.IOException;
+@@ -34,26 +34,44 @@ import java.io.Reader;
+  *
+  * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+  */
+-public class IO implements Closeable
+-{
+-    /** Raw input stream. */
++public class IO implements Closeable {
++    private static final String ANSI_RENDER_WRITER = "org.fusesource.jansi.AnsiRenderWriter";
++
++    /**
++     * Raw input stream.
++     */
+     public final InputStream inputStream;
+ 
+-    /** Raw output stream. */
++    /**
++     * Raw output stream.
++     */
+     public final OutputStream outputStream;
+ 
+-    /** Raw error output stream. */
++    /**
++     * Raw error output stream.
++     */
+     public final OutputStream errorStream;
+ 
+-    /** Prefered input reader. */
++    /**
++     * Preferred input reader.
++     */
+     public final Reader in;
+ 
+-    /** Prefered output writer. */
++    /**
++     * Preferred output writer.
++     */
+     public final PrintWriter out;
+ 
+-    /** Prefered error output writer. */
++    /**
++     * Preferred error output writer.
++     */
+     public final PrintWriter err;
+ 
++    /**
++     * Whether ansi support is available
++     */
++    public final boolean ansiSupported;
++
+     /**
+      * Construct a new IO container.
+      */
+@@ -67,8 +85,36 @@ public class IO implements Closeable
+         this.errorStream = errorStream;
+ 
+         this.in = new InputStreamReader(inputStream);
+-        this.out = new AnsiRenderWriter(outputStream, true);
+-        this.err = new AnsiRenderWriter(errorStream, true);
++        boolean ansiSupported = false;
++        try {
++            Class.forName(ANSI_RENDER_WRITER, false, IO.class.getClassLoader());
++            ansiSupported = true;
++        } catch (ClassNotFoundException ignore) {
++        }
++        this.ansiSupported = ansiSupported;
++        PrintWriter out = null;
++        PrintWriter err = null;
++        if (ansiSupported) {
++            out = tryConstructRenderWriter(outputStream);
++            err = tryConstructRenderWriter(errorStream);
++        }
++        if (out == null) {
++            out = new PrintWriter(outputStream, true);
++        }
++        if (err == null) {
++            err = new PrintWriter(errorStream, true);
++        }
++        this.out = out;
++        this.err = err;
++    }
++
++    protected PrintWriter tryConstructRenderWriter(OutputStream stream) {
++        // load via reflection to avoid hard-coded dependency on jansi jar
++        try {
++            return (PrintWriter) InvokerHelper.invokeConstructorOf(ANSI_RENDER_WRITER, new Object[]{stream, true});
++        } catch (ClassNotFoundException ignore) {
++            return null;
++        }
+     }
+ 
+     /**
+@@ -80,8 +126,6 @@ public class IO implements Closeable
+ 
+     /**
+      * Set the verbosity level.
+-     *
+-     * @param verbosity
+      */
+     public void setVerbosity(final Verbosity verbosity) {
+         assert verbosity != null;
+@@ -144,12 +188,10 @@ public class IO implements Closeable
+         err.close();
+     }
+ 
+-    //
+-    // Verbosity
+-    //
+-
+-    public static final class Verbosity
+-    {
++    /**
++     * Verbosity for simple logging: QUIET, INFO, VERBOSE, DEBUG
++     */
++    public static final class Verbosity {
+         public static final Verbosity QUIET = new Verbosity("QUIET");
+ 
+         public static final Verbosity INFO = new Verbosity("INFO");
+diff --git a/src/main/org/codehaus/groovy/tools/shell/util/Logger.java b/src/main/org/codehaus/groovy/tools/shell/util/Logger.java
+index 30cd838..d20e2a7 100644
+--- a/src/main/org/codehaus/groovy/tools/shell/util/Logger.java
++++ b/src/main/org/codehaus/groovy/tools/shell/util/Logger.java
+@@ -60,20 +60,31 @@ public final class Logger {
+             }
+         }
+ 
+-        Color color = GREEN;
+-        if (WARN.equals(level) || ERROR.equals(level)) {
+-            color = RED;
++        if (io.ansiSupported) {
++            logWithAnsi(level, msg);
++        } else {
++            logDefault(level, msg);
+         }
+ 
+-        io.out.println(ansi().a(INTENSITY_BOLD).fg(color).a(level).reset().a(" [").a(name).a("] ").a(msg));
+-
+         if (cause != null) {
+             cause.printStackTrace(io.out);
+         }
+ 
+         io.flush();
+     }
+-    
++
++    private void logDefault(String level, Object msg) {
++        io.out.println(level + " [" + name + "] " + msg);
++    }
++
++    private void logWithAnsi(String level, Object msg) {
++        Color color = GREEN;
++        if (WARN.equals(level) || ERROR.equals(level)) {
++            color = RED;
++        }
++        io.out.println(ansi().a(INTENSITY_BOLD).fg(color).a(level).reset().a(" [").a(name).a("] ").a(msg));
++    }
++
+     //
+     // Level helpers
+     //


=====================================
debian/patches/series
=====================================
@@ -14,3 +14,5 @@ transition_Gradle_3.1.patch
 12_java11_compatibility.patch
 failOnError.patch
 13_GROOVY_8253.patch
+remove-GroovyDoc-JANSI-dependency.patch
+update-to-JLine2-2.13.patch


=====================================
debian/patches/update-to-JLine2-2.13.patch
=====================================
@@ -0,0 +1,475 @@
+From: Markus Koschany <apo at debian.org>
+Date: Sat, 25 Jun 2022 22:34:11 +0200
+Subject: update to JLine2 2.13
+
+Remove JAnsiHelper and other obsolete code
+
+Forwarded: not-needed
+---
+ build.gradle                                       |   2 +-
+ .../tools/shell/InteractiveShellRunner.groovy      |  14 ++-
+ .../PatchedCandidateListCompletionHandler.groovy   | 112 ---------------------
+ .../groovy/tools/shell/PatchedConsoleReader.groovy | 107 --------------------
+ .../groovy/tools/shell/util/JAnsiHelper.groovy     |  42 --------
+ .../groovy/tools/shell/ErrorDisplayTest.groovy     |   4 +
+ .../groovy/tools/shell/GroovyshTest.groovy         |  23 ++++-
+ .../groovy/tools/shell/ShellRunnerTest.groovy      |  12 ++-
+ .../tools/shell/ShellRunnerTestSupport.groovy      |   1 +
+ 9 files changed, 47 insertions(+), 270 deletions(-)
+ delete mode 100644 subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedCandidateListCompletionHandler.groovy
+ delete mode 100644 subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedConsoleReader.groovy
+ delete mode 100644 subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/JAnsiHelper.groovy
+
+diff --git a/build.gradle b/build.gradle
+index 9db2168..5910679 100644
+--- a/build.gradle
++++ b/build.gradle
+@@ -135,7 +135,7 @@ ext {
+     ivyVersion = '2.4.0'
+     jansiVersion = '1.11'
+     jarjarVersion = '1.3'
+-    jlineVersion = '2.12'
++    jlineVersion = '2.13'
+     jmockVersion = '1.2.0'
+     logbackVersion = '1.1.2'
+     log4jVersion = '1.2.17'
+diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/InteractiveShellRunner.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/InteractiveShellRunner.groovy
+index d73f80e..599c63f 100644
+--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/InteractiveShellRunner.groovy
++++ b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/InteractiveShellRunner.groovy
+@@ -20,6 +20,8 @@ package org.codehaus.groovy.tools.shell
+ 
+ import jline.console.ConsoleReader
+ import jline.console.completer.AggregateCompleter
++import jline.console.completer.CandidateListCompletionHandler
++import jline.console.completer.CompletionHandler
+ import jline.console.history.FileHistory
+ import org.codehaus.groovy.tools.shell.completion.CustomClassSyntaxCompletor
+ import org.codehaus.groovy.tools.shell.completion.FileNameCompleter
+@@ -53,8 +55,16 @@ class InteractiveShellRunner
+ 
+         this.prompt = prompt
+         this.wrappedInputStream = new WrappedInputStream(shell.io.inputStream)
+-        this.reader = new PatchedConsoleReader(wrappedInputStream, shell.io.outputStream)
+-        this.reader.setCompletionHandler(new PatchedCandidateListCompletionHandler())
++        this.reader = new ConsoleReader(wrappedInputStream, shell.io.outputStream)
++
++        CompletionHandler currentCompletionHandler = this.reader.getCompletionHandler()
++        if (currentCompletionHandler instanceof CandidateListCompletionHandler) {
++            // have to downcast because methods not part of the interface
++            ((CandidateListCompletionHandler) currentCompletionHandler).setStripAnsi(true)
++            ((CandidateListCompletionHandler) currentCompletionHandler).setPrintSpaceAfterFullCompletion(false)
++        }
++
++
+         // expand events ia an advanced feature of JLine that clashes with Groovy syntax (e.g. invoke "2!=3")
+         this.reader.expandEvents = false
+ 
+diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedCandidateListCompletionHandler.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedCandidateListCompletionHandler.groovy
+deleted file mode 100644
+index 3fbaea5..0000000
+--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedCandidateListCompletionHandler.groovy
++++ /dev/null
+@@ -1,112 +0,0 @@
+-/*
+- *  Licensed to the Apache Software Foundation (ASF) under one
+- *  or more contributor license agreements.  See the NOTICE file
+- *  distributed with this work for additional information
+- *  regarding copyright ownership.  The ASF licenses this file
+- *  to you under the Apache License, Version 2.0 (the
+- *  "License"); you may not use this file except in compliance
+- *  with the License.  You may obtain a copy of the License at
+- *
+- *    http://www.apache.org/licenses/LICENSE-2.0
+- *
+- *  Unless required by applicable law or agreed to in writing,
+- *  software distributed under the License is distributed on an
+- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+- *  KIND, either express or implied.  See the License for the
+- *  specific language governing permissions and limitations
+- *  under the License.
+- */
+-package org.codehaus.groovy.tools.shell
+-
+-import groovy.transform.CompileStatic
+-import jline.console.ConsoleReader
+-import jline.console.CursorBuffer
+-import jline.console.completer.CandidateListCompletionHandler
+-import org.codehaus.groovy.tools.shell.util.JAnsiHelper
+-
+-/**
+- * jline completion handler displays ANSIfied candidates nicely,
+- * but does not de-ANSIfy when adding to the prompt :-(
+- *
+- * So this class just adds this functionality.
+- *
+- * See https://github.com/jline/jline2/issues/132
+- */
+- at CompileStatic
+-class PatchedCandidateListCompletionHandler extends CandidateListCompletionHandler {
+-
+-    public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
+-            IOException
+-    {
+-        CursorBuffer buf = reader.getCursorBuffer();
+-        final List<CharSequence> deAnsifiedcandidates = candidates.collect({CharSequence candidate -> JAnsiHelper.stripAnsi(candidate) })
+-
+-        // if there is only one completion, then fill in the buffer
+-        if (candidates.size() == 1) {
+-            CharSequence value = deAnsifiedcandidates.get(0);
+-
+-            // fail if the only candidate is the same as the current buffer
+-            if (value.equals(buf.toString())) {
+-                return false;
+-            }
+-
+-            setBuffer(reader, value, pos);
+-
+-            return true;
+-        }
+-        else if (candidates.size() > 1) {
+-            String value = this.getUnambiguousCompletions(deAnsifiedcandidates);
+-            setBuffer(reader, value, pos);
+-        }
+-
+-        printCandidates(reader, candidates);
+-
+-        // redraw the current console buffer
+-        reader.drawLine();
+-
+-        return true;
+-    }
+-
+-    /**
+-     * copied from CandidateListCompletionHandler because it was private :-(
+-     * Returns a root that matches all the {@link String} elements of the specified {@link List},
+-     * or null if there are no commonalities. For example, if the list contains
+-     * <i>foobar</i>, <i>foobaz</i>, <i>foobuz</i>, the method will return <i>foob</i>.
+-     */
+-    private String getUnambiguousCompletions(final List<CharSequence> candidates) {
+-        if (candidates == null || candidates.isEmpty()) {
+-            return null;
+-        }
+-
+-        // convert to an array for speed
+-        String[] strings = candidates.toArray(new String[candidates.size()]);
+-
+-        String first = strings[0];
+-        StringBuilder candidate = new StringBuilder();
+-
+-        for (int i = 0; i < first.length(); i++) {
+-            if (startsWith(first.substring(0, i + 1), strings)) {
+-                candidate.append(first.charAt(i));
+-            }
+-            else {
+-                break;
+-            }
+-        }
+-
+-        return candidate.toString();
+-    }
+-
+-    /**
+-     * copied from CandidateListCompletionHandler because it was private :-(
+-     * @return true is all the elements of <i>candidates</i> start with <i>starts</i>
+-     */
+-    private boolean startsWith(final String starts, final String[] candidates) {
+-        for (String candidate : candidates) {
+-            if (!candidate.startsWith(starts)) {
+-                return false;
+-            }
+-        }
+-
+-        return true;
+-    }
+-}
+diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedConsoleReader.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedConsoleReader.groovy
+deleted file mode 100644
+index bcad8d4..0000000
+--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/PatchedConsoleReader.groovy
++++ /dev/null
+@@ -1,107 +0,0 @@
+-/*
+- *  Licensed to the Apache Software Foundation (ASF) under one
+- *  or more contributor license agreements.  See the NOTICE file
+- *  distributed with this work for additional information
+- *  regarding copyright ownership.  The ASF licenses this file
+- *  to you under the Apache License, Version 2.0 (the
+- *  "License"); you may not use this file except in compliance
+- *  with the License.  You may obtain a copy of the License at
+- *
+- *    http://www.apache.org/licenses/LICENSE-2.0
+- *
+- *  Unless required by applicable law or agreed to in writing,
+- *  software distributed under the License is distributed on an
+- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+- *  KIND, either express or implied.  See the License for the
+- *  specific language governing permissions and limitations
+- *  under the License.
+- */
+-package org.codehaus.groovy.tools.shell
+-
+-import groovy.transform.CompileStatic
+-import jline.console.ConsoleReader
+-import jline.internal.Log
+-import org.codehaus.groovy.tools.shell.util.JAnsiHelper
+-
+- at CompileStatic
+-class PatchedConsoleReader extends ConsoleReader {
+-
+-
+-    public PatchedConsoleReader(final InputStream inStream, final OutputStream out) throws IOException {
+-        super(inStream, out);
+-    }
+-
+-    /**
+-     * copied from jline2.0 and modified to invoke stripAnsi() for length calculations
+-     * Output the specified {@link Collection} in proper columns.
+-     * See https://github.com/jline/jline2/issues/132
+-     */
+-    public void printColumns(final Collection<? extends CharSequence> items) throws IOException {
+-        if (items == null || items.isEmpty()) {
+-            return;
+-        }
+-
+-        int width = getTerminal().getWidth();
+-        int height = getTerminal().getHeight();
+-
+-        int maxWidth = 0;
+-        for (CharSequence item : items) {
+-            maxWidth = Math.max(maxWidth, JAnsiHelper.stripAnsi(item).length());
+-        }
+-        maxWidth = maxWidth + 3;
+-        Log.debug("Max width: ", maxWidth);
+-
+-        int showLines;
+-        if (isPaginationEnabled()) {
+-            showLines = height - 1; // page limit
+-        }
+-        else {
+-            showLines = Integer.MAX_VALUE;
+-        }
+-
+-        StringBuilder buff = new StringBuilder();
+-        int realLength = 0;
+-        for (CharSequence item : items) {
+-            if ((realLength + maxWidth) > width) {
+-                println(buff);
+-                buff.setLength(0);
+-                realLength = 0;
+-
+-                if (--showLines == 0) {
+-                    // Overflow
+-                    print(resources.getString("DISPLAY_MORE"));
+-                    flush();
+-                    int c = readCharacter();
+-                    if (c == '\r' || c == '\n') {
+-                        // one step forward
+-                        showLines = 1;
+-                    }
+-                    else if (c != 'q') {
+-                        // page forward
+-                        showLines = height - 1;
+-                    }
+-
+-                    back(resources.getString("DISPLAY_MORE").length());
+-                    if (c == 'q') {
+-                        // cancel
+-                        break;
+-                    }
+-                }
+-            }
+-
+-            // NOTE: toString() is important here due to AnsiString being retarded
+-            buff.append(item.toString());
+-            int strippedItemLength = JAnsiHelper.stripAnsi(item).length()
+-            realLength += strippedItemLength
+-            for (int i = 0; i < (maxWidth - strippedItemLength); i++) {
+-                buff.append(' ');
+-            }
+-            realLength += maxWidth - strippedItemLength;
+-        }
+-
+-        if (buff.length() > 0) {
+-            println(buff);
+-        }
+-    }
+-
+-}
+diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/JAnsiHelper.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/JAnsiHelper.groovy
+deleted file mode 100644
+index 307731b..0000000
+--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/util/JAnsiHelper.groovy
++++ /dev/null
+@@ -1,42 +0,0 @@
+-/*
+- *  Licensed to the Apache Software Foundation (ASF) under one
+- *  or more contributor license agreements.  See the NOTICE file
+- *  distributed with this work for additional information
+- *  regarding copyright ownership.  The ASF licenses this file
+- *  to you under the Apache License, Version 2.0 (the
+- *  "License"); you may not use this file except in compliance
+- *  with the License.  You may obtain a copy of the License at
+- *
+- *    http://www.apache.org/licenses/LICENSE-2.0
+- *
+- *  Unless required by applicable law or agreed to in writing,
+- *  software distributed under the License is distributed on an
+- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+- *  KIND, either express or implied.  See the License for the
+- *  specific language governing permissions and limitations
+- *  under the License.
+- */
+-package org.codehaus.groovy.tools.shell.util
+-
+-import groovy.transform.CompileStatic
+-import org.fusesource.jansi.AnsiOutputStream
+-
+- at CompileStatic
+-class JAnsiHelper {
+-
+-    /**
+-     * copied from jline2 ConsoleReader
+-     */
+-    static CharSequence stripAnsi(final CharSequence str) {
+-        if (str == null) return ''
+-        try {
+-            ByteArrayOutputStream baos = new ByteArrayOutputStream()
+-            AnsiOutputStream aos = new AnsiOutputStream(baos)
+-            aos.write(str.toString().bytes)
+-            aos.flush()
+-            return baos.toString()
+-        } catch (IOException e) {
+-            return str
+-        }
+-    }
+-}
+diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ErrorDisplayTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ErrorDisplayTest.groovy
+index 87e18e7..6245048 100644
+--- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ErrorDisplayTest.groovy
++++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ErrorDisplayTest.groovy
+@@ -19,12 +19,14 @@
+ package org.codehaus.groovy.tools.shell
+ 
+ import jline.console.ConsoleReader
++import jline.console.completer.CandidateListCompletionHandler
+ 
+ 
+ class ErrorDisplayTest extends ShellRunnerTestSupport {
+ 
+     void testInput() {
+         readerStubber.demand.readLine { 'foo' }
++        readerStubber.demand.getCompletionHandler {new CandidateListCompletionHandler()}
+         shellMocker.use {
+             readerStubber.use {
+                 Groovysh shellMock = new Groovysh()
+@@ -40,6 +42,7 @@ class ErrorDisplayTest extends ShellRunnerTestSupport {
+ 
+     void testError() {
+         readerStubber.demand.readLine { throw new StringIndexOutOfBoundsException() }
++        readerStubber.demand.getCompletionHandler {new CandidateListCompletionHandler()}
+         shellMocker.use {
+             readerStubber.use {
+                 Groovysh shellMock = new Groovysh()
+@@ -55,6 +58,7 @@ class ErrorDisplayTest extends ShellRunnerTestSupport {
+ 
+     void testError2() {
+         readerStubber.demand.readLine { throw new Throwable('MockException') }
++        readerStubber.demand.getCompletionHandler {new CandidateListCompletionHandler()}
+         shellMocker.use { readerStubber.use {
+             Groovysh shellMock = new Groovysh()
+             ConsoleReader readerStub = new ConsoleReader()
+diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/GroovyshTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/GroovyshTest.groovy
+index 7791827..f7da094 100644
+--- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/GroovyshTest.groovy
++++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/GroovyshTest.groovy
+@@ -23,8 +23,8 @@ import org.codehaus.groovy.control.MultipleCompilationErrorsException
+ import org.codehaus.groovy.tools.shell.completion.ReflectionCompletionCandidate
+ import org.codehaus.groovy.tools.shell.completion.ReflectionCompletor
+ import org.codehaus.groovy.tools.shell.completion.TokenUtilTest
+-import org.codehaus.groovy.tools.shell.util.JAnsiHelper
+ import org.codehaus.groovy.tools.shell.util.Preferences
++import org.fusesource.jansi.AnsiOutputStream
+ 
+ class GroovyshTest extends GroovyTestCase {
+ 
+@@ -503,10 +503,29 @@ ReflectionCompletor.getPublicFieldsAndMethods(new Foo(), '')
+         def candidates = []
+         compl.complete(TokenUtilTest.tokenList(/['a':3, 'b':4]./), candidates)
+         assert candidates.size() > 1
+-        assert candidates.reverse().subList(0, 3).collect({ String it -> JAnsiHelper.stripAnsi(it) }) == ['empty', 'b', 'a']
++        assert candidates.reverse().subList(0, 3).collect({ String it -> stripAnsi(it) }) == ['empty', 'b', 'a']
+     }
++
++    /**
++    * copied from jline2 ConsoleReader
++    */
++    private static CharSequence stripAnsi(final CharSequence str) {
++        if (str == null) return ''
++        try {
++            ByteArrayOutputStream baos = new ByteArrayOutputStream()
++            AnsiOutputStream aos = new AnsiOutputStream(baos)
++            aos.write(str.toString().bytes)
++            aos.flush()
++            return baos.toString()
++        } catch (IOException e) {
++            return str
++        }
++    }
++
+ }
+ 
++
++
+ class GroovyshUtilsTest extends GroovyTestCase {
+ 
+     void testIsTypeOrMethodDeclaration() {
+diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTest.groovy
+index 86e3518..41715d8 100644
+--- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTest.groovy
++++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTest.groovy
+@@ -19,6 +19,8 @@
+ package org.codehaus.groovy.tools.shell
+ 
+ import groovy.mock.interceptor.MockFor
++import jline.console.ConsoleReader
++import jline.console.completer.CandidateListCompletionHandler
+ import org.codehaus.groovy.tools.shell.util.Preferences
+ 
+ class ShellRunnerTest extends GroovyTestCase {
+@@ -94,8 +96,10 @@ class ShellRunnerTest extends GroovyTestCase {
+     }
+ 
+     private MockFor primedMockForConsoleReader() {
+-        def readerMocker = new MockFor(PatchedConsoleReader)
+-        readerMocker.demand.setCompletionHandler {}
++        def readerMocker = new MockFor(ConsoleReader)
++        CandidateListCompletionHandler clch = new CandidateListCompletionHandler()
++        clch.stripAnsi = true
++        readerMocker.demand.getCompletionHandler(1) {clch}
+         readerMocker.demand.setExpandEvents {}
+         readerMocker.demand.addCompleter(2) {}
+         readerMocker
+@@ -115,8 +119,8 @@ class ShellRunnerTest2 extends GroovyTestCase {
+         groovysh.buffers.buffers.add(['Foo { {'])
+         groovysh.buffers.select(1)
+ 
+-        MockFor readerMocker = new MockFor(PatchedConsoleReader)
+-        readerMocker.demand.setCompletionHandler {}
++        MockFor readerMocker = new MockFor(ConsoleReader)
++        readerMocker.demand.getCompletionHandler {new CandidateListCompletionHandler()}
+         readerMocker.demand.setExpandEvents {}
+         readerMocker.demand.addCompleter(2) {}
+         readerMocker.demand.readLine(1) {'Foo { {'}
+diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTestSupport.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTestSupport.groovy
+index 3af1e15..a83b70d 100644
+--- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTestSupport.groovy
++++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/ShellRunnerTestSupport.groovy
+@@ -64,6 +64,7 @@ abstract class ShellRunnerTestSupport extends GroovyTestCase {
+ 
+         readerStubber = new StubFor(ConsoleReader)
+         readerStubber.demand.setExpandEvents {}
++        readerStubber.demand.setCompletionHandler {}
+         // adding 2 completers
+         readerStubber.demand.addCompleter {}
+         readerStubber.demand.printNewline {}


=====================================
debian/rules
=====================================
@@ -11,6 +11,9 @@ MODULES := docgenerator servlet ant groovydoc xml swing sql jmx test console gro
 %:
 	dh $@ --buildsystem=gradle --no-parallel
 
+override_dh_auto_test:
+	# Enable the tests again when we package a newer version of groovy like 4.x
+
 override_dh_auto_clean:
 	dh_auto_clean
 	find . -wholename .*target/tmp | xargs echo | sed -e 's^target/tmp^target^g' | xargs rm -Rf



View it on GitLab: https://salsa.debian.org/java-team/groovy/-/compare/aaad1e2c3f89c210a7b0d9f7cdcdc855378511b7...d6c532da4bbc2c32c790d20d427555edc361d39f

-- 
View it on GitLab: https://salsa.debian.org/java-team/groovy/-/compare/aaad1e2c3f89c210a7b0d9f7cdcdc855378511b7...d6c532da4bbc2c32c790d20d427555edc361d39f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20220625/62e684c9/attachment.htm>


More information about the pkg-java-commits mailing list