Skip to content

Commit 18f609e

Browse files
committed
rename main.c to bad.c
1 parent d7dca0d commit 18f609e

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ coverage.xml
99
__pycache__
1010
venv
1111
result.txt
12-
testing/main.c
12+
testing/bad.c

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ clang-format.............................................................Failed
6767
Here is the diff between the modified file.
6868

6969
```diff
70-
--- a/testing/main.c
71-
+++ b/testing/main.c
70+
--- a/testing/bad.c
71+
+++ b/testing/bad.c
7272
@@ -1,3 +1,6 @@
7373
#include <stdio.h>
7474
-int main() {for (;;) break; printf("Hello world!\n");return 0;}
@@ -89,22 +89,22 @@ clang-format.............................................................Failed
8989
- hook id: clang-format
9090
- exit code: 255
9191
92-
main.c:2:11: warning: code should be clang-formatted [-Wclang-format-violations]
92+
bad.c:2:11: warning: code should be clang-formatted [-Wclang-format-violations]
9393
int main() {for (;;) break; printf("Hello world!\n");return 0;}
9494
^
95-
main.c:2:13: warning: code should be clang-formatted [-Wclang-format-violations]
95+
bad.c:2:13: warning: code should be clang-formatted [-Wclang-format-violations]
9696
int main() {for (;;) break; printf("Hello world!\n");return 0;}
9797
^
98-
main.c:2:21: warning: code should be clang-formatted [-Wclang-format-violations]
98+
bad.c:2:21: warning: code should be clang-formatted [-Wclang-format-violations]
9999
int main() {for (;;) break; printf("Hello world!\n");return 0;}
100100
^
101-
main.c:2:28: warning: code should be clang-formatted [-Wclang-format-violations]
101+
bad.c:2:28: warning: code should be clang-formatted [-Wclang-format-violations]
102102
int main() {for (;;) break; printf("Hello world!\n");return 0;}
103103
^
104-
main.c:2:54: warning: code should be clang-formatted [-Wclang-format-violations]
104+
bad.c:2:54: warning: code should be clang-formatted [-Wclang-format-violations]
105105
int main() {for (;;) break; printf("Hello world!\n");return 0;}
106106
^
107-
main.c:2:63: warning: code should be clang-formatted [-Wclang-format-violations]
107+
bad.c:2:63: warning: code should be clang-formatted [-Wclang-format-violations]
108108
int main() {for (;;) break; printf("Hello world!\n");return 0;}
109109
^
110110
```
@@ -119,7 +119,7 @@ clang-tidy...............................................................Failed
119119
522 warnings generated.
120120
Suppressed 521 warnings (521 in non-user code).
121121
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
122-
/home/runner/work/cpp-linter-hooks/cpp-linter-hooks/testing/main.c:4:13: warning: statement should be inside braces [readability-braces-around-statements]
122+
/home/runner/work/cpp-linter-hooks/cpp-linter-hooks/testing/bad.c:4:13: warning: statement should be inside braces [readability-braces-around-statements]
123123
for (;;)
124124
^
125125
{

testing/main.c

-2
This file was deleted.

testing/run.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
rm -f result.txt
2-
git restore testing/main.c
2+
git restore testing/bad.c
33

44
for config in testing/pre-commit-config.yaml testing/pre-commit-config-version.yaml; do
55
pre-commit clean
6-
pre-commit run -c $config --files testing/main.c | tee -a result.txt || true
7-
git restore testing/main.c
6+
pre-commit run -c $config --files testing/bad.c | tee -a result.txt || true
7+
git restore testing/bad.c
88
done
99

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

tests/test_clang_format.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
)
1313
def test_run_clang_format_valid(args, expected_retval, tmp_path):
1414
# copy test file to tmp_path to prevent modifying repo data
15-
test_file = tmp_path / "main.c"
16-
test_file.write_bytes(Path("testing/main.c").read_bytes())
15+
test_file = tmp_path / "bad.c"
16+
test_file.write_bytes(Path("testing/bad.c").read_bytes())
1717
ret = run_clang_format(args + [str(test_file)])
1818
assert ret == expected_retval
1919
assert test_file.read_text() == Path("testing/good.c").read_text()
@@ -27,7 +27,7 @@ def test_run_clang_format_valid(args, expected_retval, tmp_path):
2727
)
2828
def test_run_clang_format_invalid(args, expected_retval, tmp_path):
2929
# non existent file
30-
test_file = tmp_path / "main.c"
30+
test_file = tmp_path / "bad.c"
3131

3232
ret, _ = run_clang_format(args + [str(test_file)])
3333
assert ret == expected_retval

tests/test_clang_tidy.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from cpp_linter_hooks.clang_tidy import run_clang_tidy
55

66

7-
@pytest.mark.skip(reason="see https://github.com/cpp-linter/cpp-linter-hooks/pull/29")
87
@pytest.mark.parametrize(
98
('args', 'expected_retval'), (
109
(['--checks="boost-*"'], 1),
@@ -13,8 +12,8 @@
1312
)
1413
def test_run_clang_tidy_valid(args, expected_retval, tmp_path):
1514
# copy test file to tmp_path to prevent modifying repo data
16-
test_file = tmp_path / "main.c"
17-
test_file.write_bytes(Path("testing/main.c").read_bytes())
15+
test_file = tmp_path / "bad.c"
16+
test_file.write_bytes(Path("testing/bad.c").read_bytes())
1817
ret, output = run_clang_tidy(args + [str(test_file)])
1918
assert ret == expected_retval
2019
print(output)
@@ -28,7 +27,7 @@ def test_run_clang_tidy_valid(args, expected_retval, tmp_path):
2827
)
2928
def test_run_clang_tidy_invalid(args, expected_retval, tmp_path):
3029
# non existent file
31-
test_file = tmp_path / "main.c"
30+
test_file = tmp_path / "bad.c"
3231

3332
ret, _ = run_clang_tidy(args + [str(test_file)])
3433
assert ret == expected_retval

0 commit comments

Comments
 (0)