Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove implementation and add testing regarding file manager thread #11552
Conversation
highfive
commented
Jun 2, 2016
|
Heads up! This PR modifies the following files:
|
|
|
| @@ -27,7 +82,7 @@ fn test_filemanager() { | |||
| let _ = chan.send(FileManagerThreadMsg::SelectFile(tx)); | |||
|
|
|||
| match rx.try_recv() { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
977d445
to
2a53fdc
|
r? @Manishearth Not intended to bug you, just thinking it might be easier to track whatever decision I am making :P |
4761a04
to
04b0703
|
@Manishearth I just updated this. You might want to have a look if you got time :) |
| FileManagerThreadMsg::ReadFile(sender, id) => self.read_file(sender, id), | ||
| FileManagerThreadMsg::ReadFile(sender, id) => { | ||
| match self.try_read_file(id) { | ||
| Ok(buffer) => sender.send(Ok(buffer)).expect("FileManager send error"), |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 9, 2016
Member
Not expect, we should silently ignore the sending error.
send() fails if the receiver doesn't exist. This can happen if a content thread crashed, in this case. Content threads crashing should not bring down the chrome process.
(Basically, the chrome process should never crash unless it's an irrecoverable error for the entire browser)
04b0703
to
4f22598
highfive
commented
Jun 9, 2016
|
New code was committed to pull request. |
4f22598
to
49b1243
highfive
commented
Jun 9, 2016
|
New code was committed to pull request. |
| FileManagerThreadMsg::ReadFile(sender, id) => self.read_file(sender, id), | ||
| FileManagerThreadMsg::ReadFile(sender, id) => { | ||
| match self.try_read_file(id) { | ||
| Ok(buffer) => sender.send(Ok(buffer)).unwrap(), |
This comment has been minimized.
This comment has been minimized.
| Err(FileManagerThreadError::InvalidSelection) => {}, | ||
| _ => assert!(false, "Should be an invalid selection before dialog is implemented"), | ||
| if let Ok(vec) = msg { | ||
| assert!(test_file_content == vec, "Read content differs"); |
This comment has been minimized.
This comment has been minimized.
| if let Ok(mut handler) = opened { | ||
| handler.read_to_end(&mut test_file_content) | ||
| .expect("Read tests/unit/net/test.txt error"); | ||
| } |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 9, 2016
Member
We should just panic here via expect if opened is not OK, and get rid of the opened_ok checks later
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jun 9, 2016
Author
Contributor
Well, I made too loose an assumption before that the test.txt might not exist at all
… in FileManagerThreadMsg
49b1243
to
f8fa9aa
highfive
commented
Jun 9, 2016
|
New code was committed to pull request. |
|
|
||
| #[test] | ||
| fn test_filemanager() { | ||
| let chan: IpcSender<FileManagerThreadMsg> = FileManagerThreadFactory::new(); | ||
|
|
||
| // Try to open a dummy file "tests/unit/net/test.txt" in tree | ||
| let mut handler = File::open("test.txt").expect("test.txt is stolen"); |
This comment has been minimized.
This comment has been minimized.
| FileManagerThreadMsg::ReadFile(sender, id) => { | ||
| match self.try_read_file(id) { | ||
| Ok(buffer) => { let _ = sender.send(Ok(buffer)); } | ||
| Err(_) => { let _ = sender.send(Err(FileManagerThreadError::ReadFileError)); } |
This comment has been minimized.
This comment has been minimized.
|
@bors-servo r+ |
|
|
…arth
Improve implementation and add testing regarding file manager thread
First there is a more completed unit test. And in the test running, I found a runtime error `Serde(Custom("bincode does not support Deserializer::deserialize))` when reading response from file manage thread. I analyzed a bit and found that it is probably caused by the `Uuid` field. I temporarily work around it by making the `Id` essentially a string wrapped inside `SelectedFileId`.
Related to PR #11131.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
<!-- Either: -->
- [x] There are tests for these changes
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11552)
<!-- Reviewable:end -->
|
|
highfive
commented
Jun 9, 2016
|
|
@bors-servo: retry |
|
|
|
|
highfive
commented
Jun 9, 2016
|
|
@bors-servo: retry |
…arth
Improve implementation and add testing regarding file manager thread
First there is a more completed unit test. And in the test running, I found a runtime error `Serde(Custom("bincode does not support Deserializer::deserialize))` when reading response from file manage thread. I analyzed a bit and found that it is probably caused by the `Uuid` field. I temporarily work around it by making the `Id` essentially a string wrapped inside `SelectedFileId`.
Related to PR #11131.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
<!-- Either: -->
- [x] There are tests for these changes
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11552)
<!-- Reviewable:end -->
|
|
izgzhen commentedJun 2, 2016
•
edited
First there is a more completed unit test. And in the test running, I found a runtime error
Serde(Custom("bincode does not support Deserializer::deserialize))when reading response from file manage thread. I analyzed a bit and found that it is probably caused by theUuidfield. I temporarily work around it by making theIdessentially a string wrapped insideSelectedFileId.Related to PR #11131.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is