Skip to content

Commit

Permalink
cmdlineTests.sh: Add --exclude option
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Jun 19, 2023
1 parent 4752b31 commit 399457d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ one per subdirectory, and can be executed using the ``cmdlineTests.sh`` script.
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>`_,
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
inside the working copy.
Expand All @@ -291,10 +292,11 @@ Example:
.. code-block:: bash
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
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
compiler binary (unless you are on Windows -- then ``solidity/build/solc/Release/solc.exe``).

Expand Down
12 changes: 12 additions & 0 deletions test/cmdlineTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pushd "${REPO_ROOT}/test/cmdlineTests" > /dev/null
autoupdate=false
no_smt=false
declare -a included_test_patterns
declare -a excluded_test_patterns
while [[ $# -gt 0 ]]
do
case "$1" in
Expand All @@ -54,6 +55,12 @@ do
no_smt=true
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")
shift
Expand All @@ -70,6 +77,11 @@ do
done
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
# LC_COLLATE=C sort seems to ignore them.
# shellcheck disable=SC2207 # We do not support test names containing spaces.
Expand Down

0 comments on commit 399457d

Please sign in to comment.