Bug 1551611 - Add macOS version information to the ReftestEnvironment. r=Gankro
☠☠ backed out by bfddd8606240 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 15 May 2019 14:39:39 +0000
changeset 535841 85ac4e68a63e4cf49def39381105131d3520e813
parent 535840 df4a76b3e6ce045afbe647a2a99fbe6386fe296d
child 535842 f60b2e760d1adf5be0aae2485ab685dc8b2fb039
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGankro
bugs1551611
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551611 - Add macOS version information to the ReftestEnvironment. r=Gankro Differential Revision: https://phabricator.services.mozilla.com/D31182
gfx/wr/Cargo.lock
gfx/wr/wrench/Cargo.toml
gfx/wr/wrench/src/parse_function.rs
gfx/wr/wrench/src/reftest.rs
--- a/gfx/wr/Cargo.lock
+++ b/gfx/wr/Cargo.lock
@@ -1804,16 +1804,17 @@ dependencies = [
  "glutin 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "osmesa-src 0.1.1 (git+https://github.com/servo/osmesa-src)",
  "osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender 0.60.0",
  "webrender_api 0.60.0",
  "winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
--- a/gfx/wr/wrench/Cargo.toml
+++ b/gfx/wr/wrench/Cargo.toml
@@ -24,16 +24,17 @@ ron = "0.1.5"
 time = "0.1"
 crossbeam = "0.2"
 osmesa-sys = { version = "0.1.2", optional = true }
 osmesa-src = { git = "https://github.com/servo/osmesa-src", optional = true }
 webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler","no_static_freetype"]}
 webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]}
 winit = "0.16"
 serde = {version = "1.0", features = ["derive"] }
+semver = "0.9.0"
 
 [target.'cfg(target_os = "macos")'.dependencies]
 core-graphics = "0.17.1"
 core-foundation = "0.6"
 
 [features]
 default = [ "env_logger" ]
 headless = [ "osmesa-sys", "osmesa-src" ]
--- a/gfx/wr/wrench/src/parse_function.rs
+++ b/gfx/wr/wrench/src/parse_function.rs
@@ -1,22 +1,26 @@
 /* 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 std::str::CharIndices;
 
-// support arguments like '4', 'ab', '4.0'
+// support arguments like '4', 'ab', '4.0', '>=10.14'
 fn acceptable_arg_character(c: char) -> bool {
-    c.is_alphanumeric() || c == '.' || c == '-'
+    c.is_alphanumeric() || c == '.' || c == '-' || c == '<' || c == '>' || c == '='
 }
 
-// A crapy parser for parsing strings like "translate(1, 3)"
+// A crapy parser for parsing strings like "translate(1, 3) blahblah"
+// Returns a tuple with three components:
+// - First component is the function name (e.g. "translate")
+// - Second component is the list of arguments (e.g. vec!["1", "3"])
+// - Third component is the rest of the string "blahblah"
 pub fn parse_function(s: &str) -> (&str, Vec<&str>, &str) {
-    // XXX: This it not particular easy to read. Sorry.
+    // XXX: This is not particularly easy to read. Sorry.
     struct Parser<'a> {
         itr: CharIndices<'a>,
         start: usize,
         o: Option<(usize, char)>,
     }
     impl<'a> Parser<'a> {
         fn skip_whitespace(&mut self) {
             while let Some(k) = self.o {
--- a/gfx/wr/wrench/src/reftest.rs
+++ b/gfx/wr/wrench/src/reftest.rs
@@ -1,24 +1,26 @@
 /* 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 crate::{WindowWrapper, NotifierEvent};
 use base64;
+use semver;
 use image::load as load_piston_image;
 use image::png::PNGEncoder;
 use image::{ColorType, ImageFormat};
 use crate::parse_function::parse_function;
 use crate::png::save_flipped;
 use std::cmp;
 use std::fmt::{Display, Error, Formatter};
 use std::fs::File;
 use std::io::{BufRead, BufReader};
 use std::path::{Path, PathBuf};
+use std::process::Command;
 use std::sync::mpsc::Receiver;
 use webrender::RenderResults;
 use webrender::api::*;
 use webrender::api::units::*;
 use crate::wrench::{Wrench, WrenchThing};
 use crate::yaml_frame_reader::YamlFrameReader;
 
 
@@ -344,45 +346,80 @@ impl ReftestManifest {
 
 struct YamlRenderOutput {
     image: ReftestImage,
     results: RenderResults,
 }
 
 struct ReftestEnvironment {
     pub platform: &'static str,
+    pub version: Option<semver::Version>,
     pub mode: &'static str,
 }
 
 impl ReftestEnvironment {
     fn new() -> Self {
         Self {
             platform: Self::platform(),
+            version: Self::version(),
             mode: Self::mode(),
         }
     }
 
     fn has(&self, condition: &str) -> bool {
-        self.platform == condition || self.mode == condition
+        if self.platform == condition || self.mode == condition {
+            return true;
+        }
+        match (&self.version, &semver::VersionReq::parse(condition)) {
+            (None, _) => false,
+            (_, Err(_)) => false,
+            (Some(v), Ok(r)) => r.matches(v),
+        }
     }
 
     fn platform() -> &'static str {
         if cfg!(target_os = "windows") {
             "win"
         } else if cfg!(target_os = "linux") {
             "linux"
         } else if cfg!(target_os = "macos") {
             "mac"
         } else if cfg!(target_os = "android") {
             "android"
         } else {
             "other"
         }
     }
 
+    fn version() -> Option<semver::Version> {
+        if cfg!(target_os = "macos") {
+            use std::str;
+            let version_bytes = Command::new("defaults")
+                .arg("read")
+                .arg("loginwindow")
+                .arg("SystemVersionStampAsString")
+                .output()
+                .expect("Failed to get macOS version")
+                .stdout;
+            let mut version_string = str::from_utf8(&version_bytes)
+                .expect("Failed to read macOS version")
+                .trim()
+                .to_string();
+            // On some machines this produces just the major.minor and on
+            // some machines this gives major.minor.patch. But semver requires
+            // the patch so we fake one if it's not there.
+            if version_string.chars().filter(|c| *c == '.').count() == 1 {
+                version_string.push_str(".0");
+            }
+            Some(semver::Version::parse(&version_string).expect(&format!("Failed to parse macOS version {}", version_string)))
+        } else {
+            None
+        }
+    }
+
     fn mode() -> &'static str {
         if cfg!(debug_assertions) {
             "debug"
         } else {
             "release"
         }
     }
 }