Skip to content

Commit

Permalink
#185 test with poppler
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 4, 2024
1 parent bf34f50 commit 5b91070
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions metrics/raf.sh
Expand Up @@ -44,6 +44,6 @@ else
raf=0
fi

echo "raf ${raf} Relative Age of File (in the entire timeframe of repository existence),
where 0.0 means the file was added in the first commit and 1.0 means that
echo "raf ${raf} Relative Age of File (in the entire timeframe of repository existence), \
where 0.0 means the file was added in the first commit and 1.0 means that \
the file was added in the last commit" > "${output}"
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,5 +1,5 @@
javalang==0.13.0
flake8==7.0.0
pylint==3.0.3
multimetric==2.2.0
multimetric==1.3.0
chardet==5.2.0
10 changes: 10 additions & 0 deletions steps/install.sh
Expand Up @@ -83,6 +83,15 @@ if ! jq --version >/dev/null 2>&1; then
fi
fi

if ! pdftotext -v >/dev/null 2>&1; then
if [ -n "${linux}" ]; then
apt-get install -y poppler
else
echo "Install 'poppler' somehow"
exit 1
fi
fi

if ! shellcheck --version >/dev/null 2>&1; then
if [ -n "${linux}" ]; then
apt-get install -y shellcheck
Expand Down Expand Up @@ -132,6 +141,7 @@ if ! pygmentize -V >/dev/null 2>&1; then
fi
fi

$SUDO python3 -m pip install --upgrade pip
$SUDO python3 -m pip install -r "${LOCAL}/requirements.txt"

gem install --no-document rubocop -v 1.56.3
Expand Down
8 changes: 4 additions & 4 deletions tests/metrics/test-multimetric.sh
Expand Up @@ -50,9 +50,9 @@ EOT
cat "${TARGET}/temp/multimetric.json"
cat "${temp}/stdout"
grep "hsd 6" "${temp}/stdout"
grep "hse 1133.218" "${temp}/stdout"
grep "hsv 188.87" "${temp}/stdout"
grep "midx 103.261" "${temp}/stdout"
grep "fout 2" "${temp}/stdout"
grep "hse 1133.21789508" "${temp}/stdout"
grep "hsv 188.86964918" "${temp}/stdout"
grep "midx 100" "${temp}/stdout"
grep "fout 0" "${temp}/stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly counted a few metrics"
15 changes: 10 additions & 5 deletions tests/steps/test-measure-file.sh
Expand Up @@ -44,8 +44,13 @@ EOT
echo "${msg}"
set -x
test "$(echo "${msg}" | grep -c "sum=0")" = 0
all=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \;)
test "$(echo "${all}" | wc -l | xargs)" = "48"
all=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \; | sort)
expected=48
actual=$(echo "${all}" | wc -l | xargs)
if [ ! "${actual}" = "${expected}" ]; then
echo "Exactly ${expected} metrics were expected, but ${actual} were actually collected"
exit 1
fi
echo "${all}" | sort | while IFS= read -r m; do
metric=${m//m\./}
echo "${metric}: $(cat "${temp}/${m}")"
Expand All @@ -62,9 +67,9 @@ EOT
test "$(cat "${temp}/m1.notp")" = "0"
test "$(cat "${temp}/m1.final")" = "0"
test "$(cat "${temp}/m1.nobl")" = "1"
test "$(cat "${temp}/m1.hsd")" = "6.188"
test "$(cat "${temp}/m1.hsv")" = "122.624"
test "$(cat "${temp}/m1.hse")" = "758.735"
test "$(cat "${temp}/m1.hsd")" = "6.1875"
test "$(cat "${temp}/m1.hsv")" = "122.62388524"
test "$(cat "${temp}/m1.hse")" = "758.73528991"
test "$(cat "${temp}/m1.coco")" = "0"
test "$(cat "${temp}/m1.fout")" = "0"
test "$(cat "${temp}/m1.LCOM5")" = "0"
Expand Down
3 changes: 3 additions & 0 deletions tests/steps/test-report.sh
Expand Up @@ -36,6 +36,9 @@ stdout=$2
echo "\\item foo" > "${TARGET}/temp/reports/foo.tex"
"${LOCAL}/steps/report.sh"
test -e "${TARGET}/report.pdf"
pdftotext "${TARGET}/report.pdf" "${TARGET}/report.txt"
txt=$(cat "${TARGET}/report.txt")
echo "${txt}" | grep "yegor256/cam"
} > "${stdout}" 2>&1
echo "👍🏻 A PDF report generated correctly"

Expand Down

0 comments on commit 5b91070

Please sign in to comment.