Skip to content

Commit

Permalink
test-cli: Pass -v/--verbose flag to Go integration tests (#7754)
Browse files Browse the repository at this point in the history
Also remove -o/--list-integration-tests, this flag isn't really that
useful.
  • Loading branch information
beautifulentropy authored Oct 10, 2024
1 parent b0bcbb1 commit 6692160
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
20 changes: 9 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ STATUS="FAILURE"
RUN=()
UNIT_PACKAGES=()
UNIT_FLAGS=()
INTEGRATION_FLAGS=()
FILTER=()

#
Expand All @@ -39,11 +40,6 @@ function print_outcome() {
fi
}

function print_list_of_integration_tests() {
go test -tags integration -list=. ./test/integration/... | grep '^Test'
exit 0
}

function exit_msg() {
# complain to STDERR and exit with error
echo "$*" >&2
Expand Down Expand Up @@ -101,15 +97,14 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
-l, --lints Adds lint 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
-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
-n, --config-next Changes BOULDER_CONFIG_DIR from test/config to test/config-next
-i, --integration Adds integration 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
-o, --list-integration-tests Outputs a list of the available integration tests
-f <REGEX>, --filter=<REGEX> Run only those tests matching the regular expression
Note:
Expand All @@ -125,7 +120,7 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
EOM
)"

while getopts luvweciosmgnhp:f:-: OPT; do
while getopts luvwecismgnhp:f:-: OPT; do
if [ "$OPT" = - ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
Expand All @@ -134,12 +129,11 @@ while getopts luvweciosmgnhp:f:-: OPT; do
case "$OPT" in
l | lints ) RUN+=("lints") ;;
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") ;;
p | unit-test-package ) check_arg; UNIT_PACKAGES+=("${OPTARG}") ;;
e | enable-race-detection ) RACE="true"; UNIT_FLAGS+=("-race") ;;
i | integration ) RUN+=("integration") ;;
o | list-integration-tests ) print_list_of_integration_tests ;;
f | filter ) check_arg; FILTER+=("${OPTARG}") ;;
s | start-py ) RUN+=("start") ;;
g | generate ) RUN+=("generate") ;;
Expand Down Expand Up @@ -244,7 +238,11 @@ STAGE="integration"
if [[ "${RUN[@]}" =~ "$STAGE" ]] ; then
print_heading "Running Integration Tests"
flush_redis
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
if [[ "${INTEGRATION_FLAGS[@]}" =~ "-v" ]] ; then
python3 test/integration-test.py --chisel --gotestverbose "${FILTER[@]}"
else
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
fi
fi

# Test that just ./start.py works, which is a proxy for testing that
Expand Down
14 changes: 11 additions & 3 deletions test/integration-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if os.environ.get('RACE', 'true') != 'true':
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
return zero or an exception will be raised. If the filterPattern is provided
Expand All @@ -43,7 +43,10 @@ def run_go_tests(filterPattern=None):
cmdLine = ["go", "test"]
if filterPattern is not None and 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)

exit_status = 1
Expand All @@ -54,6 +57,8 @@ def main():
help="run integration tests using chisel")
parser.add_argument('--gotest', dest="run_go", action="store_true",
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",
help="Regex filter for test cases")
# allow any ACME client to run custom command for integration
Expand Down Expand Up @@ -90,7 +95,10 @@ def main():
run_chisel(args.test_case_filter)

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:
run(args.custom.split())
Expand Down

0 comments on commit 6692160

Please sign in to comment.