add test for deduplication bug

This commit is contained in:
Laszlo Nagy
2020-01-04 11:53:00 +11:00
parent bad4cee340
commit 84b6aab76a

View 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}"