test-cli: Pass -v/--verbose flag to Go integration tests (#7754)
Also remove -o/--list-integration-tests, this flag isn't really that useful.
This commit is contained in:
parent
b0bcbb12aa
commit
6692160ced
18
test.sh
18
test.sh
|
@ -17,6 +17,7 @@ STATUS="FAILURE"
|
||||||
RUN=()
|
RUN=()
|
||||||
UNIT_PACKAGES=()
|
UNIT_PACKAGES=()
|
||||||
UNIT_FLAGS=()
|
UNIT_FLAGS=()
|
||||||
|
INTEGRATION_FLAGS=()
|
||||||
FILTER=()
|
FILTER=()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -39,11 +40,6 @@ function print_outcome() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_list_of_integration_tests() {
|
|
||||||
go test -tags integration -list=. ./test/integration/... | grep '^Test'
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function exit_msg() {
|
function exit_msg() {
|
||||||
# complain to STDERR and exit with error
|
# complain to STDERR and exit with error
|
||||||
echo "$*" >&2
|
echo "$*" >&2
|
||||||
|
@ -101,7 +97,7 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
|
||||||
|
|
||||||
-l, --lints Adds lint to the list of tests to run
|
-l, --lints Adds lint to the list of tests to run
|
||||||
-u, --unit Adds unit to the list of tests to run
|
-u, --unit Adds unit to the list of tests to run
|
||||||
-v, --unit-verbose Enables verbose output for unit tests
|
-v, --verbose Enables verbose output for unit and integration tests
|
||||||
-w, --unit-without-cache Disables go test caching for unit tests
|
-w, --unit-without-cache Disables go test caching for unit tests
|
||||||
-p <DIR>, --unit-test-package=<DIR> Run unit tests for specific go package(s)
|
-p <DIR>, --unit-test-package=<DIR> Run unit tests for specific go package(s)
|
||||||
-e, --enable-race-detection Enables race detection for unit and integration tests
|
-e, --enable-race-detection Enables race detection for unit and integration tests
|
||||||
|
@ -109,7 +105,6 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
|
||||||
-i, --integration Adds integration to the list of tests to run
|
-i, --integration Adds integration to the list of tests to run
|
||||||
-s, --start-py Adds start to the list of tests to run
|
-s, --start-py Adds start to the list of tests to run
|
||||||
-g, --generate Adds generate to the list of tests to run
|
-g, --generate Adds generate to the list of tests to run
|
||||||
-o, --list-integration-tests Outputs a list of the available integration tests
|
|
||||||
-f <REGEX>, --filter=<REGEX> Run only those tests matching the regular expression
|
-f <REGEX>, --filter=<REGEX> Run only those tests matching the regular expression
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -125,7 +120,7 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
|
||||||
EOM
|
EOM
|
||||||
)"
|
)"
|
||||||
|
|
||||||
while getopts luvweciosmgnhp:f:-: OPT; do
|
while getopts luvwecismgnhp:f:-: OPT; do
|
||||||
if [ "$OPT" = - ]; then # long option: reformulate OPT and OPTARG
|
if [ "$OPT" = - ]; then # long option: reformulate OPT and OPTARG
|
||||||
OPT="${OPTARG%%=*}" # extract long option name
|
OPT="${OPTARG%%=*}" # extract long option name
|
||||||
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
|
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
|
||||||
|
@ -134,12 +129,11 @@ while getopts luvweciosmgnhp:f:-: OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
l | lints ) RUN+=("lints") ;;
|
l | lints ) RUN+=("lints") ;;
|
||||||
u | unit ) RUN+=("unit") ;;
|
u | unit ) RUN+=("unit") ;;
|
||||||
v | unit-verbose ) UNIT_FLAGS+=("-v") ;;
|
v | verbose ) UNIT_FLAGS+=("-v"); INTEGRATION_FLAGS+=("-v") ;;
|
||||||
w | unit-without-cache ) UNIT_FLAGS+=("-count=1") ;;
|
w | unit-without-cache ) UNIT_FLAGS+=("-count=1") ;;
|
||||||
p | unit-test-package ) check_arg; UNIT_PACKAGES+=("${OPTARG}") ;;
|
p | unit-test-package ) check_arg; UNIT_PACKAGES+=("${OPTARG}") ;;
|
||||||
e | enable-race-detection ) RACE="true"; UNIT_FLAGS+=("-race") ;;
|
e | enable-race-detection ) RACE="true"; UNIT_FLAGS+=("-race") ;;
|
||||||
i | integration ) RUN+=("integration") ;;
|
i | integration ) RUN+=("integration") ;;
|
||||||
o | list-integration-tests ) print_list_of_integration_tests ;;
|
|
||||||
f | filter ) check_arg; FILTER+=("${OPTARG}") ;;
|
f | filter ) check_arg; FILTER+=("${OPTARG}") ;;
|
||||||
s | start-py ) RUN+=("start") ;;
|
s | start-py ) RUN+=("start") ;;
|
||||||
g | generate ) RUN+=("generate") ;;
|
g | generate ) RUN+=("generate") ;;
|
||||||
|
@ -244,7 +238,11 @@ STAGE="integration"
|
||||||
if [[ "${RUN[@]}" =~ "$STAGE" ]] ; then
|
if [[ "${RUN[@]}" =~ "$STAGE" ]] ; then
|
||||||
print_heading "Running Integration Tests"
|
print_heading "Running Integration Tests"
|
||||||
flush_redis
|
flush_redis
|
||||||
|
if [[ "${INTEGRATION_FLAGS[@]}" =~ "-v" ]] ; then
|
||||||
|
python3 test/integration-test.py --chisel --gotestverbose "${FILTER[@]}"
|
||||||
|
else
|
||||||
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
|
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test that just ./start.py works, which is a proxy for testing that
|
# Test that just ./start.py works, which is a proxy for testing that
|
||||||
|
|
|
@ -34,7 +34,7 @@ race_detection = True
|
||||||
if os.environ.get('RACE', 'true') != 'true':
|
if os.environ.get('RACE', 'true') != 'true':
|
||||||
race_detection = False
|
race_detection = False
|
||||||
|
|
||||||
def run_go_tests(filterPattern=None):
|
def run_go_tests(filterPattern=None,verbose=False):
|
||||||
"""
|
"""
|
||||||
run_go_tests launches the Go integration tests. The go test command must
|
run_go_tests launches the Go integration tests. The go test command must
|
||||||
return zero or an exception will be raised. If the filterPattern is provided
|
return zero or an exception will be raised. If the filterPattern is provided
|
||||||
|
@ -43,7 +43,10 @@ def run_go_tests(filterPattern=None):
|
||||||
cmdLine = ["go", "test"]
|
cmdLine = ["go", "test"]
|
||||||
if filterPattern is not None and filterPattern != "":
|
if filterPattern is not None and filterPattern != "":
|
||||||
cmdLine = cmdLine + ["--test.run", filterPattern]
|
cmdLine = cmdLine + ["--test.run", filterPattern]
|
||||||
cmdLine = cmdLine + ["-tags", "integration", "-count=1", "-race", "./test/integration"]
|
cmdLine = cmdLine + ["-tags", "integration", "-count=1", "-race"]
|
||||||
|
if verbose:
|
||||||
|
cmdLine = cmdLine + ["-v"]
|
||||||
|
cmdLine = cmdLine + ["./test/integration"]
|
||||||
subprocess.check_call(cmdLine, stderr=subprocess.STDOUT)
|
subprocess.check_call(cmdLine, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
exit_status = 1
|
exit_status = 1
|
||||||
|
@ -54,6 +57,8 @@ def main():
|
||||||
help="run integration tests using chisel")
|
help="run integration tests using chisel")
|
||||||
parser.add_argument('--gotest', dest="run_go", action="store_true",
|
parser.add_argument('--gotest', dest="run_go", action="store_true",
|
||||||
help="run Go integration tests")
|
help="run Go integration tests")
|
||||||
|
parser.add_argument('--gotestverbose', dest="run_go_verbose", action="store_true",
|
||||||
|
help="run Go integration tests with verbose output")
|
||||||
parser.add_argument('--filter', dest="test_case_filter", action="store",
|
parser.add_argument('--filter', dest="test_case_filter", action="store",
|
||||||
help="Regex filter for test cases")
|
help="Regex filter for test cases")
|
||||||
# allow any ACME client to run custom command for integration
|
# allow any ACME client to run custom command for integration
|
||||||
|
@ -90,7 +95,10 @@ def main():
|
||||||
run_chisel(args.test_case_filter)
|
run_chisel(args.test_case_filter)
|
||||||
|
|
||||||
if args.run_go:
|
if args.run_go:
|
||||||
run_go_tests(args.test_case_filter)
|
run_go_tests(args.test_case_filter, False)
|
||||||
|
|
||||||
|
if args.run_go_verbose:
|
||||||
|
run_go_tests(args.test_case_filter, True)
|
||||||
|
|
||||||
if args.custom:
|
if args.custom:
|
||||||
run(args.custom.split())
|
run(args.custom.split())
|
||||||
|
|
Loading…
Reference in New Issue