|  | 
| 1 | 1 | #!/bin/bash | 
| 2 |  | -echo "===========================" | 
| 3 |  | -echo "Test pre-commit-config.yaml" | 
| 4 |  | -echo "===========================" | 
| 5 |  | -pre-commit clean | 
| 6 |  | -pre-commit run -c testing/pre-commit-config.yaml --files testing/main.c | tee -a result.txt || true | 
| 7 |  | -git restore testing/main.c | 
| 8 | 2 | 
 | 
| 9 |  | -echo "====================================" | 
| 10 |  | -echo "Test pre-commit-config-version.yaml" | 
| 11 |  | -echo "====================================" | 
| 12 |  | -pre-commit clean | 
| 13 |  | -pre-commit run -c testing/pre-commit-config-version.yaml --files testing/main.c | tee -a result.txt || true | 
| 14 |  | -git restore testing/main.c | 
|  | 3 | +configs=( | 
|  | 4 | +    "pre-commit-config.yaml" | 
|  | 5 | +    "pre-commit-config-version.yaml" | 
|  | 6 | +    "pre-commit-config-verbose.yaml" | 
|  | 7 | +    "pre-commit-config-style.yaml" | 
|  | 8 | +) | 
| 15 | 9 | 
 | 
| 16 |  | -echo "====================================" | 
| 17 |  | -echo "Test pre-commit-config-verbose.yaml" | 
| 18 |  | -echo "====================================" | 
| 19 |  | -pre-commit clean | 
| 20 |  | -pre-commit run -c testing/pre-commit-config-verbose.yaml --files testing/main.c | tee -a result.txt || true | 
| 21 |  | -git restore testing/main.c | 
|  | 10 | +for config in "${configs[@]}"; do | 
|  | 11 | +    echo "====================================" | 
|  | 12 | +    echo "Test $config" | 
|  | 13 | +    echo "====================================" | 
|  | 14 | +    pre-commit clean | 
|  | 15 | +    pre-commit run -c testing/$config --files testing/main.c | tee -a result.txt || true | 
|  | 16 | +    git restore testing/main.c | 
|  | 17 | +done | 
| 22 | 18 | 
 | 
| 23 | 19 | echo "==================================================================================" | 
| 24 |  | -echo "print result.txt" | 
|  | 20 | +echo "Print result.txt" | 
| 25 | 21 | cat result.txt | 
| 26 | 22 | echo "==================================================================================" | 
| 27 | 23 | 
 | 
| 28 |  | -failed_cases=`grep -c "Failed" result.txt` | 
|  | 24 | +failed_cases=$(grep -c "Failed" result.txt) | 
| 29 | 25 | 
 | 
| 30 |  | -echo $failed_cases " cases failed." | 
|  | 26 | +echo "$failed_cases cases failed." | 
| 31 | 27 | 
 | 
| 32 |  | -if [ $failed_cases -eq 10 ]; then | 
|  | 28 | +if [[ $failed_cases -eq 10 ]]; then | 
| 33 | 29 |     echo "==============================" | 
| 34 | 30 |     echo "Test cpp-linter-hooks success." | 
| 35 | 31 |     echo "==============================" | 
|  | 
0 commit comments