Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@
"justMyCode": false
},
{
"name": "(gdb) Launch alr at /tmp/a/xxx",
"name": "Alire: debug ./bin/alr at /tmp/a/xxx",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/alr",
"args": ["-d", "-vv", "with", "libfoo"],
"stopAtEntry": true,
"args": [
"exec",
"--",
"echo",
"blah"
],
"stopAtEntry": false,
"cwd": "/tmp/a/xxx",
"environment": [],
"externalConsole": false,
Expand All @@ -42,11 +47,11 @@
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"description": "Disable questions on multiple matches",
"text": "set multiple-symbols cancel",
"ignoreFailures": true
}
]
}
]
}
}
9 changes: 8 additions & 1 deletion src/alire/alire-os_lib-subprocess.adb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ with AnsiAda; use AnsiAda;

with CLIC.TTY;

with GNAT.IO;
with GNAT.OS_Lib;

package body Alire.OS_Lib.Subprocess is
Expand Down Expand Up @@ -208,7 +209,13 @@ package body Alire.OS_Lib.Subprocess is
and then CLIC.TTY.Is_TTY
and then CLIC.TTY.Color_Enabled
then
Ada.Text_IO.Put (Style (Dim, State));
-- We cannot use Ada.Text_IO here, as it mandates endlines,
-- and the Ada runtime flushes this with an extra '\n' on
-- finalization if this is the last output, creating an extra
-- empty line in e.g. `alr exec echo whatever`. GNAT.IO is
-- uncooked so it works as expected.
Ada.Text_IO.Flush; -- So we don't mix bufferings
GNAT.IO.Put (Style (Dim, State));
end if;
end Dim;

Expand Down
1 change: 0 additions & 1 deletion src/alr/alr-commands-exec.adb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package body Alr.Commands.Exec is
use GNAT.Strings;
use Ada.Containers;
use AAA.Strings;

begin
Cmd.Forbids_Structured_Output;

Expand Down
2 changes: 0 additions & 2 deletions src/alr/alr-utils-temp_file.adb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ package body Alr.Utils.Temp_File is
begin
if Exists (This.Name) then
Delete_File (This.Name);
null;
end if;

exception
when E : others =>
Alire.Utils.Finalize_Exception (E);
Expand Down
19 changes: 19 additions & 0 deletions testsuite/tests/exec/no-extra-line/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Check that `alr exec` does not add an extra line at the end of the output.
Fix for issue #2004. This test is more or less moot, since the bug can only be
observed when running interactively with ANSI coloring, which is disabled in
the testsuite and cannot be forced on. At least, it checks that no extra line is
added in the non-interactive case.
"""

from drivers.alr import run_alr, init_local_crate
from drivers.asserts import assert_eq

# Initialize a crate, enter it, and run an echo through exec. Check the output.

init_local_crate()

p = run_alr("exec", "--", "echo", "HELLO", quiet=False)
assert_eq("HELLO\n", p.out) # Note: only one newline at the end

print("SUCCESS")
3 changes: 3 additions & 0 deletions testsuite/tests/exec/no-extra-line/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
driver: python-script
indexes:
compiler_only_index: {}