Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Update --tmpdir doc string to say directory must not exist #29498

Merged
merged 1 commit into from Apr 9, 2024

Conversation

kevkevinpal
Copy link
Contributor

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
@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 28, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

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.

@DrahtBot DrahtBot added the Tests label Feb 28, 2024
@Empact
Copy link
Member

Empact commented Feb 28, 2024

Might you be able to modify the message as well? It will be the most available info when people encounter it.

@maflcko
Copy link
Member

maflcko commented Feb 28, 2024

lgtm ACK d4e36ae

@kevkevinpal
Copy link
Contributor Author

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'

@kevkevinpal
Copy link
Contributor Author

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

@kevkevinpal
Copy link
Contributor Author

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):

@kevkevinpal kevkevinpal force-pushed the tmpDirDocString branch 2 times, most recently from d782db0 to 191b985 Compare March 13, 2024 01:46
@kevkevinpal kevkevinpal force-pushed the tmpDirDocString branch 5 times, most recently from be027e0 to eb28434 Compare March 13, 2024 01:47
@kevkevinpal
Copy link
Contributor Author

new error log in c5eb468

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):

@kevkevinpal kevkevinpal force-pushed the tmpDirDocString branch 2 times, most recently from c5eb468 to 09067cc Compare March 13, 2024 02:42
except Exception:
self.options.tmpdir = tempfile.mkdtemp(prefix=TMPDIR_PREFIX)
self._start_logging()
self.log.error("The tmpdir must not already exist {}".format(tmpdirpath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup that makes sense and I agree reverting back to d4e36ae

@maflcko
Copy link
Member

maflcko commented Mar 13, 2024

rfm?

@davidgumberg
Copy link
Contributor

ACK d4e36ae

@bitcoin bitcoin deleted a comment from Ashflower13 Apr 9, 2024
@fanquake fanquake merged commit a160a6a into bitcoin:master Apr 9, 2024
19 checks passed
Pttn added a commit to RiecoinTeam/Riecoin that referenced this pull request Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants