mirror of
https://github.com/rizsotto/scan-build.git
synced 2025-12-16 12:00:08 +01:00
add test for deduplication bug
This commit is contained in:
61
tests/functional/cases/report/report_duplicates.fts
Normal file
61
tests/functional/cases/report/report_duplicates.fts
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# RUN: bash %s %T/report_duplicates
|
||||
# RUN: cd %T/report_duplicates; %{analyze-build} --output . --keep-empty --cdb input.json | ./check_exists.sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
# the test creates a subdirectory inside output dir.
|
||||
#
|
||||
# ${root_dir}
|
||||
# ├── input.json
|
||||
# ├── check_exists.sh
|
||||
# ├── check_not_exists.sh
|
||||
# └── src
|
||||
# └── broken.c
|
||||
|
||||
root_dir=$1
|
||||
mkdir -p "${root_dir}/src"
|
||||
|
||||
cp "${test_input_dir}/div_zero.c" "${root_dir}/src/broken.c"
|
||||
|
||||
cat > "${root_dir}/input.json" << EOF
|
||||
[
|
||||
{
|
||||
"directory": "${root_dir}",
|
||||
"file": "${root_dir}/src/broken.c",
|
||||
"command": "cc -c -o src/broken.o src/broken.c"
|
||||
},
|
||||
{
|
||||
"directory": "${root_dir}",
|
||||
"file": "${root_dir}/src/broken.c",
|
||||
"command": "cc -c -o src/broken.o -Dthose=these src/broken.c"
|
||||
}
|
||||
]
|
||||
EOF
|
||||
|
||||
check_one="${root_dir}/check_exists.sh"
|
||||
cat > "${check_one}" << EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
out_dir=\$(sed -n 's/\(.*\) Report directory created: \(.*\)/\2/p')
|
||||
if [ ! -d "\$out_dir" ]
|
||||
then
|
||||
echo "output directory should exists"
|
||||
false
|
||||
else
|
||||
count=\$(grep broken "\$out_dir/index.html" | wc -l)
|
||||
if [ \$((\$count)) -ne 1 ]
|
||||
then
|
||||
echo "\$out_dir does not contains 1 report entry";
|
||||
false
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
chmod +x "${check_one}"
|
||||
Reference in New Issue
Block a user