Skip to content

Commit fa43626

Browse files
author
MarcoFalke
committed
test_runner: Remove travis specific code
1 parent 6a095bc commit fa43626

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ test_script:
6161
- ps: src\bench_bitcoin.exe -evals=1 -scaling=0
6262
- ps: python test\util\bitcoin-util-test.py
6363
- cmd: python test\util\rpcauth-test.py
64-
- cmd: python test\functional\test_runner.py --force --quiet --combinedlogslen=4000
64+
- cmd: python test\functional\test_runner.py --ci --force --quiet --combinedlogslen=4000
6565
deploy: off

.travis/test_06_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ fi
6262

6363
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
6464
BEGIN_FOLD functional-tests
65-
DOCKER_EXEC test/functional/test_runner.py --combinedlogslen=4000 --coverage --quiet --failfast ${extended}
65+
DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended}
6666
END_FOLD
6767
fi

test/functional/test_runner.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
TEST_EXIT_PASSED = 0
6969
TEST_EXIT_SKIPPED = 77
7070

71-
# 20 minutes represented in seconds
72-
TRAVIS_TIMEOUT_DURATION = 20 * 60
73-
7471
BASE_SCRIPTS = [
7572
# Scripts that are run by the travis build process.
7673
# Longest test should go first, to favor running tests in parallel
@@ -216,6 +213,7 @@ def main():
216213
formatter_class=argparse.RawTextHelpFormatter)
217214
parser.add_argument('--combinedlogslen', '-c', type=int, default=0, help='print a combined log (of length n lines) from all test nodes and test framework to the console on failure.')
218215
parser.add_argument('--coverage', action='store_true', help='generate a basic coverage report for the RPC interface')
216+
parser.add_argument('--ci', action='store_true', help='Run checks and code that are usually only enabled in a continuous integration environment')
219217
parser.add_argument('--exclude', '-x', help='specify a comma-separated-list of scripts to exclude.')
220218
parser.add_argument('--extended', action='store_true', help='run the extended test suite in addition to the basic tests')
221219
parser.add_argument('--force', '-f', action='store_true', help='run tests even on platforms where they are disabled by default (e.g. windows).')
@@ -306,25 +304,26 @@ def main():
306304
subprocess.check_call([sys.executable, os.path.join(config["environment"]["SRCDIR"], 'test', 'functional', test_list[0].split()[0]), '-h'])
307305
sys.exit(0)
308306

309-
check_script_list(config["environment"]["SRCDIR"])
307+
check_script_list(src_dir=config["environment"]["SRCDIR"], fail_on_warn=args.ci)
310308
check_script_prefixes()
311309

312310
if not args.keepcache:
313311
shutil.rmtree("%s/test/cache" % config["environment"]["BUILDDIR"], ignore_errors=True)
314312

315313
run_tests(
316-
test_list,
317-
config["environment"]["SRCDIR"],
318-
config["environment"]["BUILDDIR"],
319-
tmpdir,
314+
test_list=test_list,
315+
src_dir=config["environment"]["SRCDIR"],
316+
build_dir=config["environment"]["BUILDDIR"],
317+
tmpdir=tmpdir,
320318
jobs=args.jobs,
321319
enable_coverage=args.coverage,
322320
args=passon_args,
323321
combined_logs_len=args.combinedlogslen,
324-
failfast=args.failfast
322+
failfast=args.failfast,
323+
runs_ci=args.ci,
325324
)
326325

327-
def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False):
326+
def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, runs_ci):
328327
args = args or []
329328

330329
# Warn if bitcoind is already running (unix only)
@@ -359,7 +358,14 @@ def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=Fal
359358
raise
360359

361360
#Run Tests
362-
job_queue = TestHandler(jobs, tests_dir, tmpdir, test_list, flags)
361+
job_queue = TestHandler(
362+
num_tests_parallel=jobs,
363+
tests_dir=tests_dir,
364+
tmpdir=tmpdir,
365+
test_list=test_list,
366+
flags=flags,
367+
timeout_duration=20 * 60 if runs_ci else float('inf'), # in seconds
368+
)
363369
start_time = time.time()
364370
test_results = []
365371

@@ -440,11 +446,12 @@ class TestHandler:
440446
Trigger the test scripts passed in via the list.
441447
"""
442448

443-
def __init__(self, num_tests_parallel, tests_dir, tmpdir, test_list=None, flags=None):
444-
assert(num_tests_parallel >= 1)
449+
def __init__(self, *, num_tests_parallel, tests_dir, tmpdir, test_list, flags, timeout_duration):
450+
assert num_tests_parallel >= 1
445451
self.num_jobs = num_tests_parallel
446452
self.tests_dir = tests_dir
447453
self.tmpdir = tmpdir
454+
self.timeout_duration = timeout_duration
448455
self.test_list = test_list
449456
self.flags = flags
450457
self.num_running = 0
@@ -479,7 +486,7 @@ def get_next(self):
479486
time.sleep(.5)
480487
for job in self.jobs:
481488
(name, start_time, proc, testdir, log_out, log_err) = job
482-
if os.getenv('TRAVIS') == 'true' and int(time.time() - start_time) > TRAVIS_TIMEOUT_DURATION:
489+
if int(time.time() - start_time) > self.timeout_duration:
483490
# In travis, timeout individual tests (to stop tests hanging and not providing useful output).
484491
proc.send_signal(signal.SIGINT)
485492
if proc.poll() is not None:
@@ -557,7 +564,7 @@ def check_script_prefixes():
557564
raise AssertionError("Some tests are not following naming convention!")
558565

559566

560-
def check_script_list(src_dir):
567+
def check_script_list(*, src_dir, fail_on_warn):
561568
"""Check scripts directory.
562569
563570
Check that there are no scripts in the functional tests directory which are
@@ -567,10 +574,11 @@ def check_script_list(src_dir):
567574
missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS)))
568575
if len(missed_tests) != 0:
569576
print("%sWARNING!%s The following scripts are not being run: %s. Check the test lists in test_runner.py." % (BOLD[1], BOLD[0], str(missed_tests)))
570-
if os.getenv('TRAVIS') == 'true':
577+
if fail_on_warn:
571578
# On travis this warning is an error to prevent merging incomplete commits into master
572579
sys.exit(1)
573580

581+
574582
class RPCCoverage():
575583
"""
576584
Coverage reporting utilities for test_runner.

0 commit comments

Comments
 (0)