servo: Merge #18710 - Replace rustc_serialize with serde_json in style_tests (from mhaessig:remove-rustc-serialize); r=jdm
authorManuel Hässig <mhaessig@users.noreply.github.com>
Wed, 15 Nov 2017 17:09:21 -0600
changeset 436636 99d239e2db3fd53fab51ab5a3fbeca2b28a970eb
parent 436635 b91ed20197290025a3cdd0dcdff1d0643849db06
child 436637 2c05266833a771d4e9969226e04023cf3acd5155
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersjdm
milestone59.0a1
servo: Merge #18710 - Replace rustc_serialize with serde_json in style_tests (from mhaessig:remove-rustc-serialize); r=jdm #12410 Stop using rustc_serialize Replaced rustc_serialize with serde_json in - [ ] ~~components/config/Cargo.toml~~ - [ ] ~~components/config/lib.rs~~ - [ ] ~~components/config/prefs.rs~~ - [ ] ~~components/script_traits/Cargo.toml~~ - [ ] ~~components/script_traits/lib.rs~~ - [ ] ~~components/script_traits/webdriver_msg.rs~~ - [ ] ~~components/webdriver_server/Cargo.toml~~ - [ ] ~~components/webdriver_server/lib.rs~~ - [X] tests/unit/style/Cargo.toml - [X] test/unit/style/lib.rs - [X] test/unit/style/properties/scaffolding.rs PR checks: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [X] These changes fix (partially) #12410. - [X] These changes do not require tests because functionality was not changed or a test itself was edited Source-Repo: https://github.com/servo/servo Source-Revision: 2977a4e26e0691dad8b640b47edbf77968d97d5a
servo/Cargo.lock
servo/tests/unit/style/Cargo.toml
servo/tests/unit/style/lib.rs
servo/tests/unit/style/properties/scaffolding.rs
--- a/servo/Cargo.lock
+++ b/servo/Cargo.lock
@@ -3227,18 +3227,18 @@ version = "0.0.1"
 dependencies = [
  "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "html5ever 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.19.0",
+ "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "servo_arc 0.0.1",
  "servo_atoms 0.0.1",
  "servo_config 0.0.1",
  "servo_url 0.0.1",
  "size_of_test 0.0.1",
  "style 0.0.1",
  "style_traits 0.0.1",
 ]
--- a/servo/tests/unit/style/Cargo.toml
+++ b/servo/tests/unit/style/Cargo.toml
@@ -12,17 +12,17 @@ doctest = false
 [dependencies]
 byteorder = "1.0"
 app_units = "0.5"
 cssparser = "0.22.0"
 euclid = "0.15"
 html5ever = "0.21"
 parking_lot = "0.4"
 rayon = "0.8"
-rustc-serialize = "0.3"
+serde_json = "1.0"
 selectors = {path = "../../../components/selectors"}
 servo_arc = {path = "../../../components/servo_arc"}
 servo_atoms = {path = "../../../components/atoms"}
 servo_config = {path = "../../../components/config"}
 servo_url = {path = "../../../components/url"}
 size_of_test = {path = "../../../components/size_of_test"}
 style = {path = "../../../components/style"}
 style_traits = {path = "../../../components/style_traits"}
--- a/servo/tests/unit/style/lib.rs
+++ b/servo/tests/unit/style/lib.rs
@@ -6,18 +6,18 @@
 #![feature(test)]
 
 extern crate app_units;
 extern crate cssparser;
 extern crate euclid;
 #[macro_use] extern crate html5ever;
 extern crate parking_lot;
 extern crate rayon;
-extern crate rustc_serialize;
 extern crate selectors;
+extern crate serde_json;
 extern crate servo_arc;
 extern crate servo_atoms;
 extern crate servo_config;
 extern crate servo_url;
 #[macro_use] extern crate size_of_test;
 #[macro_use] extern crate style;
 extern crate style_traits;
 extern crate test;
--- a/servo/tests/unit/style/properties/scaffolding.rs
+++ b/servo/tests/unit/style/properties/scaffolding.rs
@@ -1,13 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-use rustc_serialize::json::Json;
+use serde_json::{self, Value};
 use std::env;
 use std::fs::{File, remove_file};
 use std::path::Path;
 use std::process::Command;
 
 #[test]
 fn properties_list_json() {
     let top = Path::new(file!()).parent().unwrap().join("..").join("..").join("..").join("..");
@@ -20,20 +20,21 @@ fn properties_list_json() {
     let status = Command::new(python)
         .arg(&script)
         .arg("servo")
         .arg("html")
         .arg("regular")
         .status()
         .unwrap();
     assert!(status.success());
-    let properties = Json::from_reader(&mut File::open(json).unwrap()).unwrap();
+
+    let properties: Value = serde_json::from_reader(File::open(json).unwrap()).unwrap();
     assert!(properties.as_object().unwrap().len() > 100);
-    assert!(properties.find("margin").is_some());
-    assert!(properties.find("margin-top").is_some());
+    assert!(properties.as_object().unwrap().contains_key("margin"));
+    assert!(properties.as_object().unwrap().contains_key("margin-top"));
 }
 
 #[cfg(windows)]
 fn find_python() -> String {
     if Command::new("python2.7.exe").arg("--version").output().is_ok() {
         return "python2.7.exe".to_owned();
     }