@@ -42,8 +42,8 @@ source "${REPO_ROOT}/scripts/common_cmdline.sh"
42
42
pushd " ${REPO_ROOT} /test/cmdlineTests" > /dev/null
43
43
autoupdate=false
44
44
no_smt=false
45
- declare -a selected_tests
46
- declare -a patterns_with_no_matches
45
+ declare -a included_test_patterns
46
+ declare -a excluded_test_patterns
47
47
while [[ $# -gt 0 ]]
48
48
do
49
49
case " $1 " in
55
55
no_smt=true
56
56
shift
57
57
;;
58
+ --exclude)
59
+ [[ $2 != ' ' ]] || fail " No pattern given to --exclude option or the pattern is empty."
60
+ excluded_test_patterns+=(" $2 " )
61
+ shift
62
+ shift
63
+ ;;
58
64
* )
59
- matching_tests=$( find . -mindepth 1 -maxdepth 1 -type d -name " $1 " | cut -c 3- | LC_COLLATE=C sort)
60
-
61
- if [[ $matching_tests == " " ]]
62
- then
63
- patterns_with_no_matches+=(" $1 " )
64
- printWarning " No tests matching pattern '$1 ' found."
65
- else
66
- # shellcheck disable=SC2206 # We do not support test names containing spaces.
67
- selected_tests+=($matching_tests )
68
- fi
69
-
65
+ included_test_patterns+=(" $1 " )
70
66
shift
71
67
;;
72
68
esac
73
69
done
74
70
75
- if (( ${# selected_tests[@]} == 0 && ${# patterns_with_no_matches[@]} == 0 ))
71
+ (( ${# included_test_patterns[@]} > 0 )) || included_test_patterns+=(' *' )
72
+
73
+ test_name_filter=(' (' -name " ${included_test_patterns[0]} " )
74
+ for pattern in " ${included_test_patterns[@]: 1} "
75
+ do
76
+ test_name_filter+=(-or -name " $pattern " )
77
+ done
78
+ test_name_filter+=(' )' )
79
+
80
+ for pattern in " ${excluded_test_patterns[@]} "
81
+ do
82
+ test_name_filter+=(-and -not -name " $pattern " )
83
+ done
84
+
85
+ # NOTE: We want leading symbols in names to affect the sort order but without
86
+ # LC_COLLATE=C sort seems to ignore them.
87
+ # shellcheck disable=SC2207 # We do not support test names containing spaces.
88
+ selected_tests=($( find . -mindepth 1 -maxdepth 1 -type d " ${test_name_filter[@]} " | cut -c 3- | LC_COLLATE=C sort) )
89
+
90
+ if (( ${# selected_tests[@]} == 0 ))
76
91
then
77
- # NOTE: We want leading symbols in names to affect the sort order but without
78
- # LC_COLLATE=C sort seems to ignore them.
79
- all_tests= $( echo * | tr ' [:space:] ' ' \n ' | LC_COLLATE=C sort )
80
- # shellcheck disable=SC2206 # We do not support test names containing spaces.
81
- selected_tests=( $all_tests )
92
+ printWarning " The pattern ' ${test_name_filter[*]} ' did not match any tests. "
93
+ exit 0 ;
94
+ else
95
+ test_count= $( find . -mindepth 1 -maxdepth 1 -type d | wc -l )
96
+ printLog " Selected ${ # selected_tests[@]} out of ${test_count} tests. "
82
97
fi
98
+
83
99
popd > /dev/null
84
100
85
101
case " $OSTYPE " in
0 commit comments