From 951bfeca4f2088e8fadd4740596e05f5244f1bb4 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 10 Jan 2025 14:15:33 +0100 Subject: [PATCH] feat: propagate verbosity in `alr test` (#1817) * fix: propagate verbosity to test run * New test --- src/alr/alr-commands-test.adb | 6 ++++ .../tests/test/verbose-propagation/test.py | 33 +++++++++++++++++++ .../tests/test/verbose-propagation/test.yaml | 4 +++ 3 files changed, 43 insertions(+) create mode 100644 testsuite/tests/test/verbose-propagation/test.py create mode 100644 testsuite/tests/test/verbose-propagation/test.yaml diff --git a/src/alr/alr-commands-test.adb b/src/alr/alr-commands-test.adb index d98838d9..6ddf2fb1 100644 --- a/src/alr/alr-commands-test.adb +++ b/src/alr/alr-commands-test.adb @@ -157,6 +157,12 @@ package body Alr.Commands.Test is Empty_Vector & "-d" & "-n" + & (if Alire.Log_Level >= Detail + then To_Vector ("-v") + else Empty_Vector) + & (if Alire.Log_Level >= Debug + then To_Vector ("-v") + else Empty_Vector) & (if Alire.Force then To_Vector ("--force") else Empty_Vector); diff --git a/testsuite/tests/test/verbose-propagation/test.py b/testsuite/tests/test/verbose-propagation/test.py new file mode 100644 index 00000000..23d9aafc --- /dev/null +++ b/testsuite/tests/test/verbose-propagation/test.py @@ -0,0 +1,33 @@ +""" +Check that when running `alr test` with the verbose flag, the spawned command +of the default test action inherits the verbosity flag. +""" + +import os +from drivers.alr import init_local_crate, run_alr +from drivers.asserts import assert_not_substring, assert_substring +from drivers.helpers import content_of + +# Run `alr test` in a local crate for this test with increasing verbosity +# levels; we check the existence of expected output in the test log. The +# selected messages are representative of the log level at play. + +LOGFILE = os.path.join("alire", "alr_test_local.log") + +init_local_crate() + +# Default log level +run_alr("test", quiet=False) +assert_not_substring("alr build done", content_of(LOGFILE)) + +# Verbose +run_alr("-v", "test", quiet=False) +assert_substring("alr build done", content_of(LOGFILE)) +assert_not_substring("Setenv ALIRE=True", content_of(LOGFILE)) + +# More verbose +run_alr("-vv", "test", quiet=False) +assert_substring("alr build done", content_of(LOGFILE)) +assert_substring("Setenv ALIRE=True", content_of(LOGFILE)) + +print("SUCCESS") diff --git a/testsuite/tests/test/verbose-propagation/test.yaml b/testsuite/tests/test/verbose-propagation/test.yaml new file mode 100644 index 00000000..70201052 --- /dev/null +++ b/testsuite/tests/test/verbose-propagation/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +build_mode: both +indexes: + compiler_only_index: {} -- 2.39.5