From c17acc9cd8b27e8b44c282a669fba5354af0e6f2 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 5 May 2023 11:43:49 +0200 Subject: [PATCH] Add tests for different fmf_root Signed-off-by: Cristian Le --- tests/precommit/test.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/precommit/test.sh b/tests/precommit/test.sh index 72d7921ed8..0705d776f1 100755 --- a/tests/precommit/test.sh +++ b/tests/precommit/test.sh @@ -79,20 +79,41 @@ EOF # Force broken test into repo rlRun -s "git commit --no-verify -m wrong" "0" - # Add another good test, pre-commit should pass because /wrong - # is not touched + ## Add another good test, pre-commit should pass because /wrong + ## is not touched rlRun "echo summary: hello world > good.fmf" rlRun "git add good.fmf" rlRun -s "git commit -m 'add_good'" rlAssertGrep "$expected_command.*Passed" $rlRun_LOG - # Modify main.fmf so both /good and /wrong are checked + ## Modify main.fmf so both /good and /wrong are checked rlRun "echo summary: foo >> main.fmf" rlRun -s "git commit -a -m 'modify_main'" "1" rlAssertGrep "$expected_command.*Failed" $rlRun_LOG rlAssertGrep '/good' $rlRun_LOG rlAssertGrep '/wrong' $rlRun_LOG + ## Check it works in different fmf_root + rlRun "mkdir tmt_root" + rlRun -s "git mv .fmf/ tmt_root/.fmf/" + # Should fail because fmf_root is in different location + # (Also tests that pre-commit runs when .fmf/version is changed) + rlRun -s "git commit -m 'wrong_fmf_root'" "1" + rlAssertGrep "$expected_command.*Failed" $rlRun_LOG + # Add the correct root +cat < .pre-commit-config.yaml +repos: + - repo: $REPO + rev: "$REV" + hooks: + - id: "$hook" + args: [ --root, tmt_root ] +EOF + rlRun -s "git add .pre-commit-config.yaml" + rlRun -s "git mv main.fmf tmt_root" + rlRun -s "git commit -m 'pass different root'" + rlAssertGrep "$expected_command.*Passed" $rlRun_LOG + rlRun "popd" rlRun "rm -rf $tmp" 0 "Removing tmp directory" rlPhaseEnd