Skip to content

Commit

Permalink
Merge pull request #3343 from agullon/skip_rf_tests
Browse files Browse the repository at this point in the history
USHIFT-2463: Add PreRunModifier flag to skip RF
  • Loading branch information
openshift-merge-bot[bot] committed May 10, 2024
2 parents 1407777 + 6279bb2 commit 5cf96a2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
26 changes: 26 additions & 0 deletions test/resources/SkipTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Pre-run modifier that skips tests by their name.
Tests to skip are specified by Test Name
"""

import os
from robot.api import SuiteVisitor


class SkipTests(SuiteVisitor):

def __init__(self, list_skip_test):
self.list_skip_test = list_skip_test

if self.list_skip_test:
print("List of tests to be skipped:")
print(f" - {self.list_skip_test.replace(',', f'{os.linesep} - ')}")
else:
print("No tests to be skipped")

def visit_test(self, test):
"""Set tag to skip tests"""

# set `robot:skip` tag
if test.name in self.list_skip_test.split(","):
test.tags.add("robot:skip")
11 changes: 8 additions & 3 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OUTDIR="${ROOTDIR}/_output/e2e-$(date +%Y%m%d-%H%M%S)"
function usage {
local -r script_name=$(basename "$0")
cat - <<EOF
${script_name} [-h] [-n] [-o output_dir] [-v venv_dir] [-i var_file] [-s name=value] [test suite files]
${script_name} [-h] [-n] [-o output_dir] [-v venv_dir] [-i var_file] [-s name=value] [-k test_names] [test suite files]
Options:
Expand All @@ -23,11 +23,12 @@ Options:
-o DIR The output directory. (${OUTDIR})
-v DIR The venv directory. (${RF_VENV})
-i PATH The variables file. (${RF_VARIABLES})
-s NAME=VALUE To enable an stress condition.
-s NAME=VALUE To enable a stress condition.
-k SKIP_TESTS Comma separated list of tests to skip.
EOF
}

while getopts "hno:v:i:s:" opt; do
while getopts "hno:v:i:s:k:" opt; do
case ${opt} in
h)
usage
Expand All @@ -48,6 +49,9 @@ while getopts "hno:v:i:s:" opt; do
s)
STRESS_TESTING=${OPTARG}
;;
k)
SKIP_TESTS=${OPTARG}
;;
*)
usage
exit 1
Expand Down Expand Up @@ -101,6 +105,7 @@ else
# shellcheck disable=SC2086
"${RF_BINARY}" \
--randomize all \
--prerunmodifier "${SCRIPTDIR}/resources/SkipTests.py:${SKIP_TESTS:-}" \
--loglevel TRACE \
-V "${RF_VARIABLES}" \
-x junit.xml \
Expand Down

0 comments on commit 5cf96a2

Please sign in to comment.