summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-04-09 15:55:06 +0300
committerrobot-piglet <[email protected]>2025-04-09 16:06:54 +0300
commit8c02be7c9a260edf13714760e07bf560c803761a (patch)
treeca5fc439fce2609c288c1a6e95fb14ee9ca2f771
parent3a93a5327c56de1d9b5df1457120d5d788068123 (diff)
Intermediate changes
commit_hash:82c13e8369702b168088dc96f7c8c9025d7abbb6
-rwxr-xr-xyql/essentials/core/type_ann/type-ann-coverage.sh63
-rwxr-xr-xyql/essentials/scripts/collect-coverage.sh54
2 files changed, 83 insertions, 34 deletions
diff --git a/yql/essentials/core/type_ann/type-ann-coverage.sh b/yql/essentials/core/type_ann/type-ann-coverage.sh
index 09a28963e57..e5336f6aac7 100755
--- a/yql/essentials/core/type_ann/type-ann-coverage.sh
+++ b/yql/essentials/core/type_ann/type-ann-coverage.sh
@@ -1,22 +1,38 @@
#!/bin/bash
#
# Script to collect the type annotation callbacks, being uncovered
-# by minirun test suite. Pass the filename as the first argument
+# by minirun test suite. Pass the coverage report root directory
+# as the first argument, and the filename as the second argument
# to store the collected list to the particular file.
set -eu
-ARC_ROOT=$(arc rev-parse --show-toplevel)
-REPORT_ROOT=$(mktemp --tmpdir -d yql-essentials-core-type_ann-coverage-XXXXXXX)
+REPORT_ROOT=$1
+# Check whether the desired prefix (i.e. yql/essentials/core/type_ann)
+# is collected (see collect-coverage.sh for the contract).
+COLLECTED_PREFIX=yql/essentials/core/type_ann
+COLLECTED_ANCHOR=${REPORT_ROOT}/collect-coverage.sh/${COLLECTED_PREFIX}/collected
+if [ ! -f ${COLLECTED_ANCHOR} ]; then
+ cat <<NOANCHOR
+==================================================================
+[FATAL] Anchor file is missing: ${COLLECTED_ANCHOR}
+------------------------------------------------------------------
+NB: Looks like the particular prefix (i.e. ${COLLECTED_PREFIX})
+is not set in collect-coverage.sh.
+==================================================================
+NOANCHOR
+ exit 1
+fi
+
# Save the list with uncovered callbacks into the file, that is
# given by the first parameter of this script; otherwise, save
# the list into the temporary file.
-UNCOVERED_FILE=${1:-$(mktemp --tmpdir yql-essentials-core-type_ann-uncovered-XXXXXXX.list)}
+UNCOVERED_FILE=${2:-$(mktemp --tmpdir yql-essentials-core-type_ann-uncovered-XXXXXXX.list)}
# File with the list of the callbacks to be ignored by coverage.
UNCOVERED_IGNORE=$(realpath $0 | sed -e 's/\.sh/\.ignore/')
-if [ ! -r $UNCOVERED_IGNORE ]; then
+if [ ! -r ${UNCOVERED_IGNORE} ]; then
cat <<NOIGNORE
==================================================================
-[FATAL] Ignore file is missing: $UNCOVERED_IGNORE
+[FATAL] Ignore file is missing: ${UNCOVERED_IGNORE}
------------------------------------------------------------------
NB: If no uncovered type annotation callbacks ought to be ignored,
just "touch" the empty file and do not remove it in future.
@@ -25,46 +41,25 @@ NOIGNORE
exit 1
fi
-# Run the command to collect code coverage over the sources in
-# /yql/essentials/core/type_ann by the minirun test suite.
-# XXX: Here are the rationales for the particular options:
-# * --clang-coverage -- collect the code coverage only for C++
-# sources;
-# * --coverage-prefix-filter -- collect the code coverage only
-# for the dedicated source files;
-# * --coverage-report --output $REPORT_ROOT -- build the HTML
-# report for the collected code coverage;
-# See more info here: https://docs.yandex-team.ru/devtools/test/coverage.
-ya make -tA \
- -C ${ARC_ROOT}/yql/essentials/tests/sql/minirun \
- -C ${ARC_ROOT}/yql/essentials/tests/s-expressions/minirun \
- --build profile \
- --clang-coverage \
- --coverage-prefix-filter yql/essentials/core/type_ann \
- --coverage-report \
- --output $REPORT_ROOT \
- --test-disable-timeout
-
# Find an anchor to uncovered line in HTML report, ...
UNCOVERED_ANCHOR="<td class='uncovered-line'><pre>0</pre></td>"
# ... find the return type of the type annotation callback,
# preceding the target function name ...
RETURN_TYPE="IGraphTransformer::TStatus"
# XXX: See more info re \K here: https://perldoc.perl.org/perlre#%5CK.
-CALLBACK_PREFIX="<td class='code'><pre>\s*$RETURN_TYPE\s*\K"
+CALLBACK_PREFIX="<td class='code'><pre>\s*${RETURN_TYPE}\s*\K"
# ... and find the parameters types of the type annotation
# callback, following the target function name.
INPUT_TYPE="const TExprNode::TPtr&amp; input"
OUTPUT_TYPE="TExprNode::TPtr&amp; output"
CONTEXT_TYPE="(?:TExtContext|TContext)&amp; ctx"
-CALLBACK_SUFFIX="(?=\($INPUT_TYPE,\s*$OUTPUT_TYPE,\s*$CONTEXT_TYPE\))"
-grep -oP "$UNCOVERED_ANCHOR$CALLBACK_PREFIX(\w+)$CALLBACK_SUFFIX" \
- -r $REPORT_ROOT/coverage.report/ \
- --no-filename \
- | grep -vf $UNCOVERED_IGNORE \
- | tee -a $UNCOVERED_FILE
+CALLBACK_SUFFIX="(?=\(${INPUT_TYPE},\s*${OUTPUT_TYPE},\s*${CONTEXT_TYPE}\))"
+grep -oP "${UNCOVERED_ANCHOR}${CALLBACK_PREFIX}(\w+)${CALLBACK_SUFFIX}" \
+ -r ${REPORT_ROOT}/coverage.report/ \
+ --no-filename \
+ | grep -vf ${UNCOVERED_IGNORE} \
+ | tee -a ${UNCOVERED_FILE}
-rm -rf $REPORT_ROOT
echo "The list of the uncovered functions: $UNCOVERED_FILE"
# Make script fail if uncovered list is not empty.
test ! -s $UNCOVERED_FILE
diff --git a/yql/essentials/scripts/collect-coverage.sh b/yql/essentials/scripts/collect-coverage.sh
new file mode 100755
index 00000000000..5d7a6510a1d
--- /dev/null
+++ b/yql/essentials/scripts/collect-coverage.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# Script to collect the coverage report for the specified contents
+# in yql/essentials/core (i.e. type annotation machinery, optimizers)
+# to the directory, given as the first argument.
+set -eu
+
+ARC_ROOT=$(arc rev-parse --show-toplevel)
+# Save the coverage report with to the given directory; otherwise,
+# save the list into the temporary file.
+REPORT_ROOT=${1:-$(mktemp --tmpdir -d yql-essentials-core-coverage-XXXXXXX)}
+# Define the array of the prefixes to be collected to the coverage
+# report.
+COVERAGE_PREFIXES=(
+ 'yql/essentials/core/type_ann'
+)
+# XXX: Join the prefixes listed above by a pipe (|) to make a
+# valid regexp alternatives for COVERAGE_TARGET_REGEXP parameter.
+COVERAGE_PREFIX_ALTERNATIVES=$(IFS='|'; echo "${COVERAGE_PREFIXES[*]}")
+
+# Run the command to collect code coverage over the sources in
+# /yql/essentials/core/ by the minirun test suite.
+# XXX: Here are the rationales for the particular options:
+# * --clang-coverage -- collect the code coverage only for C++
+# sources;
+# * --coverage-report --output $REPORT_ROOT -- build the HTML
+# report for the collected code coverage;
+# * -DCOVERAGE_TARGET_REGEXP -- collect the code coverage only
+# for the dedicated source files;
+# XXX: --coverage-prefix-filter doesn't work properly if several
+# paths are given, but fortunately, there is a recipe for C++
+# coverage in DEVTOOLSSUPPORT-52275#67093d22473c6c1da0bd17fd, that
+# uses -DCOVERAGE_TARGET_REGEXP and allows to specify several
+# paths by regexp.
+# See more info here: https://docs.yandex-team.ru/devtools/test/coverage.
+ya make -tA \
+ -C ${ARC_ROOT}/yql/essentials/tests/sql/minirun \
+ -C ${ARC_ROOT}/yql/essentials/tests/s-expressions/minirun \
+ -DCOVERAGE_TARGET_REGEXP="($COVERAGE_PREFIX_ALTERNATIVES)" \
+ --build profile \
+ --clang-coverage \
+ --coverage-report \
+ --output ${REPORT_ROOT} \
+ --test-disable-timeout
+
+# Create an anchor for each prefix, to ensure the analyzer part
+# that the coverage for particular prefixes is collected.
+for prefix in ${COVERAGE_PREFIXES[@]}; do
+ COLLECTED_PREFIX=${REPORT_ROOT}/$(basename $0)/$prefix
+ mkdir -p ${COLLECTED_PREFIX}
+ touch ${COLLECTED_PREFIX}/collected
+done
+
+echo "The coverage report is stored in ${REPORT_ROOT}"