Skip to content

Commit

Permalink
feat: propagate verbosity in alr test (#1817)
Browse files Browse the repository at this point in the history
* fix: propagate verbosity to test run

* New test
  • Loading branch information
mosteo authored Jan 10, 2025
1 parent 79a8353 commit 951bfec
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/alr/alr-commands-test.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions testsuite/tests/test/verbose-propagation/test.py
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 4 additions & 0 deletions testsuite/tests/test/verbose-propagation/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: python-script
build_mode: both
indexes:
compiler_only_index: {}

0 comments on commit 951bfec

Please sign in to comment.