cmdlineTests.sh: Add --exclude option

This commit is contained in:
Kamil Śliwak 2023-06-16 14:36:24 +02:00
parent 4752b31e6c
commit 399457d74b
2 changed files with 16 additions and 2 deletions

View File

@ -280,6 +280,7 @@ one per subdirectory, and can be executed using the ``cmdlineTests.sh`` script.
By default the script runs all available tests. By default the script runs all available tests.
You can also provide one or more `file name patterns <https://www.gnu.org/software/bash/manual/bash.html#Filename-Expansion>`_, You can also provide one or more `file name patterns <https://www.gnu.org/software/bash/manual/bash.html#Filename-Expansion>`_,
in which case only the tests matching at least one pattern will be executed. in which case only the tests matching at least one pattern will be executed.
It is also possible to exclude files matching a specific pattern by prefixing it with ``--exclude``.
By default the script assumes that a ``solc`` binary is available inside the ``build/`` subdirectory By default the script assumes that a ``solc`` binary is available inside the ``build/`` subdirectory
inside the working copy. inside the working copy.
@ -291,10 +292,11 @@ Example:
.. code-block:: bash .. code-block:: bash
export SOLIDITY_BUILD_DIR=~/solidity/build/ export SOLIDITY_BUILD_DIR=~/solidity/build/
test/cmdlineTests.sh "standard_*" "*_yul_*" test/cmdlineTests.sh "standard_*" "*_yul_*" --exclude "standard_yul_*"
The commands above will run tests from directories starting with ``test/cmdlineTests/standard_`` and The commands above will run tests from directories starting with ``test/cmdlineTests/standard_`` and
subdirectories of ``test/cmdlineTests/`` that have ``_yul_`` somewhere in the name. subdirectories of ``test/cmdlineTests/`` that have ``_yul_`` somewhere in the name,
but no test whose name starts with ``standard_yul_`` will be executed.
It will also assume that the file ``solidity/build/solc/solc`` inside your home directory is the It will also assume that the file ``solidity/build/solc/solc`` inside your home directory is the
compiler binary (unless you are on Windows -- then ``solidity/build/solc/Release/solc.exe``). compiler binary (unless you are on Windows -- then ``solidity/build/solc/Release/solc.exe``).

View File

@ -43,6 +43,7 @@ pushd "${REPO_ROOT}/test/cmdlineTests" > /dev/null
autoupdate=false autoupdate=false
no_smt=false no_smt=false
declare -a included_test_patterns declare -a included_test_patterns
declare -a excluded_test_patterns
while [[ $# -gt 0 ]] while [[ $# -gt 0 ]]
do do
case "$1" in case "$1" in
@ -54,6 +55,12 @@ do
no_smt=true no_smt=true
shift shift
;; ;;
--exclude)
[[ $2 != '' ]] || fail "No pattern given to --exclude option or the pattern is empty."
excluded_test_patterns+=("$2")
shift
shift
;;
*) *)
included_test_patterns+=("$1") included_test_patterns+=("$1")
shift shift
@ -70,6 +77,11 @@ do
done done
test_name_filter+=(')') test_name_filter+=(')')
for pattern in "${excluded_test_patterns[@]}"
do
test_name_filter+=(-and -not -name "$pattern")
done
# NOTE: We want leading symbols in names to affect the sort order but without # NOTE: We want leading symbols in names to affect the sort order but without
# LC_COLLATE=C sort seems to ignore them. # LC_COLLATE=C sort seems to ignore them.
# shellcheck disable=SC2207 # We do not support test names containing spaces. # shellcheck disable=SC2207 # We do not support test names containing spaces.