summaryrefslogtreecommitdiff
path: root/scripts/rspec_helpers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rspec_helpers.sh')
-rw-r--r--scripts/rspec_helpers.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh
index 0c9d3505ff3..110567a15be 100644
--- a/scripts/rspec_helpers.sh
+++ b/scripts/rspec_helpers.sh
@@ -110,3 +110,27 @@ function rspec_paralellized_job() {
date
}
+
+function rspec_matched_tests() {
+ local test_file_count_threshold=20
+ local matching_tests_file=${1}
+ local rspec_opts=${2}
+ local test_files="$(cat "${matching_tests_file}")"
+ local test_file_count=$(wc -w "${matching_tests_file}" | awk {'print $1'})
+
+ if [[ "${test_file_count}" -gt "${test_file_count_threshold}" ]]; then
+ echo "There are more than ${test_file_count_threshold} FOSS test files matched,"
+ echo "which would take too long to run in this job."
+ echo "To reduce the likelihood of breaking FOSS pipelines,"
+ echo "please add [RUN AS-IF-FOSS] to the MR title and restart the pipeline."
+ echo "This would run all as-if-foss jobs in this merge request"
+ echo "and remove this job from the pipeline."
+ exit 1
+ fi
+
+ if [[ -n $test_files ]]; then
+ rspec_simple_job "${rspec_opts} ${test_files}"
+ else
+ echo "No test files to run"
+ fi
+}