servo: Merge #9333 - Add a script to list all CSS properties parsed by Servo (from servo:list-properties); r=larsbergstrom

I’ve been asked for that list by two different people this week :)

r? @larsbergstrom

Source-Repo: https://github.com/servo/servo
Source-Revision: dba1f27305c5e81eda6acd4c438a2adfb6ed053d
This commit is contained in:
Simon Sapin 2016-01-16 00:37:03 +05:01
parent 928d1d2132
commit 9a7c1d808c
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/usr/bin/env python
# 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/.
import os.path
import sys
import json
style = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(style, "Mako-0.9.1.zip"))
from mako.template import Template
template = Template(filename=os.path.join(style, "properties.mako.rs"), input_encoding='utf8')
template.render()
properties = dict(
(p.name, {
"flag": p.experimental,
"shorthand": hasattr(p, "sub_properties")
})
for p in template.module.LONGHANDS + template.module.SHORTHANDS
)
print(json.dumps(properties, indent=4))

View File

@ -15,6 +15,7 @@ import sys
import os
import os.path as path
import subprocess
import json
from collections import OrderedDict
from time import time
@ -158,6 +159,14 @@ class MachCommands(CommandBase):
@CommandArgument('test_name', nargs=argparse.REMAINDER,
help="Only run tests that match this pattern or file path")
def test_unit(self, test_name=None, package=None):
properties = json.loads(subprocess.check_output([
sys.executable,
path.join(self.context.topdir, "components", "style", "list_properties.py")
]))
assert len(properties) >= 100
assert "margin-top" in properties
assert "margin" in properties
if test_name is None:
test_name = []