Tests: Add Metaclass for BitcoinTestFramework#12856
Tests: Add Metaclass for BitcoinTestFramework#12856laanwj merged 1 commit intobitcoin:masterfrom WillAyd:meta-tst
Conversation
There was a problem hiding this comment.
As is this is not integrated into your current CI. Still trying to wrap my head around everything so I could be wrong on this but since you are using your own test suite / runner which uses this meta class I don't think there's a great way to integrate into your current workflow. This can be tested directly from the command line as needed
There was a problem hiding this comment.
To more strictly enforce this protocol I had to add this here, even though it just calls the superclass implementation anyway. I figured this is cleaner than making an exception in the metaclass
There was a problem hiding this comment.
That's fine. ComparisonTestFramework should hopefully go away very soon (#11818)
|
Hmm have there been intermittent travis failures? I looked into both here but can't see how they would be directly related to the change. Here's a quick summary of them 26871.1 $ if [ "$CHECK_DOC" = 1 -a "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then contrib/devtools/lint-all.sh; fi
src/walletinitinterface.h seems to be missing the expected include guard:
#ifndef BITCOIN_WALLETINITINTERFACE_H
#define BITCOIN_WALLETINITINTERFACE_H
...
#endif // BITCOIN_WALLETINITINTERFACE_H
^---- failure generated from contrib/devtools/lint-include-guards.sh26871.3 File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-unknown-linux-gnu/test/functional/test_framework/mininode.py", line 213, in send_message
raise IOError('Not connected, no pushbuf')
OSError: Not connected, no pushbuf |
This failure is caused by a new linter. Rebasing on master will fix this for you. |
|
Concept ACK. I think the metaclass is useful to catch non-conforming tests. However, I think adding unit tests to test the test framework is probably overkill. I think I'd prefer this PR if the |
|
Easy enough to revert. Do you want me to include the metaclass directly in |
|
Jup, that saves one file and one import. I'd agree to that. |
|
Looks good. I'll ACK once commits are squashed. |
|
Looks like the failure here was on a make job on Travis but this change shouldn't not impact any compilation - any chance to restart that? |
|
I agree. Travis failure seems unrelated. I've restarted the job. |
|
Travis error is unrelated. utACK, this is very neat! Learned something new. |
BitcoinTestFramework instructs developers in its docstring to override `set_test_params` and `run_test` in subclasses while being sure NOT to override `__init__` and `main` . This change adds a metaclass to ensure that developers adhere to that protocol, raising a ``TypeError`` in instances where they have not. closes #12835
|
Concept ACK |
| for i in range(self.num_nodes): | ||
| initialize_datadir(self.options.tmpdir, i) | ||
|
|
||
|
|
There was a problem hiding this comment.
please remove stray newline
There was a problem hiding this comment.
That was intentional from our conversation in #12884. This would follow PEP8 so I figured bundle in here. OK to remove still if you want
There was a problem hiding this comment.
sure. Fine to leave it in.
|
utACK c9cce0a. (Seems fine to add the new line, since it is already done.) |
|
utACK c9cce0a |
c9cce0a Tests: Add Metaclass for BitcoinTestFramework (Will Ayd) Pull request description: BitcoinTestFramework instructs developers in its docstring to override `set_test_params` and `run_test` in subclasses while being sure NOT to override `__init__` and `main` . This change adds a metaclass to ensure that developers adhere to that protocol, raising a ``TypeError`` in instances where they have not. closes #12835 Tree-SHA512: 5a47a7ead1f18361138cad4374747c4a8f29d25506f7b2c2a8c1c966a0b65e5ccf7317f9a078df8680fdab5d3fb71fee46a159c9f381878a3683c1e9f874abbe
Summary: c9cce0a Tests: Add Metaclass for BitcoinTestFramework (Will Ayd) Pull request description: BitcoinTestFramework instructs developers in its docstring to override `set_test_params` and `run_test` in subclasses while being sure NOT to override `__init__` and `main` . This change adds a metaclass to ensure that developers adhere to that protocol, raising a ``TypeError`` in instances where they have not. closes #12835 Tree-SHA512: 5a47a7ead1f18361138cad4374747c4a8f29d25506f7b2c2a8c1c966a0b65e5ccf7317f9a078df8680fdab5d3fb71fee46a159c9f381878a3683c1e9f874abbe Backport of Core [[bitcoin/bitcoin#12856 | PR12856]] Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, nakihito Reviewed By: nakihito Differential Revision: https://reviews.bitcoinabc.org/D6353
Summary: c9cce0a Tests: Add Metaclass for BitcoinTestFramework (Will Ayd) Pull request description: BitcoinTestFramework instructs developers in its docstring to override `set_test_params` and `run_test` in subclasses while being sure NOT to override `__init__` and `main` . This change adds a metaclass to ensure that developers adhere to that protocol, raising a ``TypeError`` in instances where they have not. closes #12835 Tree-SHA512: 5a47a7ead1f18361138cad4374747c4a8f29d25506f7b2c2a8c1c966a0b65e5ccf7317f9a078df8680fdab5d3fb71fee46a159c9f381878a3683c1e9f874abbe Backport of Core [[bitcoin/bitcoin#12856 | PR12856]] Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, nakihito Reviewed By: nakihito Differential Revision: https://reviews.bitcoinabc.org/D6353
c9cce0a Tests: Add Metaclass for BitcoinTestFramework (Will Ayd) Pull request description: BitcoinTestFramework instructs developers in its docstring to override `set_test_params` and `run_test` in subclasses while being sure NOT to override `__init__` and `main` . This change adds a metaclass to ensure that developers adhere to that protocol, raising a ``TypeError`` in instances where they have not. closes bitcoin#12835 Tree-SHA512: 5a47a7ead1f18361138cad4374747c4a8f29d25506f7b2c2a8c1c966a0b65e5ccf7317f9a078df8680fdab5d3fb71fee46a159c9f381878a3683c1e9f874abbe
BitcoinTestFramework instructs developers in its docstring to override
set_test_paramsandrun_testin subclasses while being sure NOT tooverride
__init__andmain. This change adds a metaclass to ensurethat developers adhere to that protocol, raising a
TypeErrorininstances where they have not.
closes #12835