From f08d310c176f5369e4d43fc9e9aed2e78d4846ec Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 3 Apr 2023 13:50:54 +0200 Subject: [PATCH] Bump clic dependency (#1363) * Bump clic dependency to include clic#27 * Add test to double-check proper UTF-8 output * Make test not dependent on tty detection --- alire.toml | 2 +- deps/clic | 2 +- src/alr/alr-commands-dev.adb | 22 ++++++++++++++++++++++ src/alr/alr-commands-dev.ads | 1 + testsuite/tests/misc/utf8-output/test.py | 18 ++++++++++++++++++ testsuite/tests/misc/utf8-output/test.yaml | 1 + 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 testsuite/tests/misc/utf8-output/test.py create mode 100644 testsuite/tests/misc/utf8-output/test.yaml diff --git a/alire.toml b/alire.toml index 0c772e9b..cda0dcd2 100644 --- a/alire.toml +++ b/alire.toml @@ -47,7 +47,7 @@ windows = { ALIRE_OS = "windows" } [[pins]] aaa = { url = "https://github.com/mosteo/aaa", commit = "906d9eaf4fb8efabfbc3d8cfb34d04ceec340e13" } ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" } -clic = { url = "https://github.com/alire-project/clic", commit = "ce4668206bbd038e857ce6a2d463c3de9a0cc9bb" } +clic = { url = "https://github.com/alire-project/clic", commit = "8d26222de71014554999e48c821906fca0e3dc41" } gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "92bb91130a9ec628b4c48b7ef9fe7f24d9dc25fa" } semantic_versioning = { url = "https://github.com/alire-project/semantic_versioning", commit = "2f23fc5f6b4855b836b599adf292fed9c0ed4144" } simple_logging = { url = "https://github.com/alire-project/simple_logging", commit = "3505dc645f3eef6799a486aae223d37e88cfc4d5" } diff --git a/deps/clic b/deps/clic index ce466820..8d26222d 160000 --- a/deps/clic +++ b/deps/clic @@ -1 +1 @@ -Subproject commit ce4668206bbd038e857ce6a2d463c3de9a0cc9bb +Subproject commit 8d26222de71014554999e48c821906fca0e3dc41 diff --git a/src/alr/alr-commands-dev.adb b/src/alr/alr-commands-dev.adb index 77ab8fb5..4b84110f 100644 --- a/src/alr/alr-commands-dev.adb +++ b/src/alr/alr-commands-dev.adb @@ -1,3 +1,5 @@ +with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; + with Alire.Selftest; package body Alr.Commands.Dev is @@ -11,6 +13,17 @@ package body Alr.Commands.Dev is null; end Custom; + -------------------------- + -- Print_UTF_8_Sequence -- + -------------------------- + + procedure Print_UTF_8_Sequence is + use Ada.Strings.UTF_Encoding.Wide_Wide_Strings; + begin + -- When compiled with -gnatW8, the following should produce valid UTF-8 + Trace.Always (Encode ("ⓘ✓")); + end Print_UTF_8_Sequence; + ------------- -- Execute -- ------------- @@ -39,6 +52,10 @@ package body Alr.Commands.Dev is if Cmd.Self_Test then Alire.Selftest.Run; end if; + + if Cmd.UTF_8_Test then + Print_UTF_8_Sequence; + end if; end Execute; ---------------------- @@ -83,6 +100,11 @@ package body Alr.Commands.Dev is Cmd.Self_Test'Access, "", "--test", "Run self-tests"); + + Define_Switch (Config, + Cmd.UTF_8_Test'Access, + "", "--utf8", + "Print a known UTF-8 sequence"); end Setup_Switches; end Alr.Commands.Dev; diff --git a/src/alr/alr-commands-dev.ads b/src/alr/alr-commands-dev.ads index 92e8f10a..b83011bf 100644 --- a/src/alr/alr-commands-dev.ads +++ b/src/alr/alr-commands-dev.ads @@ -36,6 +36,7 @@ private Filtering : aliased Boolean := False; -- Runs debug scope filtering Raise_Except : aliased Boolean := False; Self_Test : aliased Boolean := False; + UTF_8_Test : aliased Boolean := False; -- Produce some UTF-8 output end record; end Alr.Commands.Dev; diff --git a/testsuite/tests/misc/utf8-output/test.py b/testsuite/tests/misc/utf8-output/test.py new file mode 100644 index 00000000..adb377a0 --- /dev/null +++ b/testsuite/tests/misc/utf8-output/test.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Just to be sure + +""" +Verify that by default, alr prints the proper UTF-8 output +""" + +from drivers.alr import init_local_crate, run_alr +from drivers.asserts import assert_eq + +# Check that logging output is producing the expected valid UTF-8 output + +init_local_crate() +p = run_alr("dev", "--utf8") + +assert_eq("ⓘ✓\n", p.out) + +print('SUCCESS') diff --git a/testsuite/tests/misc/utf8-output/test.yaml b/testsuite/tests/misc/utf8-output/test.yaml new file mode 100644 index 00000000..32c747b3 --- /dev/null +++ b/testsuite/tests/misc/utf8-output/test.yaml @@ -0,0 +1 @@ +driver: python-script -- 2.39.5