Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10855 - servo:unit, r=nox
Make css-properties.json checking a proper unit test. <!-- 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/10855) <!-- Reviewable:end -->
- Loading branch information
Showing
5 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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,53 @@ | ||
/* 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 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(".."); | ||
let json = top.join("target").join("doc").join("servo").join("css-properties.json"); | ||
if json.exists() { | ||
remove_file(&json).unwrap() | ||
} | ||
let python = env::var("PYTHON").ok().unwrap_or_else(find_python); | ||
let script = top.join("components").join("style").join("properties").join("build.py"); | ||
let status = Command::new(python) | ||
.arg(&script) | ||
.arg("servo") | ||
.arg("html") | ||
.status() | ||
.unwrap(); | ||
assert!(status.success()); | ||
let properties = Json::from_reader(&mut 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()); | ||
} | ||
|
||
#[cfg(windows)] | ||
fn find_python() -> String { | ||
if Command::new("python27.exe").arg("--version").output().is_ok() { | ||
return "python27.exe".to_owned(); | ||
} | ||
|
||
if Command::new("python.exe").arg("--version").output().is_ok() { | ||
return "python.exe".to_owned(); | ||
} | ||
|
||
panic!("Can't find python (tried python27.exe and python.exe)! Try fixing PATH or setting the PYTHON env var"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
fn find_python() -> String { | ||
if Command::new("python2.7").arg("--version").output().unwrap().status.success() { | ||
"python2.7" | ||
} else { | ||
"python" | ||
}.to_owned() | ||
} |