servo/tests/unit/style/properties/scaffolding.rs
Delan Azabani faf754dfa6
Move Stylo to its own repo (#31350)
* Remove packages that were moved to external repo

* Add workspace dependencies pointing to 2023-06-14 branch

* Fix servo-tidy.toml errors

* Update commit to include #31346

* Update commit to include servo/stylo#2

* Move css-properties.json lookup to target/doc/stylo

* Remove dependency on vendored mako in favour of pypi dependency

This also removes etc/ci/generate_workflow.py, which has been unused
since at least 9e71bd6a70.

* Add temporary code to debug Windows test failures

* Fix failures on Windows due to custom target dir

* Update commit to include servo/stylo#3

* Fix license in tests/unit/style/build.rs

* Document how to build with local Stylo in Cargo.toml
2024-02-27 15:39:06 +00:00

31 lines
1.1 KiB
Rust

/* 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 https://mozilla.org/MPL/2.0/. */
use std::env;
use std::fs::File;
use std::path::Path;
use serde_json::{self, Value};
#[test]
fn properties_list_json() {
// Four dotdots: /path/to/target(4)/debug(3)/build(2)/style_tests-*(1)/out
// Do not ascend above the target dir, because it may not be called target
// or even have a parent (see CARGO_TARGET_DIR).
let target_dir = Path::new(env!("OUT_DIR"))
.join("..")
.join("..")
.join("..")
.join("..");
let json = target_dir
.join("doc")
.join("stylo")
.join("css-properties.json");
let properties: Value = serde_json::from_reader(File::open(json).unwrap()).unwrap();
let longhands = properties["longhands"].as_object().unwrap();
assert!(longhands.len() > 100);
assert!(longhands.get("margin-top").is_some());
assert!(properties["shorthands"].get("margin").is_some());
}