Skip to content

Commit

Permalink
Add tests for different fmf_root
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed May 5, 2023
1 parent f5394ad commit 7e5e9b1
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/precommit/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > .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
Expand Down

0 comments on commit 7e5e9b1

Please sign in to comment.