This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Fix for issue #89(Improve savestate error handling)
#92
Open
XuefengHuang
wants to merge
8
commits into
SeattleTestbed:master
Choose a base branch
from
XuefengHuang:fix-#89
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
00fc172
Improve `savestate` error handling.
XuefengHuang a5e4d7f
Added a unit test for savestate's error messages
XuefengHuang 7112869
Added an unit test for savestate command
XuefengHuang 41857af
Added an unit test for savestate command
XuefengHuang 1ca6cc6
Split this unit test into two unit tests
XuefengHuang fcb0243
Change another way to raise error message
XuefengHuang 507c1b4
Modify error message
XuefengHuang 4827887
Modify error message
XuefengHuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """ | ||
| This unit test is to test error messages at these situations. One is using | ||
| savestate before having loaded at least a pubkey, and work as that identity. | ||
| Another is using savestate to a write-protected file. | ||
| """ | ||
|
|
||
| import seash | ||
| import sys | ||
| import os | ||
| import seash_exceptions | ||
|
|
||
| #pragma out Please load at least a pubkey, and work as that identity. | ||
| #pragma out Don't use savestate to a write-protected file. | ||
|
|
||
| open('write_protected_file', 'w+').close() | ||
| os.system('chmod a-w write_protected_file') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work cross-platform (think Windows). |
||
|
|
||
| command_list = [ | ||
| 'savestate NO_KEYS_LOADED', | ||
| ] | ||
|
|
||
| try: | ||
| seash.command_loop(command_list) | ||
| except seash_exceptions.UserError, e: | ||
| print str(e) | ||
|
|
||
| command_list = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we would have the second test as a separate unit test file. Otherwise, you can't really say which of the tests failed. |
||
| 'loadkeys guest0', | ||
| 'as guest0', | ||
| 'savestate write_protected_file', | ||
| ] | ||
|
|
||
| try: | ||
| seash.command_loop(command_list) | ||
| except seash_exceptions.UserError, e: | ||
| print str(e) | ||
|
|
||
| os.remove('write_protected_file') | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the
TypeErrorabove) feel odd to check against, even if that is whatseash_helpercurrently raises.Can we make
seash_helperraise more appropriate exceptions? How do its other commands deal with situations like these?