Skip to content

Commit

Permalink
Add the ability to ignore tests from the command line using IGNORES
Browse files Browse the repository at this point in the history
  • Loading branch information
JLockerman committed Dec 10, 2018
1 parent 8da8ac3 commit 9b52909
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,4 @@ ts_function_types_equal(Oid left[], Oid right[], int nargs)
return false;
}
return true;
}
}
39 changes: 29 additions & 10 deletions test/pg_isolation_regress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,40 @@ EXE_DIR=$(dirname $0)
PG_ISOLATION_REGRESS=${PG_ISOLATION_REGRESS:-pg_isolation_regress}
ISOLATION_TEST_SCHEDULE=${ISOLATION_TEST_SCHEDULE:-}
TESTS=${TESTS:-}
IGNORES=${IGNORES:-}

contains() {
# a list contains a value foo if the regex ".* foo .*" holds true
[[ $1 =~ (.*[[:space:]]|^)$2([[:space:]].*|$) ]];
return $?
}

echo "TESTS ${TESTS}"
echo "IGNORES ${IGNORES}"

if [[ -z ${TESTS} ]]; then
if [[ -z ${ISOLATION_TEST_SCHEDULE} ]]; then
for t in ${EXE_DIR}/isolation/specs/*.spec; do
t=${t##${EXE_DIR}/isolation/specs/}
t=${t%.spec}
TESTS="${TESTS} $t"

if ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} ${t}"
fi
done
elif [[ -n ${IGNORES} ]]; then
# get the tests from the test schedule, but ignore our IGNORES
while read t; do
if [[ t =~ ignore:* ]]; then
t=${t##ignore:* }
IGNORES="${t} ${IGNORES}"
continue
fi
t=${t##test: }
if ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} ${t}"
fi
done < ${TEST_SCHEDULE}
else
PG_ISOLATION_REGRESS_OPTS="${PG_ISOLATION_REGRESS_OPTS} --schedule=${ISOLATION_TEST_SCHEDULE}"
fi
Expand All @@ -31,15 +57,8 @@ else
for t in ${EXE_DIR}/isolation/specs/*.spec; do
t=${t##${EXE_DIR}/isolation/specs/}
t=${t%.spec}
# we use the following chain of comparisons to properly handle the case
# where a test name is a substring of another
if [[ $FILTER = "$t" ]]; then # one test
TESTS="${TESTS} $t"
elif [[ $FILTER = "$t "* ]]; then # first test in the list
TESTS="${TESTS} $t"
elif [[ $FILTER = *" $t" ]]; then # last test in the list
TESTS="${TESTS} $t"
elif [[ $FILTER = *" $t "* ]]; then # test in middle of the list

if contains "${FILTER}" "${t}" && ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} $t"
fi
done
Expand Down
36 changes: 26 additions & 10 deletions test/pg_regress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,37 @@ EXE_DIR=$(dirname $0)
PG_REGRESS=${PG_REGRESS:-pg_regress}
TEST_SCHEDULE=${TEST_SCHEDULE:-}
TESTS=${TESTS:-}
IGNORES=${IGNORES:-}

contains() {
# a list contains a value foo if the regex ".* foo .*" holds true
[[ $1 =~ (.*[[:space:]]|^)$2([[:space:]].*|$) ]];
return $?
}

if [[ -z ${TESTS} ]]; then
if [[ -z ${TEST_SCHEDULE} ]]; then
for t in ${EXE_DIR}/sql/*.sql; do
t=${t##${EXE_DIR}/sql/}
t=${t%.sql}
TESTS="${TESTS} $t"

if ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} ${t}"
fi
done
elif [[ -n ${IGNORES} ]]; then
# get the tests from the test schedule, but ignore our IGNORES
while read t; do
if [[ t =~ ignore:* ]]; then
t=${t##ignore:* }
IGNORES="${t} ${IGNORES}"
continue
fi
t=${t##test: }
if ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} ${t}"
fi
done < ${TEST_SCHEDULE}
else
PG_REGRESS_OPTS="${PG_REGRESS_OPTS} --schedule=${TEST_SCHEDULE}"
fi
Expand All @@ -31,15 +54,8 @@ else
for t in ${EXE_DIR}/sql/*.sql; do
t=${t##${EXE_DIR}/sql/}
t=${t%.sql}
# we use the following chain of comparisons to properly handle the case
# where a test name is a substring of another
if [[ $FILTER = "$t" ]]; then # one test
TESTS="${TESTS} $t"
elif [[ $FILTER = "$t "* ]]; then # first test in the list
TESTS="${TESTS} $t"
elif [[ $FILTER = *" $t" ]]; then # last test in the list
TESTS="${TESTS} $t"
elif [[ $FILTER = *" $t "* ]]; then # test in middle of the list

if contains "${FILTER}" "${t}" && ! contains "${IGNORES}" "${t}"; then
TESTS="${TESTS} $t"
fi
done
Expand Down

0 comments on commit 9b52909

Please sign in to comment.