Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
simplecpp/run-tests.py at master · cppcheck-opensource/simplecpp · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
cppcheck-opensource
/
simplecpp
Public
Notifications
You must be signed in to change notification settings
Fork
104
Star
263
Code
Issues
83
Pull requests
32
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
simplecpp
/
run-tests.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
163 lines (134 loc) · 5.02 KB
master
Breadcrumbs
simplecpp
/
run-tests.py
Copy path
Top
File metadata and controls
Code
Blame
163 lines (134 loc) · 5.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import
glob
import
os
import
shutil
import
subprocess
import
sys
def
cleanup
(
out
:
str
)
->
str
:
parts
=
[]
for
line
in
out
.
splitlines
():
if
len
(
line
)
>
1
and
line
[
0
]
==
'#'
:
continue
parts
.
append
(
""
.
join
(
line
.
split
()))
return
""
.
join
(
parts
)
# Check for required compilers and exit if any are missing
CLANG_EXE
=
shutil
.
which
(
'clang'
)
if
not
CLANG_EXE
:
sys
.
exit
(
'Failed to run tests: clang compiler not found'
)
GCC_EXE
=
shutil
.
which
(
'gcc'
)
if
not
GCC_EXE
:
sys
.
exit
(
'Failed to run tests: gcc compiler not found'
)
SIMPLECPP_EXE
=
'./simplecpp'
commands
=
[]
for
f
in
sorted
(
glob
.
glob
(
os
.
path
.
expanduser
(
'testsuite/clang-preprocessor-tests/*.c*'
))):
for
line
in
open
(
f
,
'rt'
,
encoding
=
'utf-8'
):
if
line
.
startswith
(
'// RUN: %clang_cc1 '
):
cmd
=
''
for
arg
in
line
[
19
:].
split
():
if
arg
==
'-E'
or
(
len
(
arg
)
>=
3
and
arg
[:
2
]
==
'-D'
):
cmd
=
cmd
+
' '
+
arg
if
len
(
cmd
)
>
1
:
newcmd
=
cmd
[
1
:]
+
' '
+
f
if
not
newcmd
in
commands
:
commands
.
append
(
cmd
[
1
:]
+
' '
+
f
)
for
f
in
sorted
(
glob
.
glob
(
os
.
path
.
expanduser
(
'testsuite/gcc-preprocessor-tests/*.c*'
))):
commands
.
append
(
'-E '
+
f
)
# skipping tests..
skip
=
[
'assembler-with-cpp.c'
,
'builtin_line.c'
,
'c99-6_10_3_3_p4.c'
,
'clang_headers.c'
,
# missing include <limits.h>
'comment_save.c'
,
# _Pragma
'has_attribute.c'
,
'has_attribute.cpp'
,
'header_lookup1.c'
,
# missing include <stddef.h>
'line-directive-output.c'
,
# 'macro_paste_hashhash.c',
'microsoft-ext.c'
,
'normalize-3.c'
,
# gcc has different output \uAC00 vs \U0000AC00 on cygwin/linux
'pr63831-1.c'
,
# __has_attribute => works differently on cygwin/linux
'pr63831-2.c'
,
# __has_attribute => works differently on cygwin/linux
'pr65238-1.c'
,
# __has_attribute => works differently on cygwin/linux
'_Pragma-location.c'
,
'_Pragma-dependency.c'
,
'_Pragma-dependency2.c'
,
'_Pragma-physloc.c'
,
'pragma-pushpop-macro.c'
,
# pragma push/pop
'x86_target_features.c'
,
'warn-disabled-macro-expansion.c'
,
'ucnid-2011-1.c'
# \u00A8 generates different output on cygwin/linux
]
todo
=
[
# todo, low priority: wrong number of macro arguments, pragma, etc
'macro_backslash.c'
,
'macro_fn_comma_swallow.c'
,
'macro_fn_comma_swallow2.c'
,
'macro_expand.c'
,
'macro_fn_disable_expand.c'
,
'macro_paste_commaext.c'
,
'macro_paste_hard.c'
,
'macro_rescan_varargs.c'
,
# todo, high priority
'c99-6_10_3_4_p5.c'
,
'c99-6_10_3_4_p6.c'
,
'expr_usual_conversions.c'
,
# condition is true: 4U - 30 >= 0
'stdint.c'
,
# GCC..
'diagnostic-pragma-1.c'
,
'pr45457.c'
,
'pr57580.c'
,
]
def
run
(
compiler_executable
:
str
,
compiler_args
:
list
[
str
])
->
tuple
[
int
,
str
,
str
,
str
]:
"""Execute a compiler command and capture its exit code, stdout, and stderr."""
compiler_cmd
=
[
compiler_executable
]
compiler_cmd
.
extend
(
compiler_args
)
with
subprocess
.
Popen
(
compiler_cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
text
=
True
,
encoding
=
"utf-8"
)
as
process
:
stdout
,
stderr
=
process
.
communicate
()
exit_code
=
process
.
returncode
output
=
cleanup
(
stdout
)
error
=
(
stderr
or
""
).
strip
()
return
(
exit_code
,
output
,
stdout
,
error
)
numberOfSkipped
=
0
numberOfFailed
=
0
numberOfFixed
=
0
usedTodos
=
[]
for
cmd
in
commands
:
if
cmd
[
cmd
.
rfind
(
'/'
)
+
1
:]
in
skip
:
numberOfSkipped
=
numberOfSkipped
+
1
continue
_
,
clang_output_c
,
clang_output
,
_
=
run
(
CLANG_EXE
,
cmd
.
split
(
' '
))
_
,
gcc_output_c
,
gcc_output
,
_
=
run
(
GCC_EXE
,
cmd
.
split
(
' '
))
# -E is not supported and we bail out on unknown options
simplecpp_ec
,
simplecpp_output_c
,
simplecpp_output
,
simplecpp_err
=
run
(
SIMPLECPP_EXE
,
cmd
.
replace
(
'-E '
,
''
,
1
).
split
(
' '
))
if
simplecpp_output_c
!=
clang_output_c
and
simplecpp_output_c
!=
gcc_output_c
:
filename
=
cmd
[
cmd
.
rfind
(
'/'
)
+
1
:]
if
filename
in
todo
:
print
(
'TODO '
+
cmd
)
usedTodos
.
append
(
filename
)
else
:
print
(
'FAILED '
+
cmd
)
print
(
'---expected (clang):'
)
print
(
clang_output_c
)
print
(
'---expected (gcc):'
)
print
(
gcc_output_c
)
print
(
'---actual:'
)
print
(
simplecpp_output_c
)
print
(
'---output (clang):'
)
print
(
clang_output
)
print
(
'---output (gcc):'
)
print
(
gcc_output
)
print
(
'---output (simplecpp):'
)
print
(
simplecpp_output
)
if
simplecpp_ec
:
print
(
'simplecpp failed - '
+
simplecpp_err
)
numberOfFailed
=
numberOfFailed
+
1
for
filename
in
todo
:
if
not
filename
in
usedTodos
:
print
(
'FIXED '
+
filename
)
numberOfFixed
=
numberOfFixed
+
1
print
(
'Number of tests: '
+
str
(
len
(
commands
)))
print
(
'Number of skipped: '
+
str
(
numberOfSkipped
))
print
(
'Number of todos (fixed): '
+
str
(
len
(
usedTodos
))
+
' ('
+
str
(
numberOfFixed
)
+
')'
)
print
(
'Number of failed: '
+
str
(
numberOfFailed
))
if
numberOfFailed
or
numberOfFixed
:
sys
.
exit
(
1
)
sys
.
exit
(
0
)
You can’t perform that action at this time.