Skip to content

Commit

Permalink
squash: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Jan 28, 2025
1 parent 29fc1e5 commit 854da66
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 39 deletions.
72 changes: 46 additions & 26 deletions tests/steps/when/data/plan.fmf
Original file line number Diff line number Diff line change
@@ -1,32 +1,52 @@
execute:
how: tmt

discover:
how: shell
tests:
- name: /
test: touch $TMT_PLAN_DATA/when-in-discover
when: trigger == commit

provision:
how: local

prepare:
- how: shell
script: touch $TMT_PLAN_DATA/when-prepare-always
- how: shell
script: touch $TMT_PLAN_DATA/when-prepare-fedora
when: distro == fedora

finish:
- how: shell
script: touch $TMT_PLAN_DATA/when-finish-no-distro
when:
- initiator == human
- distro is not defined

report:
- how: junit
file: $TMT_PLAN_DATA/when-report-fedora
when: distro == fedora
- how: display
/sanity:
discover:
how: shell
tests:
- name: /
test: touch $TMT_PLAN_DATA/when-in-discover
when: trigger == commit

prepare:
- how: shell
script: touch $TMT_PLAN_DATA/when-prepare-always
- how: shell
script: touch $TMT_PLAN_DATA/when-prepare-fedora
when: distro == fedora

finish:
- how: shell
script: touch $TMT_PLAN_DATA/when-finish-no-distro
when:
- initiator == human
- distro is not defined

report:
- how: junit
file: $TMT_PLAN_DATA/when-report-fedora
when: distro == fedora
- how: display

/execute-must-obey:
link:
- verifies: https://github.com/teemtee/tmt/issues/3492

discover:
- how: shell
name: shell-not-run
tests:
- name: nope
test: echo
when: flag == on

- how: shell
name: shell-run
tests:
- name: yes
test: echo
when: flag is not defined
32 changes: 19 additions & 13 deletions tests/steps/when/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,33 @@ rlJournalStart

rlPhaseStartTest
# No tests discovered
rlRun -s "tmt run --id $tmp/no-context" "3"
rlRun -s "tmt run --id $tmp/no-context plan -n '/sanity'" "3"
rlPhaseEnd

rlPhaseStartTest
rlRun -s "tmt -c distro=fedora -c trigger=commit run --id $tmp/distro-trigger-context"
rlAssertExists "$tmp/distro-trigger-context/plan/data/when-in-discover"
rlAssertExists "$tmp/distro-trigger-context/plan/data/when-prepare-always"
rlAssertExists "$tmp/distro-trigger-context/plan/data/when-prepare-fedora"
rlAssertExists "$tmp/distro-trigger-context/plan/data/when-report-fedora"
rlAssertNotExists "$tmp/distro-trigger-context/plan/data/when-finish-no-distro"
rlRun -s "tmt -c distro=fedora -c trigger=commit run --id $tmp/distro-trigger-context plan -n '/sanity'"
rlAssertExists "$tmp/distro-trigger-context/plan/sanity/data/when-in-discover"
rlAssertExists "$tmp/distro-trigger-context/plan/sanity/data/when-prepare-always"
rlAssertExists "$tmp/distro-trigger-context/plan/sanity/data/when-prepare-fedora"
rlAssertExists "$tmp/distro-trigger-context/plan/sanity/data/when-report-fedora"
rlAssertNotExists "$tmp/distro-trigger-context/plan/sanity/data/when-finish-no-distro"
rlPhaseEnd

rlPhaseStartTest
rlRun -s "tmt -c trigger=commit run --id $tmp/trigger-context"
rlAssertExists "$tmp/trigger-context/plan/data/when-in-discover"
rlAssertExists "$tmp/trigger-context/plan/data/when-prepare-always"
rlAssertNotExists "$tmp/trigger-context/plan/data/when-prepare-fedora"
rlAssertNotExists "$tmp/trigger-context/plan/data/when-report-fedora"
rlAssertExists "$tmp/trigger-context/plan/data/when-finish-no-distro"
rlRun -s "tmt -c trigger=commit run --id $tmp/trigger-context plan -n '/sanity'"
rlAssertExists "$tmp/trigger-context/plan/sanity/data/when-in-discover"
rlAssertExists "$tmp/trigger-context/plan/sanity/data/when-prepare-always"
rlAssertNotExists "$tmp/trigger-context/plan/sanity/data/when-prepare-fedora"
rlAssertNotExists "$tmp/trigger-context/plan/sanity/data/when-report-fedora"
rlAssertExists "$tmp/trigger-context/plan/sanity/data/when-finish-no-distro"
rlPhaseEnd

rlPhaseStartTest
rlRun -s "tmt run --id $tmp/execute-must-obey plan -n '/execute-must-obey'"
rlAssertExists "$tmp/execute-must-obey/plan/execute-must-obey/execute/data/guest/default-0/shell-run"
rlAssertExists "$tmp/execute-must-obey/plan/execute-must-obey/execute/data/guest/default-0/shell-run/yes-1/output.txt"
rlAssertNotExists "$tmp/execute-must-obey/plan/execute-must-obey/execute/data/guest/default-0/shell-not-run"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
Expand Down

0 comments on commit 854da66

Please sign in to comment.