Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement parsing for mask shorthand #13336
Conversation
highfive
commented
Sep 20, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 20, 2016
|
r? @Manishearth |
|
@canaltinova I found an easy way to disable the link failure. I'm not sure if this is the right way to do it though, but it's good enough for now while you iterate, till I figure out something better. diff --git a/tests/unit/stylo/fakebindings.rs b/tests/unit/stylo/fakebindings.rs
new file mode 100644
index 0000000..ef5e09d
--- /dev/null
+++ b/tests/unit/stylo/fakebindings.rs
@@ -0,0 +1,14 @@
+#[no_mangle]
+pub extern "C" fn Gecko_ReleaseURIArbitraryThread(aPtr: *mut ()) {
+ println!("Stub for Gecko_ReleaseURIArbitraryThread");
+}
+
+#[no_mangle]
+pub extern "C" fn Gecko_ReleasePrincipalArbitraryThread(aPtr: *mut ()) {
+ println!("Stub for Gecko_ReleasePrincipalArbitraryThread");
+}
+
+#[no_mangle]
+pub extern "C" fn Gecko_ReleaseAtom(aPtr: *mut ()) {
+ println!("Stub for Gecko_ReleaseAtom");
+}
\ No newline at end of file
diff --git a/tests/unit/stylo/lib.rs b/tests/unit/stylo/lib.rs
index a74d74d..8e75b0a 100644
--- a/tests/unit/stylo/lib.rs
+++ b/tests/unit/stylo/lib.rs
@@ -8,5 +8,6 @@ extern crate gecko_bindings;
extern crate style;
extern crate style_traits;
+pub mod fakebindings;
mod sanity_checks;
mod parsing; |
|
@canaltinova also, looking at the tests, you don't need to test individual serialization like done in the style unit tests. Just test that the |
|
Another option is to continue using the style_tests crate for parsing tests, and compile it in a special mode where all properties are included. Don't touch the stylo tests crate then. I think you should use this one over the previous one for now, since you can share code with the existing parse tests. From 3ab46561a67dacc18c291012b9f696afb63b3dac Mon Sep 17 00:00:00 2001
From: Manish Goregaokar <manishsmail@gmail.com>
Date: Fri, 23 Sep 2016 09:40:16 +0530
Subject: [PATCH] Run tests with all properties enabled
---
components/style/Cargo.toml | 1 +
components/style/build.rs | 1 +
components/style/properties/build.py | 4 +++-
components/style/properties/data.py | 7 ++++---
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index 27dd885..14e412e 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -18,6 +18,7 @@ servo = ["serde", "serde/unstable", "serde_macros", "heapsize", "heapsize_plugin
"cssparser/heap_size", "cssparser/serde-serialization",
"selectors/heap_size", "selectors/unstable", "string_cache",
"url/heap_size", "plugins"]
+testing = []
[dependencies]
app_units = "0.3"
diff --git a/components/style/build.rs b/components/style/build.rs
index 23ee9d5..ab385b8 100644
--- a/components/style/build.rs
+++ b/components/style/build.rs
@@ -55,6 +55,7 @@ fn main() {
.arg(&script)
.arg(product)
.arg("style-crate")
+ .arg(if cfg!(feature = "testing") {"testing"} else {"regular"})
.status()
.unwrap();
if !status.success() {
diff --git a/components/style/properties/build.py b/components/style/properties/build.py
index daa9140..6997588 100644
--- a/components/style/properties/build.py
+++ b/components/style/properties/build.py
@@ -23,10 +23,12 @@ def main():
abort(usage)
product = sys.argv[1]
output = sys.argv[2]
+ testing = len(sys.argv) > 3 and sys.argv[3] == "testing"
+
if product not in ["servo", "gecko"] or output not in ["style-crate", "geckolib", "html"]:
abort(usage)
- properties = data.PropertiesData(product=product)
+ properties = data.PropertiesData(product=product, testing=testing)
rust = render(os.path.join(BASE, "properties.mako.rs"), product=product, data=properties)
if output == "style-crate":
write(os.environ["OUT_DIR"], "properties.rs", rust)
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index 94ae75f..b34a55b 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -160,8 +160,9 @@ class StyleStruct(object):
class PropertiesData(object):
- def __init__(self, product):
+ def __init__(self, product, testing):
self.product = product
+ self.testing = testing
self.style_structs = []
self.current_style_struct = None
self.longhands = []
@@ -179,7 +180,7 @@ class PropertiesData(object):
def declare_longhand(self, name, products="gecko servo", **kwargs):
products = products.split()
- if self.product not in products:
+ if self.product not in products and not self.testing:
return
longhand = Longhand(self.current_style_struct, name, **kwargs)
@@ -194,7 +195,7 @@ class PropertiesData(object):
def declare_shorthand(self, name, sub_properties, products="gecko servo", *args, **kwargs):
products = products.split()
- if self.product not in products:
+ if self.product not in products and not self.testing:
return
sub_properties = [self.longhands_by_name[s] for s in sub_properties]
--
2.8.3@emilio, any preferences? I like this option because we won't need to keep stubbing out methods. |
|
Implemented the latter solution in #13386 You should rebase over that PR and just write your tests in the regular style unit tests crate. |
|
Thanks for the help. I rebased your commits and added |
|
Got your ping about CSSStyleDeclaration -- you may need to temporarily edit CSSStyleDeclaration.webidl to add the mask shorthands and longhands. However, you don't need to. |
|
#13415 should be a more permanent fix for your testing woes. |
076d59a
to
d66d8ef
|
Re: your comment in IRC: Instead, use the parse function you added, and assert that the |
|
Code itself looks good, r=me on that, just needs some parse tests. |
2c40fac
to
16d5466
|
still needs the parse tests I mentioned, but otherwise okay |
| try!(write!(dest, " ")); | ||
|
|
||
| try!(position.unwrap_or(&mask_position::single_value | ||
| ::get_initial_specified_value()) |
This comment has been minimized.
This comment has been minimized.
|
I added some tests about you've mentioned and fixed the nit. |
|
Spec (https://drafts.fxtf.org/css-masking-1/#the-mask, https://drafts.csswg.org/css-backgrounds-3/#the-background) says that a single value should set both origin and clip. The current code for both is buggy. However, that can be fixed later. |
| let mut parser = Parser::new("padding-box"); | ||
| let result = mask::parse_value(&context, &mut parser).unwrap(); | ||
|
|
||
| assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box")); |
This comment has been minimized.
This comment has been minimized.
Manishearth
Sep 27, 2016
Member
File a followup about the clip/origin issue and leave a comment here linking to that.
|
r=me with the bug filed and links |
|
filed an issue here: #13466 and added comment about it. |
|
@bors-servo r+ |
|
@bors-servo r+ |
|
|
|
Fixed merge conflicts. |
Implement parsing for mask shorthand <!-- Please describe your changes on the following line: --> Implement parsing for mask shorthand. It doesn't contain tests yet. I'll write and update the PR. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #13235 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13336) <!-- Reviewable:end -->
|
|
highfive
commented
Sep 29, 2016
|
|
@bors-servo retry |
Implement parsing for mask shorthand <!-- Please describe your changes on the following line: --> Implement parsing for mask shorthand. It doesn't contain tests yet. I'll write and update the PR. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #13235 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13336) <!-- Reviewable:end -->
|
|
|
wooo! |
|
|
canova commentedSep 20, 2016
•
edited
Implement parsing for mask shorthand. It doesn't contain tests yet. I'll write and update the PR.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is