mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
60b3c5a64e
3d0a82cff8cbb809876e82dbe62d14d2adc07d94 devtools: Accomodate block-style copyright blocks (Ben Woosley) 0ef0e51fe4bb592e67255776b5a0ba04679fb8c4 lint: Bump flake8 to 3.7.8 (Ben Woosley) 838920704ad90a71cf288b700052503db8abb17e lint: Disable flake8 W504 warning (Ben Woosley) b21680baf5391a602b295b9d7d0ef66553661cb9 test/contrib: Fix invalid escapes in regex strings (Ben Woosley) Pull request description: This is a second go at #15221, fixing new lints in: W504 line break after binary operator W605 invalid escape sequence F841 local variable 'e' is assigned to but never used This time around: * One commit per rule, for easier review * I went with the PEP-8 style of breaking before binary operators * I looked into the raw regex newline issue, and found that raw strings with newlines embedded do work appropriately. E.g. run `re.match(r" \n ", " \n ")` to check this for yourself. `re.MULTILINE` exists to modify `^` and `$` in multiline scenarios, but all of these searches are per-line. ACKs for top commit: practicalswift: ACK 3d0a82cff8cbb809876e82dbe62d14d2adc07d94 -- diff looks correct Tree-SHA512: bea0c144cadd72e4adf2e9a4b4ee0535dd91a8e694206924cf8a389dc9253f364a717edfe9abda88108fbb67fda19b9e823f46822d7303c0aaa72e48909a6105
76 lines
2.9 KiB
Python
Executable File
76 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test debug logging."""
|
|
|
|
import os
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.test_node import ErrorMatch
|
|
|
|
|
|
class LoggingTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 1
|
|
self.setup_clean_chain = True
|
|
|
|
def relative_log_path(self, name):
|
|
return os.path.join(self.nodes[0].datadir, self.chain, name)
|
|
|
|
def run_test(self):
|
|
# test default log file name
|
|
default_log_path = self.relative_log_path("debug.log")
|
|
assert os.path.isfile(default_log_path)
|
|
|
|
# test alternative log file name in datadir
|
|
self.restart_node(0, ["-debuglogfile=foo.log"])
|
|
assert os.path.isfile(self.relative_log_path("foo.log"))
|
|
|
|
# test alternative log file name outside datadir
|
|
tempname = os.path.join(self.options.tmpdir, "foo.log")
|
|
self.restart_node(0, ["-debuglogfile=%s" % tempname])
|
|
assert os.path.isfile(tempname)
|
|
|
|
# check that invalid log (relative) will cause error
|
|
invdir = self.relative_log_path("foo")
|
|
invalidname = os.path.join("foo", "foo.log")
|
|
self.stop_node(0)
|
|
exp_stderr = r"Error: Could not open debug log file \S+$"
|
|
self.nodes[0].assert_start_raises_init_error(["-debuglogfile=%s" % (invalidname)], exp_stderr, match=ErrorMatch.FULL_REGEX)
|
|
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
|
|
|
|
# check that invalid log (relative) works after path exists
|
|
self.stop_node(0)
|
|
os.mkdir(invdir)
|
|
self.start_node(0, ["-debuglogfile=%s" % (invalidname)])
|
|
assert os.path.isfile(os.path.join(invdir, "foo.log"))
|
|
|
|
# check that invalid log (absolute) will cause error
|
|
self.stop_node(0)
|
|
invdir = os.path.join(self.options.tmpdir, "foo")
|
|
invalidname = os.path.join(invdir, "foo.log")
|
|
self.nodes[0].assert_start_raises_init_error(["-debuglogfile=%s" % invalidname], exp_stderr, match=ErrorMatch.FULL_REGEX)
|
|
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
|
|
|
|
# check that invalid log (absolute) works after path exists
|
|
self.stop_node(0)
|
|
os.mkdir(invdir)
|
|
self.start_node(0, ["-debuglogfile=%s" % (invalidname)])
|
|
assert os.path.isfile(os.path.join(invdir, "foo.log"))
|
|
|
|
# check that -nodebuglogfile disables logging
|
|
self.stop_node(0)
|
|
os.unlink(default_log_path)
|
|
assert not os.path.isfile(default_log_path)
|
|
self.start_node(0, ["-nodebuglogfile"])
|
|
assert not os.path.isfile(default_log_path)
|
|
|
|
# just sanity check no crash here
|
|
self.stop_node(0)
|
|
self.start_node(0, ["-debuglogfile=%s" % os.devnull])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
LoggingTest().main()
|