Skip to content

Commit eb8dd08

Browse files
author
Daniel McCarney
authored
test: don't eat go test stdout, support filter. (letsencrypt#4432)
* Use `check_call` instead of `check_output`, we don't care about capturing the output and instead want it to go to stdout so test failures can be debugged. * Don't use `shell=True`, it isn't needed here. * Pipe through the test case filter so that it can be used with `--test.run` to limit the Go integration tests run.
1 parent 9906c93 commit eb8dd08

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ if [[ "$RUN" =~ "integration" ]] ; then
105105

106106
source ${CERTBOT_PATH:-/certbot}/${VENV_NAME:-venv}/bin/activate
107107
DIRECTORY=http://boulder:4000/directory \
108-
python2 test/integration-test.py --chisel "${args[@]}"
108+
python2 test/integration-test.py --chisel --gotest "${args[@]}"
109109
fi
110110

111111
# Test that just ./start.py works, which is a proxy for testing that

test/integration-test.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import re
1818
import requests
1919
import subprocess
20+
import shlex
2021
import signal
2122
import time
2223

@@ -38,8 +39,17 @@ def run_client_tests():
3839
cmd = os.path.join(root, 'tests', 'boulder-integration.sh')
3940
run(cmd, cwd=root)
4041

41-
def run_go_tests():
42-
run("go test -tags integration -count=1 ./test/integration")
42+
def run_go_tests(filterPattern=None):
43+
"""
44+
run_go_tests launches the Go integration tests. The go test command must
45+
return zero or an exception will be raised. If the filterPattern is provided
46+
it is used as the value of the `--test.run` argument to the go test command.
47+
"""
48+
cmdLine = [ "go", "test", ]
49+
if filterPattern is not None and filterPattern != "":
50+
cmdLine = cmdLine + ["--test.run", filterPattern]
51+
cmdLine = cmdLine + ["-tags", "integration", "-count=1", "./test/integration"]
52+
return subprocess.check_call(cmdLine, shell=False, stderr=subprocess.STDOUT)
4353

4454
def run_expired_authz_purger():
4555
# Note: This test must be run after all other tests that depend on
@@ -222,6 +232,8 @@ def main():
222232
help="run the certbot integration tests")
223233
parser.add_argument('--chisel', dest="run_chisel", action="store_true",
224234
help="run integration tests using chisel")
235+
parser.add_argument('--gotest', dest="run_go", action="store_true",
236+
help="run Go integration tests")
225237
parser.add_argument('--filter', dest="test_case_filter", action="store",
226238
help="Regex filter for test cases")
227239
# allow any ACME client to run custom command for integration
@@ -259,7 +271,8 @@ def main():
259271
if args.run_certbot:
260272
run_client_tests()
261273

262-
run_go_tests()
274+
if args.run_go:
275+
run_go_tests(args.test_case_filter)
263276

264277
if args.custom:
265278
run(args.custom)

0 commit comments

Comments
 (0)