Skip to content

Commit

Permalink
test layout
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Apr 5, 2024
1 parent 3cf5fbb commit 1465490
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
40 changes: 14 additions & 26 deletions tests/steps/test-unique.sh → tests/before/test-layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,21 @@
set -e
set -o pipefail

temp=$1
stdout=$2

{
java="${temp}/Foo(xls;)';не привет '\".java"
cat > "${java}" <<EOT
class Foo extends Boo implements Bar {
// This is static
private static int X = 1;
private String z;
Foo(String zz) {
this.z = zz;
}
private final boolean boom() { return true; }
}
EOT
"${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m1"
set -x
all=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \; | sort)
expected=$(echo "${all}" | wc -l | xargs)
actual=$(echo "${all}" | uniq | wc -l | xargs)
if [ ! "${actual}" = "${expected}" ]; then
echo "Exactly ${expected} unique metric names were expected, but ${actual} were actually found"
exit 1
fi
set +x
dirs=$(find "${LOCAL}/tests" -mindepth 1 -maxdepth 1 -type d -not -name "before" -not -name "after" -exec basename {} \;)
echo "${dirs}" | while IFS= read -r d; do
tests=$(find "${LOCAL}/tests/${d}" -mindepth 1 -maxdepth 1 -type f -name '*.sh' -exec basename {} \;)
echo "${tests}" | while IFS= read -r t; do
tail=${t:5:100}
base=${tail%.*}
name=${d}/${tail}
if [ "$(find "${LOCAL}/${d}" -name "${base}.*" 2>/dev/null | wc -l)" -eq 0 ]; then
echo "Script '${name}' doesn't exist, but its test exists in '${LOCAL}/tests/${d}/${t}'"
exit 1
fi
done
done
} > "${stdout}" 2>&1
echo "👍🏻 All provided metrics are named uniquely"

echo "👍🏻 All test scripts have they live counterparts"
27 changes: 27 additions & 0 deletions tests/steps/test-measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,30 @@ EOT
done
} > "${stdout}" 2>&1
echo "👍🏻 All metrics are correctly named in AllCaps format"

{
java="${temp}/Foo(xls;)';не привет '\".java"
cat > "${java}" <<EOT
class Foo extends Boo implements Bar {
// This is static
private static int X = 1;
private String z;
Foo(String zz) {
this.z = zz;
}
private final boolean boom() { return true; }
}
EOT
"${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m1"
set -x
all=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \; | sort)
expected=$(echo "${all}" | wc -l | xargs)
actual=$(echo "${all}" | uniq | wc -l | xargs)
if [ ! "${actual}" = "${expected}" ]; then
echo "Exactly ${expected} unique metric names were expected, but ${actual} were actually found"
exit 1
fi
set +x
} > "${stdout}" 2>&1
echo "👍🏻 All provided metrics are named uniquely"

0 comments on commit 1465490

Please sign in to comment.