mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
Auto merge of #10238 - jdm:winunit, r=larsbergstrom
Run unit tests on appveyor <!-- 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/10238) <!-- Reviewable:end -->
This commit is contained in:
commit
e148571812
6 changed files with 60 additions and 7 deletions
|
@ -8,7 +8,6 @@ use net::cookie::Cookie;
|
|||
use net::cookie_storage::CookieStorage;
|
||||
use net_traits::CookieSource;
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_domain_match() {
|
||||
assert!(Cookie::domain_match("foo.com", "foo.com"));
|
||||
|
@ -100,6 +99,20 @@ fn fn_cookie_constructor() {
|
|||
assert!(Cookie::new_wrapped(cookie, u, CookieSource::HTTP).is_some());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn delay_to_ensure_different_timestamp() {
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
// time::now()'s resolution on some platforms isn't granular enought to ensure
|
||||
// that two back-to-back calls to Cookie::new_wrapped generate different timestamps .
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn delay_to_ensure_different_timestamp() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sort_order() {
|
||||
use std::cmp::Ordering;
|
||||
|
@ -107,6 +120,7 @@ fn test_sort_order() {
|
|||
let url = &url!("http://example.com/foo");
|
||||
let a_wrapped = cookie_rs::Cookie::parse("baz=bar; Path=/foo/bar/").unwrap();
|
||||
let a = Cookie::new_wrapped(a_wrapped.clone(), url, CookieSource::HTTP).unwrap();
|
||||
delay_to_ensure_different_timestamp();
|
||||
let a_prime = Cookie::new_wrapped(a_wrapped, url, CookieSource::HTTP).unwrap();
|
||||
let b = cookie_rs::Cookie::parse("baz=bar;Path=/foo/bar/baz/").unwrap();
|
||||
let b = Cookie::new_wrapped(b, url, CookieSource::HTTP).unwrap();
|
||||
|
|
|
@ -19,12 +19,11 @@ use hyper::status::StatusCode;
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use net::cookie::Cookie;
|
||||
use net::cookie_storage::CookieStorage;
|
||||
use net::hsts::{HSTSList, HSTSEntry};
|
||||
use net::hsts::HSTSEntry;
|
||||
use net::http_loader::{load, LoadError, HttpRequestFactory, HttpRequest, HttpResponse, HttpState};
|
||||
use net::resource_thread::{AuthCacheEntry, CancellationListener};
|
||||
use net_traits::{LoadData, CookieSource, LoadContext, IncludeSubdomains};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::io::{self, Write, Read, Cursor};
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::sync::{Arc, mpsc, RwLock};
|
||||
|
|
|
@ -5,9 +5,15 @@
|
|||
use std::path::Path;
|
||||
use util::opts::parse_url_or_filename;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
const FAKE_CWD: &'static str = "/fake/cwd";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const FAKE_CWD: &'static str = "C:/fake/cwd";
|
||||
|
||||
#[test]
|
||||
fn test_argument_parsing() {
|
||||
let fake_cwd = Path::new("/fake/cwd");
|
||||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
assert!(parse_url_or_filename(fake_cwd, "http://example.net:invalid").is_err());
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "http://example.net").unwrap();
|
||||
|
@ -16,10 +22,33 @@ fn test_argument_parsing() {
|
|||
let url = parse_url_or_filename(fake_cwd, "file:///foo/bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["foo", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn test_file_path_parsing() {
|
||||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["fake", "cwd", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn test_file_path_parsing() {
|
||||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
|
||||
let url = parse_url_or_filename(fake_cwd, "bar.html").unwrap();
|
||||
assert_eq!(url.scheme, "file");
|
||||
assert_eq!(url.path().unwrap(), ["C:", "fake", "cwd", "bar.html"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
// Windows file paths can't contain ?
|
||||
fn test_argument_parsing_special() {
|
||||
let fake_cwd = Path::new(FAKE_CWD);
|
||||
|
||||
// '?' and '#' have a special meaning in URLs...
|
||||
let url = parse_url_or_filename(fake_cwd, "file:///foo/bar?baz#buzz.html").unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue