@@ -60,6 +60,39 @@ publish-worker() {
6060 docker push beeshive/elegant-git-ci:${1}
6161}
6262
63+ robot () {
64+ # runs a
65+ local smart_testing_status=" "
66+ local command_files=($( git ls-files --modified --other -- libexec/git-elegant* ) )
67+
68+ for command_file in ${command_files[@]} ; do
69+ local command_name=$( basename ${command_file} )
70+ if ! test -f tests/${command_name} .bats; then continue ; fi
71+ ( testing ${command_name} && info-text " '${command_file} ' testing is passed." ) || {
72+ error-text " '${command_name} ' testing is failed."
73+ smart_testing_status=failed
74+ }
75+ done
76+ local tests_files=($( git ls-files --modified --other -- tests/git-elegant* .bats) )
77+ for test_file in ${tests_files[@]} ; do
78+ local file_name=$( basename ${test_file} )
79+ if [[ ${command_files[@]} =~ " ${file_name/ .bats/ } " ]] ; then
80+ continue # already tested
81+ fi
82+ if ! test -f tests/${command_name} .bats; then continue ; fi
83+ ( testing ${file_name} && info-text " '${file_name} ' testing is passed." ) || {
84+ error-text " '${file_name} ' testing is failed."
85+ smart_testing_status=failed
86+ }
87+ done
88+ if test -z " ${smart_testing_status} " ; then
89+ info-text " Everything is great!"
90+ else
91+ error-text " Something should be improved!"
92+ exit 1
93+ fi
94+ }
95+
6396usage () {
6497 cat << MESSAGE
6598usage: ${BASH_SOURCE[0]} [command] [arg]...
@@ -69,6 +102,8 @@ Available commands:
69102 testing runs bats tests; accepts a optional pattern for tests
70103 filtering ("${BASH_SOURCE[0]} testing work" run all tests
71104 which have the word in the test name)
105+ robot runs tests for updated "libexec/git-elegant*" or
106+ "tests/git-elegant*.bats" files
72107 repository creates a git repository and installs Elegant Git within
73108 generate-docs generates fresh commands documentation bases on the latest
74109 changes
@@ -83,6 +118,7 @@ MESSAGE
83118commands=(
84119 usage
85120 testing
121+ robot
86122 repository
87123 generate-docs
88124 preview-docs
@@ -99,8 +135,10 @@ main() {
99135 echo " "
100136 select any in ${commands[@]} ; do
101137 command=${any}
102- question-text " Please give the arguments: "
103- read args
138+ if test ${command} = testing; then
139+ question-text " Please give the tests pattern: "
140+ read args
141+ fi
104142 break
105143 done
106144 else
0 commit comments