The error message given if passing an existing dir to --tmpdir is confusing so this makes it clear that the directory must not already exist
This change is motivated by this comment #29335 (comment)
The error message given if passing an existing dir to --tmpdir is confusing so this makes it clear that the directory must not already exist
This change is motivated by this comment #29335 (comment)
The error message given if passing an existing dir to --tmpdir is
confusing so this makes it clear that the directory must not already
exist
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For detailed information about the code coverage, see the test coverage report.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | maflcko, davidgumberg |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Might you be able to modify the message as well? It will be the most available info when people encounter it.
lgtm ACK d4e36ae80d4b3f03647fd9057461edf7ecd794a3
Updated in be027e0 I added a line to enable logging and it now gives this error which it did not before because it would throw an error because logging was not enabled
New Error message
./test/functional/feature_bind_port_discover.py --tmpdir=./temp
2024-03-12T23:08:06.633000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
self.setup()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 267, in setup
os.makedirs(self.options.tmpdir, exist_ok=False)
File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/Users/kevkevin/DEVDIR/bitcoin/temp'
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/./test/functional/feature_bind_port_discover.py", line 78, in <module>
BindPortDiscoverTest().main()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 154, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 310, in shutdown
self.network_thread.close()
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close'
Previous Error message
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
self.setup()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 266, in setup
os.makedirs(self.options.tmpdir, exist_ok=False)
File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/Users/kevkevin/DEVDIR/bitcoin/temp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 148, in main
self.log.exception("Unexpected exception caught during testing")
^^^^^^^^
AttributeError: 'BindPortDiscoverTest' object has no attribute 'log'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/./test/functional/feature_bind_port_discover.py", line 78, in <module>
BindPortDiscoverTest().main()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 154, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 304, in shutdown
if self.success == TestStatus.FAILED and self.options.pdbonfailure:
^^^^^^^^^^^^
AttributeError: 'BindPortDiscoverTest' object has no attribute 'success'
I may want to find a way to remove the logs after FileExistsError: [Errno 17] File exists: '/Users/kevkevin/DEVDIR/bitcoin/temp' to make this error more clear
force pushed once more eb28434
the error log now makes sense
./test/functional/feature_bind_port_discover.py --tmpdir=./temp
2024-03-12T23:12:18.583000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
self.setup()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 267, in setup
os.makedirs(self.options.tmpdir, exist_ok=False)
File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/Users/kevkevin/DEVDIR/bitcoin/temp'
2024-03-12T23:12:18.584000Z TestFramework (INFO): Stopping nodes
2024-03-12T23:12:18.584000Z TestFramework (WARNING): Not cleaning up dir /Users/kevkevin/DEVDIR/bitcoin/temp
2024-03-12T23:12:18.584000Z TestFramework (ERROR): Test failed. Test logging available at /Users/kevkevin/DEVDIR/bitcoin/temp/test_framework.log
2024-03-12T23:12:18.584000Z TestFramework (ERROR):
2024-03-12T23:12:18.584000Z TestFramework (ERROR): Hint: Call /Users/kevkevin/DEVDIR/bitcoin/test/functional/combine_logs.py '/Users/kevkevin/DEVDIR/bitcoin/temp' to consolidate all logs
2024-03-12T23:12:18.584000Z TestFramework (ERROR):
2024-03-12T23:12:18.584000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-03-12T23:12:18.585000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
2024-03-12T23:12:18.585000Z TestFramework (ERROR):
new error log in c5eb4688a90577c573861cc56f10c9dac15f97de
let me know if you want to change the verbiage and if the dir exists we use the default location and then raise and exception
./test/functional/p2p_tx_privacy.py --tmpdir=./tmp
2024-03-13T01:48:26.199000Z TestFramework (ERROR): The tmpdir must not already exist ./tmp
2024-03-13T01:48:26.200000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
self.setup()
File "/Users/kevkevin/DEVDIR/bitcoin/test/functional/test_framework/test_framework.py", line 268, in setup
os.makedirs(self.options.tmpdir, exist_ok=False)
File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/Users/kevkevin/DEVDIR/bitcoin/tmp'
2024-03-13T01:48:26.201000Z TestFramework (INFO): Stopping nodes
2024-03-13T01:48:26.201000Z TestFramework (WARNING): Not cleaning up dir /var/folders/9g/cvx014yx4dq5lwl_x5zvn_j80000gn/T/bitcoin_func_test_9s71cl9w
2024-03-13T01:48:26.201000Z TestFramework (ERROR): Test failed. Test logging available at /var/folders/9g/cvx014yx4dq5lwl_x5zvn_j80000gn/T/bitcoin_func_test_9s71cl9w/test_framework.log
2024-03-13T01:48:26.201000Z TestFramework (ERROR):
2024-03-13T01:48:26.201000Z TestFramework (ERROR): Hint: Call /Users/kevkevin/DEVDIR/bitcoin/test/functional/combine_logs.py '/var/folders/9g/cvx014yx4dq5lwl_x5zvn_j80000gn/T/bitcoin_func_test_9s71cl9w' to consolidate all logs
2024-03-13T01:48:26.201000Z TestFramework (ERROR):
2024-03-13T01:48:26.201000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-03-13T01:48:26.201000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
2024-03-13T01:48:26.202000Z TestFramework (ERROR):
269 | + self.options.tmpdir = os.path.abspath(tmpdirpath) 270 | + os.makedirs(self.options.tmpdir, exist_ok=False) 271 | + except Exception: 272 | + self.options.tmpdir = tempfile.mkdtemp(prefix=TMPDIR_PREFIX) 273 | + self._start_logging() 274 | + self.log.error("The tmpdir must not already exist {}".format(tmpdirpath))
Not sure about using a different tempdir than the one the user asked for as fallback to start logging.
I don't think code needs to be written for users that fail to read the docs, and also fail to read the python stacktrace?
yup that makes sense and I agree reverting back to https://github.com/bitcoin/bitcoin/commit/d4e36ae80d4b3f03647fd9057461edf7ecd794a3
rfm?