Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS.Process on_exit callback $3 parameter is erroneous #143

Open
dsauvage opened this issue Dec 9, 2022 · 2 comments
Open

GPS.Process on_exit callback $3 parameter is erroneous #143

dsauvage opened this issue Dec 9, 2022 · 2 comments
Assignees

Comments

@dsauvage
Copy link

dsauvage commented Dec 9, 2022

GPS.Process on_exit callback $3 parameter is erroneous

Environment:

Debian GNU/Linux 10 X86_64
GNAT Studio 23.0w (20220512)

Bug Description:

When using GPS.Process and its on_exit callback in GNAT Studio plugins [1];

A. When no regexp is used, and on_match is set to None [2]

The issue is that the third parameter given to the on_exit callback contains twice all the output since the process has been launched.

B. When regexp is used, and on_match is set [3]

The issue is that the third parameter given to the on_exit callback contains all the output since the process has been launched, and not only "the output of the process since the last call to on match()", as specified in the documentation.

When different regexp is used, i.e regexp='^[\x20-\x7E]', this issue can occurs randomly

[1] https://docs.adacore.com/live/wave/gps/html/gps_ug/GPS.html#gps-process
on_exit is a subprogram called when the process has exited. You can no longer send input to it at this stage. Its parameters are:

$1 = the instance of GPS.Process

$2 = the exit status

$3 = the output of the process since the last call to on_match()

[2]
proc = backend.process(command=command,regexp='',on_match=None, before_kill=on_kill, remote_server="Execution_Server", on_exit=on_exit, strip_cr=False, progress_regexp="^ *completed (\d*) out of (\d*)")

[3]
proc = GPS.Process(command=command,regexp='.+',on_match=on_match, before_kill=on_kill, remote_server="Execution_Server", on_exit=on_exit, strip_cr=False, progress_regexp="^ *completed (\d*)

@AdrienBoulanger
Copy link
Contributor

Hi @dsauvage,
I can't reproduce the behavior with the following basic plugin:

import GPS
from gs_utils import interactive

# Create a contextual action starting gprbuild and show the output when
# stopping the process in the TEST console
@interactive(contextual="Test/launch command",
             name="test on exit")
def align_colons():
    def on_exit(p, status, out):
        GPS.Console("TEST").write("Process finished with: %i\n" % status)
        GPS.Console("TEST").write("Remaining output:\n %s\n" % out)

    def on_kill(p, out):
        GPS.Console("TEST").write("Before kill:\n %s\n" % out)

    command = ["gprbuild", "-d", "-Ptest.gpr", "-f"]
    proc = GPS.Process(command=command,
                       regexp="",
                       on_match=None,
                       before_kill=on_kill,
                       on_exit=on_exit,
                       strip_cr=False,
                       progress_regexp="^ *completed (\d*) out of (\d*).*$")
    proc.wait()
    GPS.Console("TEST").write("\n")

No duplication in stdout when regexp is not set.
I tested it with both the current wavefront and 20220512
Can you share your plugin and the command?

@dsauvage
Copy link
Author

dsauvage commented Jun 4, 2023

Hi @AdrienBoulanger,
thanks for your feedback,
we will evaluate making a reduced reproducer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants