FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcheck/test/cli/samples_test.py at main · cppcheck-opensource/cppcheck · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
cppcheck-opensource
/
cppcheck
Public
Notifications
You must be signed in to change notification settings
Fork
1.6k
Star
6.7k
Code
Pull requests
201
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcheck
/
test
/
cli
/
samples_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (34 loc) · 1.68 KB
Breadcrumbs
cppcheck
/
test
/
cli
/
samples_test.py
Copy path
File metadata and controls
45 lines (34 loc) · 1.68 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
import
os
import
sys
from
testutils
import
cppcheck
__script_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
__root_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
__script_dir
,
'..'
,
'..'
))
def
test_samples
():
failures
=
{}
samples_dir
=
os
.
path
.
join
(
__root_dir
,
'samples'
)
for
entry
in
os
.
listdir
(
samples_dir
):
sample_dir
=
os
.
path
.
join
(
samples_dir
,
entry
)
if
not
os
.
path
.
isdir
(
sample_dir
):
continue
with
open
(
os
.
path
.
join
(
sample_dir
,
'out.txt'
))
as
out_in
:
out_txt
=
out_in
.
read
()
if
sys
.
platform
!=
'win32'
:
out_txt
=
out_txt
.
replace
(
'
\\
'
,
'/'
)
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
sample_dir
,
'good.c'
)):
good_src
=
os
.
path
.
join
(
'samples'
,
entry
,
'good.cpp'
)
bad_src
=
os
.
path
.
join
(
'samples'
,
entry
,
'bad.cpp'
)
else
:
good_src
=
os
.
path
.
join
(
'samples'
,
entry
,
'good.c'
)
bad_src
=
os
.
path
.
join
(
'samples'
,
entry
,
'bad.c'
)
# check that good input does not produce any warnings
ret
,
_
,
stderr
=
cppcheck
([
'-q'
,
'--enable=all'
,
'--disable=missingInclude'
,
'--inconclusive'
,
'--check-level=exhaustive'
,
'--error-exitcode=1'
,
good_src
],
cwd
=
__root_dir
)
if
ret
!=
0
:
failures
[
good_src
]
=
stderr
# check that the bad inout produces a warning
ret
,
_
,
stderr
=
cppcheck
([
'-q'
,
'--enable=all'
,
'--disable=missingInclude'
,
'--inconclusive'
,
'--check-level=exhaustive'
,
'--error-exitcode=1'
,
bad_src
],
cwd
=
__root_dir
)
if
ret
!=
1
:
failures
[
bad_src
]
=
stderr
# check that the bad input procudes the expected output
if
not
stderr
==
out_txt
:
failures
[
bad_src
]
=
stderr
assert
failures
==
{}
Back
|
FazBrowse Home
|
New Git URL