From 652a36b0f2501b370a1dbc72349b8f8b254b6040 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 15 May 2019 15:49:48 -0400 Subject: [PATCH] Merge #15943: tests: Fail if RPC has been added without tests fad0ce59e9 tests: Fail if RPC has been added without tests (MarcoFalke) Pull request description: Need to be run with --coverage ACKs for commit fad0ce: ryanofsky: utACK fad0ce59e9154f9b7e61907a71c740a942c60282. New comment in travis.yml is the only change since last review. Tree-SHA512: b53632dfe9865ec06991bfcba2fd67238bebbb866b355f09624eaf233257b2bca902caac6c24abb358b2f4c1c43f28ca75e30982765911e1a117102df65276d9 --- .travis.yml | 1 + ci/test_integrationtests.sh | 2 +- test/functional/rpc_misc.py | 8 ++++++++ test/functional/test_runner.py | 8 ++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34755430e0..b6fbd97406 100644 --- a/.travis.yml +++ b/.travis.yml @@ -239,6 +239,7 @@ after_success: HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" + TEST_RUNNER_EXTRA="--coverage --extended --exclude feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CFLAGS=\"-g0 -O2 -funsigned-char\" CXXFLAGS=\"-g0 -O2 -funsigned-char\"" diff --git a/ci/test_integrationtests.sh b/ci/test_integrationtests.sh index ac68ca36dd..ce95c09098 100755 --- a/ci/test_integrationtests.sh +++ b/ci/test_integrationtests.sh @@ -34,7 +34,7 @@ echo "Using socketevents mode: $SOCKETEVENTS" EXTRA_ARGS="--dashd-arg=-socketevents=$SOCKETEVENTS" set +e -./test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --failfast --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS $EXTRA_ARGS +./test/functional/test_runner.py --ci --combinedlogslen=4000 ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS $EXTRA_ARGS RESULT=$? set -e diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py index 7bf8e68176..8a3f8c6f06 100755 --- a/test/functional/rpc_misc.py +++ b/test/functional/rpc_misc.py @@ -46,5 +46,13 @@ class RpcMiscTest(BitcoinTestFramework): assert_raises_rpc_error(-8, "unknown mode foobar", node.getmemoryinfo, mode="foobar") + self.log.info("test logging") + assert_equal(node.logging()['qt'], True) + node.logging(exclude=['qt']) + assert_equal(node.logging()['qt'], False) + node.logging(include=['qt']) + assert_equal(node.logging()['qt'], True) + + if __name__ == '__main__': RpcMiscTest().main() diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index ad36770968..30399e5a1d 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -444,16 +444,18 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= print_results(test_results, max_len_name, (int(time.time() - start_time))) if coverage: - coverage.report_rpc_coverage() + coverage_passed = coverage.report_rpc_coverage() logging.debug("Cleaning up coverage data") coverage.cleanup() + else: + coverage_passed = True # Clear up the temp directory if all subdirectories are gone if not os.listdir(tmpdir): os.rmdir(tmpdir) - all_passed = all(map(lambda test_result: test_result.was_successful, test_results)) + all_passed = all(map(lambda test_result: test_result.was_successful, test_results)) and coverage_passed # This will be a no-op unless failfast is True in which case there may be dangling # processes which need to be killed. @@ -655,8 +657,10 @@ class RPCCoverage(): if uncovered: print("Uncovered RPC commands:") print("".join((" - %s\n" % command) for command in sorted(uncovered))) + return False else: print("All RPC commands covered.") + return True def cleanup(self): return shutil.rmtree(self.dir)