/ test.sh
test.sh
1 #!/bin/bash 2 source ./shtest ./cehgit 3 4 test_begin "$@" 5 6 export VERBOSITY_LEVEL=4 7 8 function test_locks 9 { 10 lock_wait test.lock 11 lock_remove test.lock 12 } 13 14 ok test_locks 15 16 # Setup test repository 17 function setup_test_repo() { 18 rm -rf tests.git 19 mkdir tests.git 20 cd tests.git || exit 1 21 git init 22 echo "# Test Repository" > README.md 23 git add README.md 24 git config --local user.email "test@example.com" 25 git config --local user.name "Test User" 26 git commit -m "Initial commit" 27 } 28 29 call setup_test_repo 30 expect ".*/tests.git" pwd 31 32 # Test cehgit initialization 33 ok ../cehgit init 34 ok test -f .cehgit 35 ok test -d .cehgit.d 36 37 # Test action installation 38 ok ./.cehgit install-action --all 39 ok test -f .cehgit.d/mod-git 40 ok test -f .cehgit.d/30cargo-check 41 42 # Test hook installation 43 ok ./.cehgit install-hook --all 44 ok test -L .git/hooks/pre-commit 45 ok test -L .git/hooks/commit-msg 46 47 # Test hook removal 48 function test_remove_hooks() { 49 ok ./.cehgit remove-hook pre-commit 50 ok test ! -e .git/hooks/pre-commit 51 } 52 53 # Test listing functionality 54 expect ".*commit-msg.*" ./.cehgit list-hooks 55 expect ".*cargo.*" ./.cehgit list-actions 56 expect ".*cargo.*" ./.cehgit available-actions 57 58 # run tests and clean 59 call git add --all 60 ok ./.cehgit run 61 ok ./.cehgit clean 62 ok test ! -e .test-* 63 64 # Cleanup 65 call cd .. 66 call rm -rf tests.git 67 68 testreport 69 70 grep -niA2 'fixme:' cehgit || true