aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/tests/fetch.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-12 13:33:45 -0400
committerGitHub <noreply@github.com>2018-09-12 13:33:45 -0400
commit910cc23a6e85cced43905f7615065b23bdb54b42 (patch)
tree3ceae959c0ebdf3f224c5c07f5b8c2cbd31dddf1 /components/net/tests/fetch.rs
parent9a83ab6297ddb62937fc54521b7fd4d19017e6b1 (diff)
parent2a996fbc8fef722b264389680cc55c25c46807d1 (diff)
downloadservo-910cc23a6e85cced43905f7615065b23bdb54b42.tar.gz
servo-910cc23a6e85cced43905f7615065b23bdb54b42.zip
Auto merge of #21325 - gterzian:crossbeam_integration, r=SimonSapin,jdm
Replace mpsc with crossbeam-channel Follow up on https://github.com/servo/servo/pull/19515 --- Selecting over multiple channels in `std::sync::mpsc` is not stable and likely never will be: https://github.com/rust-lang/rust/issues/27800#issuecomment-260136777 > It seems the only thing keeping `mpsc_select` around is Servo. crossbeam-channel is designed specifically to replace `std::sync::mpsc` and fix many of its shortcomings: https://github.com/stjepang/rfcs-crossbeam/blob/channel/text/2017-11-09-channel.md This is to be landed together with https://github.com/servo/ipc-channel/pull/183. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21325) <!-- Reviewable:end -->
Diffstat (limited to 'components/net/tests/fetch.rs')
-rw-r--r--components/net/tests/fetch.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs
index e71882de3e0..2e33727e37f 100644
--- a/components/net/tests/fetch.rs
+++ b/components/net/tests/fetch.rs
@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use {DEFAULT_USER_AGENT, new_fetch_context, create_embedder_proxy, fetch, make_server};
-use devtools_traits::DevtoolsControlMsg;
use devtools_traits::HttpRequest as DevtoolsHttpRequest;
use devtools_traits::HttpResponse as DevtoolsHttpResponse;
use fetch_with_context;
@@ -34,13 +33,13 @@ use net_traits::NetworkError;
use net_traits::ReferrerPolicy;
use net_traits::request::{Destination, Origin, RedirectMode, Referrer, Request, RequestMode};
use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
+use servo_channel::{channel, Sender};
use servo_url::{ImmutableOrigin, ServoUrl};
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicUsize, Ordering};
-use std::sync::mpsc::{Sender, channel};
use time::{self, Duration};
use unicase::UniCase;
@@ -774,17 +773,17 @@ fn test_fetch_redirect_updates_method() {
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
// make sure the test doesn't send more data than expected
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, Method::Post);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, Method::Get);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
let extension = Method::Extension("FOO".to_owned());
@@ -792,18 +791,18 @@ fn test_fetch_redirect_updates_method() {
assert_eq!(rx.recv().unwrap(), true);
// for MovedPermanently and Found, Method should only be changed if it was Post
assert_eq!(rx.recv().unwrap(), false);
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, extension.clone());
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), false);
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, extension.clone());
assert_eq!(rx.recv().unwrap(), true);
// for SeeOther, Method should always be changed, so this should be true
assert_eq!(rx.recv().unwrap(), true);
- assert_eq!(rx.try_recv().is_err(), true);
+ assert_eq!(rx.try_recv().is_none(), true);
}
fn response_is_done(response: &Response) -> bool {
@@ -912,7 +911,7 @@ fn test_fetch_with_devtools() {
let mut request = Request::new(url.clone(), Some(origin), Some(TEST_PIPELINE_ID));
request.referrer = Referrer::NoReferrer;
- let (devtools_chan, devtools_port) = channel::<DevtoolsControlMsg>();
+ let (devtools_chan, devtools_port) = channel();
let _ = fetch(&mut request, Some(devtools_chan));
let _ = server.close();