Skip to content

Commit

Permalink
Add an initial set of basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psss committed Oct 4, 2019
1 parent 4f2de91 commit 2a9fb8a
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stories/docs.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ story:
As a command line user I want to have all essential
documentation at hand.

tested: /tests/docs
implemented: /tmt/cli

/help:
story:
Main command and all its subcommands should provide --help
Expand Down
2 changes: 2 additions & 0 deletions tests/docs/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
summary: Check that essential documentation is working
coverage: /stories/docs
36 changes: 36 additions & 0 deletions tests/docs/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1

PACKAGE="tmt"
EXAMPLES="/usr/share/doc/tmt/examples"

rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "set -o pipefail"
rlPhaseEnd

rlPhaseStartTest "help"
rlRun "tmt --help | tee help" 0 "Run help"
rlAssertGrep "Test Metadata Tool" "help"
rlPhaseEnd

rlPhaseStartTest "man"
rlRun "man tmt | tee man" 0 "Check man page"
rlAssertGrep "usage is straightforward" "man"
rlPhaseEnd

rlPhaseStartTest "examples"
rlRun "ls $EXAMPLES | tee examples" 0 "Check examples"
rlAssertGrep "mini" "examples"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalEnd
3 changes: 3 additions & 0 deletions tests/ls/example-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/basic/smoke:
summary: "Basic smoke test"
test: tmt --help
5 changes: 5 additions & 0 deletions tests/ls/example-testset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/smoke:
discover:
how: fmf
execute:
how: shell
2 changes: 2 additions & 0 deletions tests/ls/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
summary: List available tests and testsets
description: Make sure that 'tmt test ls' and 'tmt testset ls' work.
35 changes: 35 additions & 0 deletions tests/ls/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1

examples="/usr/share/doc/tmt/examples/systemd"

rlJournalStart
rlPhaseStartSetup
rlAssertRpm "tmt"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp example-test.txt $TmpDir/test.fmf"
rlRun "cp example-testset.txt $TmpDir/testset.fmf"
rlRun "pushd $TmpDir"
rlRun "fmf init"
rlRun "set -o pipefail"
rlPhaseEnd

rlPhaseStartTest "Test listing available tests"
rlRun "tmt test ls | tee output"
rlAssertGrep "/test/basic/smoke" "output"
rlAssertNotGrep "/testset/smoke" "output"
rlPhaseEnd

rlPhaseStartTest "Test listing available testsets"
rlRun "tmt testset ls | tee output"
rlAssertGrep "/testset/smoke" "output"
rlAssertNotGrep "/test/basic/smoke" "output"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalEnd
3 changes: 3 additions & 0 deletions tests/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test: ./test.sh
contact: Petr Šplíchal <psplicha@redhat.com>
duration: 5m
7 changes: 7 additions & 0 deletions testsets/basic.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary:
Essential command line features
discover:
how: fmf
repository: https://github.com/psss/fmf
execute:
how: beakerlib
4 changes: 4 additions & 0 deletions testsets/smoke.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary:
Just a basic smoke test
execute:
script: tmt --help

0 comments on commit 2a9fb8a

Please sign in to comment.