Skip to content

Commit

Permalink
squash: add a test for #2006
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed May 5, 2023
1 parent 1d1b356 commit 7e46330
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
11 changes: 10 additions & 1 deletion tests/plan/lint/main.fmf
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
summary: Checks whether plan linting works correctly
/implicit-root:
summary: Checks whether plan linting works correctly
environment:
EXPLICIT_ROOT: no

/explicit-root:
summary: Checks whether plan linting works correctly with explicit --root

environment:
EXPLICIT_ROOT: yes
31 changes: 19 additions & 12 deletions tests/plan/lint/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@

rlJournalStart
rlPhaseStartSetup
rlRun "pushd data"
if [ "$EXPLICIT_ROOT" = "yes" ]; then
tmt="tmt --root data"
else
tmt="tmt"
rlRun "pushd data"
fi
rlPhaseEnd

rlPhaseStartTest "Good"
rlRun -s "tmt plan lint good"
rlRun -s "$tmt plan lint good"
rlAssertGrep "/good" $rlRun_LOG
rlAssertNotGrep 'warn ' $rlRun_LOG
rlRun "rm $rlRun_LOG"

rlRun -s "tmt plan lint valid_fmf"
rlRun -s "$tmt plan lint valid_fmf"
rlAssertGrep "pass P005 remote fmf id in \"default-0\" is valid" $rlRun_LOG
rlAssertNotGrep 'warn ' $rlRun_LOG
rlRun "rm $rlRun_LOG"

rlRun -s "tmt plan lint multi_execute"
rlRun -s "$tmt plan lint multi_execute"
rlAssertGrep "/multi_execute" $rlRun_LOG
rlAssertNotGrep 'fail ' $rlRun_LOG
rlRun "rm $rlRun_LOG"
rlPhaseEnd

rlPhaseStartTest "Bad"
rlRun -s "tmt plan lint bad" 1
rlRun -s "$tmt plan lint bad" 1
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
rlAssertGrep "warn C001 summary key is missing" $rlRun_LOG
rlAssertGrep "fail P002 execute step must be defined with \"how\"" $rlRun_LOG

rlRun -s "tmt plan lint invalid_how" 1
rlRun -s "$tmt plan lint invalid_how" 1
rlAssertGrep "warn C000 value of \"how\" is not \"shell\"" $rlRun_LOG
rlAssertGrep "warn C000 value of \"how\" is not \"fmf\"" $rlRun_LOG
rlAssertGrep "warn C000 value of \"how\" is not \"tmt\"" $rlRun_LOG
Expand All @@ -39,20 +44,20 @@ rlJournalStart
rlAssertGrep "fail P003 unknown execute method \"somehow\" in \"default-0\"" $rlRun_LOG
rlAssertGrep "fail P004 unknown discover method \"somehow\" in \"default-0\"" $rlRun_LOG

rlRun -s "tmt plan lint invalid_url" 1
rlRun -s "$tmt plan lint invalid_url" 1
rlAssertGrep "fail P005 remote fmf id in \"default-0\" is invalid, repo 'http://invalid-url' cannot be cloned" $rlRun_LOG

rlRun -s "tmt plan lint invalid_ref" 1
rlRun -s "$tmt plan lint invalid_ref" 1
rlAssertGrep "fail P005 remote fmf id in \"default-0\" is invalid, git ref 'invalid-ref-123456' is invalid" $rlRun_LOG

rlRun -s "tmt plan lint invalid_path" 1
rlRun -s "$tmt plan lint invalid_path" 1
rlAssertGrep "fail P005 remote fmf id in \"default-0\" is invalid, path '/invalid-path-123456' is invalid" $rlRun_LOG

rlRun -s "tmt plan lint multi_discover" 1
rlRun -s "$tmt plan lint multi_discover" 1
rlAssertGrep "pass P005 remote fmf id in \"a\" is valid" $rlRun_LOG
rlAssertGrep "fail P005 remote fmf id in \"b\" is invalid, repo 'http://invalid-url' cannot be cloned" $rlRun_LOG

rlRun -s "tmt plan lint invalid_attr" 1
rlRun -s "$tmt plan lint invalid_attr" 1
rlAssertGrep "warn C000 fmf node failed schema validation" $rlRun_LOG
rlAssertGrep "warn C001 summary key is missing" $rlRun_LOG
rlAssertGrep "fail P001 unknown key \"discove\" is used" $rlRun_LOG
Expand All @@ -61,6 +66,8 @@ rlJournalStart
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
if [ "$EXPLICIT_ROOT" != "yes" ]; then
rlRun "popd"
fi
rlPhaseEnd
rlJournalEnd

0 comments on commit 7e46330

Please sign in to comment.