@@ -78,13 +78,51 @@ choose_newest_directory() {
7878 fi
7979}
8080
81+ circleci_tests_available () {
82+ command -v circleci > /dev/null 2>&1 && [[ " $CIRCLECI " == " true" ]]
83+ }
84+
85+ select_circleci_suites () {
86+ local glob_pattern=" $1 "
87+ local output_file=" $2 "
88+
89+ rm -f " $output_file "
90+ # Use xargs to normalize input to newlines, then sed to process
91+ # This follows CircleCI docs recommendation to use xargs for input handling
92+ if ! circleci tests glob " $glob_pattern " | \
93+ circleci tests run --command=" xargs -n1 echo | sed 's|.*/||; s|\.erl$||' >>$output_file " --verbose
94+ then
95+ echo " circleci tests run failed for pattern $glob_pattern "
96+ return 1
97+ fi
98+
99+ if [ ! -s " $output_file " ]; then
100+ echo " circleci tests run returned no suites for pattern $glob_pattern "
101+ return 1
102+ fi
103+ }
104+
105+ maybe_select_small_test_suites () {
106+ if circleci_tests_available && select_circleci_suites " test/**/*_SUITE.erl" selected_small_suites; then
107+ if [ -s selected_small_suites ]; then
108+ # Convert newline-separated suites to comma-separated list for rebar3
109+ SELECTED_SUITES=$( cat selected_small_suites | tr ' \n' ' ,' | sed ' s/,$//' )
110+ echo " Selected small test suites: $SELECTED_SUITES "
111+ export SUITE=" $SELECTED_SUITES "
112+ fi
113+ else
114+ echo " CircleCI did not return specific small-test suites to rerun; executing default list"
115+ fi
116+ }
117+
81118run_small_tests () {
82119 tools/print-dots.sh start
83120 tools/print-dots.sh monitor $$
84121 if [ " $COVER_ENABLED " = true ]; then
85122 REBAR_CT_EXTRA_ARGS=" -c $REBAR_CT_EXTRA_ARGS "
86123 fi
87124 export REBAR_CT_EXTRA_ARGS=" $REBAR_CT_EXTRA_ARGS "
125+ maybe_select_small_test_suites
88126 make ct
89127 RESULT=" $? "
90128 tools/print-dots.sh stop
@@ -159,11 +197,15 @@ run_test_preset() {
159197}
160198
161199maybe_select_suites () {
162- if command -v circleci > /dev/null 2>&1 && [[ " $CIRCLECI " == " true" ]]; then
163- circleci tests glob tests/* _SUITE.erl | \
164- circleci tests run --command=" >selected_suites xargs -d' ' -I {} basename {} .erl"
165- escript ../tools/select_suites_to_run.erl $TESTSPEC $( < selected_suites)
200+ if circleci_tests_available && select_circleci_suites " tests/*_SUITE.erl" selected_suites; then
201+ if [ -s selected_suites ]; then
202+ escript ../tools/select_suites_to_run.erl $TESTSPEC $( < selected_suites)
203+ else
204+ echo " CircleCI returned an empty suite list for big tests; running defaults"
166205 fi
206+ else
207+ echo " CircleCI did not provide failed big-test suites; running defaults"
208+ fi
167209}
168210
169211print_running_nodes () {
0 commit comments