Skip to content
Prev Previous commit
Next Next commit
Use two test configs, one with version given, one with default version
  • Loading branch information
maxnoe committed Feb 19, 2024
commit e17a7a9aa7fd4798971f8a7ae6351a7cc162239a
8 changes: 7 additions & 1 deletion testing/main.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#include <stdio.h>
int main() {for (;;) break; printf("Hello world!\n");return 0;}
int main()
{
for (;;)
break;
printf("Hello world!\n");
return 0;
}
File renamed without changes.
8 changes: 8 additions & 0 deletions testing/pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: .
rev: HEAD
hooks:
- id: clang-format
args: [--style=file] # to load .clang-format
- id: clang-tidy
args: [--checks=.clang-tidy] # path/to/.clang-tidy
11 changes: 8 additions & 3 deletions testing/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
pre-commit clean
pre-commit run --files testing/main.c | tee result.txt || true
rm -f result.txt

for config in testing/pre-commit-config.yaml testing/pre-commit-config-version.yaml; do
git restore testing/main.c
pre-commit clean
pre-commit run -c $config --files testing/main.c | tee -a result.txt || true
done

failed_cases=`grep -c "Failed" result.txt`

if [ $failed_cases -eq 2 ]; then
if [ $failed_cases -eq 4 ]; then
echo "=============================="
echo "Test cpp-linter-hooks success."
echo "=============================="
Expand Down