Skip to content

Commit

Permalink
Include an example template for creating tmt tests
Browse files Browse the repository at this point in the history
Vast majority of tests verifying the `tmt` features shares a
similar outline of the `beakerlib` skeleton. Let's make it super
easy to start writing a new `tmt` test. The skeleton also covers
submitting `log.txt` when something goes wrong during the test
execution so that a detailed investigation is possible later.
  • Loading branch information
psss committed Mar 12, 2024
1 parent 91b8734 commit b1ba3a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

==================================================================
tmt test template
==================================================================

When creating a new ``tmt`` test it is recommended to use the test
template provided in this directory. In order to be able to use it
directly from the ``tmt test create`` command you might want to
symlink it to your configuration::

ln -sr test.sh ~/.config/tmt/templates/script/tmt.j2
ln -sr main.fmf ~/.config/tmt/templates/test/tmt.j2
4 changes: 4 additions & 0 deletions examples/template/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary: Verify that this and that works like this
description:
Include a bit longer description which would help a stranger
or your future self to quickly grasp the purpose of the test.
20 changes: 20 additions & 0 deletions examples/template/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart
rlPhaseStartSetup
rlRun "run=\$(mktemp -d)" 0 "Create a run directory"
rlRun "pushd data"
rlPhaseEnd

rlPhaseStartTest
rlRun "tmt run --id $run"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
rlGetTestState || rlFileSubmit "$run/log.txt"
rlRun "rm -r $run" 0 "Remove the run directory"
rlPhaseEnd
rlJournalEnd

0 comments on commit b1ba3a0

Please sign in to comment.