Skip to content

Commit

Permalink
Show manual test instructions in verbose mode (#3431)
Browse files Browse the repository at this point in the history
Include instructions for the manual test execution in verbose mode
of the `tmt test show` command.
  • Loading branch information
psss authored Jan 16, 2025
1 parent f101de9 commit 1a42f5a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
======================


tmt-1.42.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``tmt show`` command now prints in verbose mode manual test
instructions as well.


tmt-1.41.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions tests/test/show/data/tests/manual.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
summary: A simple manual test
test: manual.md
manual: true
7 changes: 7 additions & 0 deletions tests/test/show/data/tests/manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test

## Step
Do this and that.

## Expect
Check this and that.
22 changes: 22 additions & 0 deletions tests/test/show/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ rlJournalStart
rlAssertGrep "relates https://something.org/related" $rlRun_LOG
rlPhaseEnd

rlPhaseStartTest "Show a manual test"

# Basic mode
rlRun -s "tmt tests show manual"
rlAssertGrep "summary A simple manual test" $rlRun_LOG
rlAssertGrep "test manual.md" $rlRun_LOG
rlAssertGrep "path /tests" $rlRun_LOG
rlAssertGrep "manual true" $rlRun_LOG
rlAssertNotGrep "instructions" $rlRun_LOG

# Verbose mode
rlRun -s "tmt --verbose tests show manual"
rlAssertGrep "summary A simple manual test" $rlRun_LOG
rlAssertGrep "test manual.md" $rlRun_LOG
rlAssertGrep "path /tests" $rlRun_LOG
rlAssertGrep "manual true" $rlRun_LOG
rlAssertGrep "instructions" $rlRun_LOG
rlAssertGrep "# Test" $rlRun_LOG
rlAssertGrep "## Step" $rlRun_LOG
rlAssertGrep "Do this and that\." $rlRun_LOG
rlPhaseEnd

rlPhaseStartTest "List all tests by default"
rlRun -s "tmt tests ls"
rlAssertGrep "/tests/enabled" $rlRun_LOG
Expand Down
26 changes: 26 additions & 0 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,27 @@ def enabled_on_guest(self, guest: tmt.steps.provision.Guest) -> bool:

return any(destination in (guest.name, guest.role) for destination in self.where)

def show_manual(self) -> None:
""" Show manual test instructions """

if self.tree is None or self.tree.root is None:
return

if self.test is None or self.test._script is None:
return

if self.path is not None:
instructions_path = self.tree.root / self.path.unrooted() / self.test._script
else:
instructions_path = self.tree.root / self.test._script

try:
instructions = instructions_path.read_text()
echo(tmt.utils.format('instructions', instructions))

except FileNotFoundError:
self.warn(f"Manual test instructions file '{instructions_path}' not found.")

def show(self) -> None:
""" Show test details """
self.ls()
Expand Down Expand Up @@ -1368,6 +1389,11 @@ def show(self) -> None:
continue
if value not in [None, [], {}]:
echo(tmt.utils.format(key, value))

# Show test instructions for manual tests in verbose mode
if key == "manual" and self.manual and self.verbosity_level:
self.show_manual()

if self.verbosity_level:
self._show_additional_keys()
if self.verbosity_level >= 2:
Expand Down

0 comments on commit 1a42f5a

Please sign in to comment.