From 9d29c3d2f52946e02c92ce7c31ac74433c2c6f8e Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 15 Jan 2016 15:50:32 +0100 Subject: [PATCH 1/2] Add a script to list all CSS properties parsed by Servo. --- components/style/list_properties.py | 14 ++++++++++++++ python/servo/testing_commands.py | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100755 components/style/list_properties.py diff --git a/components/style/list_properties.py b/components/style/list_properties.py new file mode 100755 index 00000000000..a787cbb8706 --- /dev/null +++ b/components/style/list_properties.py @@ -0,0 +1,14 @@ +#!/bin/env python2.7 + +import os.path +import sys + +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 = template.module.LONGHANDS + template.module.SHORTHANDS +for name in sorted(p.name for p in properties): + print(name) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 9892a0e6669..80d4515c8e4 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -158,6 +158,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 = subprocess.check_output([ + sys.executable, + path.join(self.context.topdir, "components", "style", "list_properties.py") + ]).splitlines() + assert len(properties) >= 100 + assert "margin-top" in properties + assert "margin" in properties + if test_name is None: test_name = [] From 2222f345c8a024d319f6f6f89d2517c3633c8c6d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 15 Jan 2016 16:18:58 +0100 Subject: [PATCH 2/2] Make the properties list JSON and add some more info. --- components/style/list_properties.py | 20 +++++++++++++++----- python/servo/testing_commands.py | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) mode change 100755 => 100644 components/style/list_properties.py diff --git a/components/style/list_properties.py b/components/style/list_properties.py old mode 100755 new mode 100644 index a787cbb8706..63bbe247511 --- a/components/style/list_properties.py +++ b/components/style/list_properties.py @@ -1,14 +1,24 @@ -#!/bin/env python2.7 +#!/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 = template.module.LONGHANDS + template.module.SHORTHANDS -for name in sorted(p.name for p in properties): - print(name) +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)) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 80d4515c8e4..acd92dea9a2 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -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,10 +159,10 @@ 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 = subprocess.check_output([ + properties = json.loads(subprocess.check_output([ sys.executable, path.join(self.context.topdir, "components", "style", "list_properties.py") - ]).splitlines() + ])) assert len(properties) >= 100 assert "margin-top" in properties assert "margin" in properties