servo: Merge #19338 - Replace compiletest suite by doc-tests with `compile_fail` (from servo:compiletest); r=nox
authorSimon Sapin <simon.sapin@exyr.org>
Wed, 22 Nov 2017 09:35:54 -0600
changeset 393081 cc77ce263b1fcfcf37892ca81b50bc659ff14f4f
parent 393080 fc4036a8b9e8ddc4007faa49d96384e06d5f47a9
child 393082 20bc0a541fe995396877c89f00f1203fcc882321
push id55839
push userservo-vcs-sync@mozilla.com
push dateWed, 22 Nov 2017 16:36:35 +0000
treeherderautoland@cc77ce263b1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
milestone59.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
servo: Merge #19338 - Replace compiletest suite by doc-tests with `compile_fail` (from servo:compiletest); r=nox `compiletest-rs` use internal rustc APIs and is broken in today’s Nightly. rustdoc however is maintained with rustc and so much less fragile. Closes #9945. Source-Repo: https://github.com/servo/servo Source-Revision: 5213e2a5a9ed8859a004e480f52c7e04f8d7f85e
servo/Cargo.lock
servo/etc/ci/buildbot_steps.yml
servo/etc/rustdoc-with-private
servo/ports/servo/Cargo.toml
servo/python/servo/command_base.py
servo/python/servo/testing_commands.py
servo/tests/compiletest/helper/Cargo.toml
servo/tests/compiletest/helper/lib.rs
servo/tests/compiletest/plugin/Cargo.toml
servo/tests/compiletest/plugin/compile-fail/arc_rc_must_not_derive_malloc_size_of.rs
servo/tests/compiletest/plugin/compile-fail/deny_public_fields.rs
servo/tests/compiletest/plugin/compile-fail/trustedpromise_mustnot_deriveclone.rs
servo/tests/compiletest/plugin/compile-fail/unrooted_must_root.rs
servo/tests/compiletest/plugin/lib.rs
servo/tests/unit/deny_public_fields/Cargo.toml
servo/tests/unit/deny_public_fields/lib.rs
servo/tests/unit/malloc_size_of/Cargo.toml
servo/tests/unit/malloc_size_of/lib.rs
servo/tests/unit/script/Cargo.toml
servo/tests/unit/script/lib.rs
servo/tests/unit/script_plugins/Cargo.toml
servo/tests/unit/script_plugins/lib.rs
--- a/servo/Cargo.lock
+++ b/servo/Cargo.lock
@@ -436,32 +436,16 @@ dependencies = [
 ]
 
 [[package]]
 name = "color_quant"
 version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "compiletest_helper"
-version = "0.0.1"
-dependencies = [
- "compiletest_rs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "compiletest_rs"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "compositing"
 version = "0.0.1"
 dependencies = [
  "euclid 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "gfx_traits 0.0.1",
  "gleam 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -698,16 +682,23 @@ dependencies = [
 name = "deny_public_fields"
 version = "0.0.1"
 dependencies = [
  "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
+name = "deny_public_fields_tests"
+version = "0.0.1"
+dependencies = [
+ "deny_public_fields 0.0.1",
+]
+
+[[package]]
 name = "device"
 version = "0.0.1"
 source = "git+https://github.com/servo/devices#c3b012b0ac4fbc47d1ebc9bd3fc308f599be4ee4"
 dependencies = [
  "blurdroid 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "blurmac 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "blurmock 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "blurz 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1733,16 +1724,24 @@ name = "malloc_size_of_derive"
 version = "0.0.1"
 dependencies = [
  "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
+name = "malloc_size_of_tests"
+version = "0.0.1"
+dependencies = [
+ "malloc_size_of 0.0.1",
+ "servo_arc 0.0.1",
+]
+
+[[package]]
 name = "markup5ever"
 version = "0.6.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
  "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2354,26 +2353,16 @@ source = "registry+https://github.com/ru
 dependencies = [
  "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "plugin_compiletest"
-version = "0.0.1"
-dependencies = [
- "compiletest_helper 0.0.1",
- "deny_public_fields 0.0.1",
- "script 0.0.1",
- "script_plugins 0.0.1",
-]
-
-[[package]]
 name = "png"
 version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "inflate 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-iter 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2724,16 +2713,23 @@ dependencies = [
  "webrender_api 0.54.0 (git+https://github.com/servo/webrender)",
 ]
 
 [[package]]
 name = "script_plugins"
 version = "0.0.1"
 
 [[package]]
+name = "script_plugins_tests"
+version = "0.0.1"
+dependencies = [
+ "script_plugins 0.0.1",
+]
+
+[[package]]
 name = "script_tests"
 version = "0.0.1"
 dependencies = [
  "euclid 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "msg 0.0.1",
  "script 0.0.1",
  "servo_url 0.0.1",
  "style 0.0.1",
@@ -2854,28 +2850,29 @@ dependencies = [
 
 [[package]]
 name = "servo"
 version = "0.0.1"
 dependencies = [
  "android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)",
- "compiletest_helper 0.0.1",
+ "deny_public_fields_tests 0.0.1",
  "gfx_tests 0.0.1",
  "glutin_app 0.0.1",
  "layout_tests 0.0.1",
  "libservo 0.0.1",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "malloc_size_of_tests 0.0.1",
  "metrics_tests 0.0.1",
  "msg_tests 0.0.1",
  "net_tests 0.0.1",
  "net_traits_tests 0.0.1",
- "plugin_compiletest 0.0.1",
  "profile_tests 0.0.1",
+ "script_plugins_tests 0.0.1",
  "script_tests 0.0.1",
  "servo_config_tests 0.0.1",
  "servo_remutex_tests 0.0.1",
  "sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "style_tests 0.0.1",
 ]
 
 [[package]]
@@ -3891,17 +3888,16 @@ dependencies = [
 "checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
 "checksum clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b8c532887f1a292d17de05ae858a8fe50a301e196f9ef0ddb7ccd0d1d00f180"
 "checksum clipboard 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd3a9a938558f33ec1baaa6ca631a69c104aafaacbc66868d9ad28cf5f30564f"
 "checksum clipboard-win 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "693b1280c514045382dfdbb78d1594b1b03cdb66320aeb7ebd2bd38d49bae959"
 "checksum cmake 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "9b0ec063cbc2034e27f7166d04aa7aa1b9ed85b6c7c2414fb68aff20d1ebf604"
 "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
 "checksum cocoa 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac0d785ff4faf0ff23d7b5561346bb50dc7ef9a11cb0e65e07ef776b7752938f"
 "checksum color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
-"checksum compiletest_rs 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "617b23d0ed4f57b3bcff6b5fe0a78f0010f1efb636298317665a960b6dbc0533"
 "checksum cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30b3493e12a550c2f96be785088d1da8d93189e7237c8a8d0d871bc9070334c3"
 "checksum cookie 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "477eb650753e319be2ae77ec368a58c638f9f0c4d941c39bad95e950fb1d1d0d"
 "checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7"
 "checksum core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9fb3d6cb663e6fd7cf1c63f9b144ee2b1e4a78595a0451dd34bff85b9a3387"
 "checksum core-graphics 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc0a78ab2ac23b6ea7b3fe5fe93b227900dc0956979735b8f68032417976dd4"
 "checksum core-text 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcad23756dd1dc4b47bf6a914ace27aadb8fa68889db5837af2308d018d0467c"
 "checksum cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44313341610282488e1156ad1fedebca51c54766c87a041d0287b10499c04ba1"
 "checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
--- a/servo/etc/ci/buildbot_steps.yml
+++ b/servo/etc/ci/buildbot_steps.yml
@@ -75,17 +75,16 @@ mac-rel-intermittent:
   - env PKG_CONFIG_PATH=/usr/local/opt/zlib/lib/pkgconfig ./mach build --release
   - ./etc/ci/check_intermittents.sh --log-raw intermittents.log
 
 linux-dev:
   - ./mach clean-nightlies --keep 3 --force
   - ./mach test-tidy --no-progress --all
   - ./mach test-tidy --no-progress --self-test
   - env CC=gcc-5 CXX=g++-5 ./mach build --dev
-  - env ./mach test-compiletest
   - env ./mach test-unit
   - env ./mach package --dev
   - env ./mach build-cef
   - env ./mach build --dev --no-default-features --features default-except-unstable
   - ./mach build-geckolib
   - ./mach test-stylo
   - bash ./etc/ci/lockfile_changed.sh
   - bash ./etc/ci/manifest_changed.sh
deleted file mode 100755
--- a/servo/etc/rustdoc-with-private
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# Skip the strip-private and strip-hidden rustdoc passes
-# https://github.com/rust-lang/rust/issues/15347
-rustdoc --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports "$@"
--- a/servo/ports/servo/Cargo.toml
+++ b/servo/ports/servo/Cargo.toml
@@ -9,26 +9,27 @@ publish = false
 
 [[bin]]
 name = "servo"
 path = "main.rs"
 test = false
 bench = false
 
 [dev-dependencies]
-compiletest_helper = {path = "../../tests/compiletest/helper"}
+deny_public_fields_tests = {path = "../../tests/unit/deny_public_fields"}
 gfx_tests = {path = "../../tests/unit/gfx"}
 layout_tests = {path = "../../tests/unit/layout"}
+malloc_size_of_tests = {path = "../../tests/unit/malloc_size_of"}
 metrics_tests = {path = "../../tests/unit/metrics"}
 msg_tests = {path = "../../tests/unit/msg"}
 net_tests = {path = "../../tests/unit/net"}
 net_traits_tests = {path = "../../tests/unit/net_traits"}
-plugin_compiletest = {path = "../../tests/compiletest/plugin"}
 profile_tests = {path = "../../tests/unit/profile"}
 script_tests = {path = "../../tests/unit/script"}
+script_plugins_tests = {path = "../../tests/unit/script_plugins"}
 servo_config_tests = {path = "../../tests/unit/servo_config"}
 servo_remutex_tests = {path = "../../tests/unit/servo_remutex"}
 style_tests = {path = "../../tests/unit/style"}
 
 [features]
 default = ["unstable", "default-except-unstable"]
 default-except-unstable = ["webdriver", "max_log_level"]
 max_log_level = ["log/release_max_level_info"]
--- a/servo/python/servo/command_base.py
+++ b/servo/python/servo/command_base.py
@@ -481,17 +481,17 @@ class CommandBase(object):
         if "ANDROID_NDK" in env:
             env["NDK_HOME"] = env["ANDROID_NDK"]
         if "ANDROID_TOOLCHAIN" in env:
             env["NDK_STANDALONE"] = env["ANDROID_TOOLCHAIN"]
 
         if hosts_file_path:
             env['HOST_FILE'] = hosts_file_path
 
-        env['RUSTDOC'] = path.join(self.context.topdir, 'etc', 'rustdoc-with-private')
+        env['RUSTDOCFLAGS'] = "--document-private-items"
 
         if self.config["build"]["rustflags"]:
             env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " " + self.config["build"]["rustflags"]
 
         # Don't run the gold linker if on Windows https://github.com/servo/servo/issues/9499
         if self.config["tools"]["rustc-with-gold"] and sys.platform != "win32":
             if subprocess.call(['which', 'ld.gold'], stdout=PIPE, stderr=PIPE) == 0:
                 env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C link-args=-fuse-ld=gold"
--- a/servo/python/servo/testing_commands.py
+++ b/servo/python/servo/testing_commands.py
@@ -54,19 +54,16 @@ TEST_SUITES = OrderedDict([
               "include_arg": "include"}),
     ("wpt", {"kwargs": {"release": False},
              "paths": [path.abspath(WEB_PLATFORM_TESTS_PATH),
                        path.abspath(SERVO_TESTS_PATH)],
              "include_arg": "include"}),
     ("unit", {"kwargs": {},
               "paths": [path.abspath(path.join("tests", "unit"))],
               "include_arg": "test_name"}),
-    ("compiletest", {"kwargs": {"release": False},
-                     "paths": [path.abspath(path.join("tests", "compiletest"))],
-                     "include_arg": "test_name"})
 ])
 
 TEST_SUITES_BY_PREFIX = {path: k for k, v in TEST_SUITES.iteritems() if "paths" in v for path in v["paths"]}
 
 
 def create_parser_wpt():
     parser = wptcommandline.create_parser()
     parser.add_argument('--release', default=False, action="store_true",
@@ -112,17 +109,16 @@ class MachCommands(CommandBase):
                      help="Run all test suites")
     def test(self, params, render_mode=DEFAULT_RENDER_MODE, release=False, tidy_all=False,
              no_progress=False, self_test=False, all_suites=False):
         suites = copy.deepcopy(TEST_SUITES)
         suites["tidy"]["kwargs"] = {"all_files": tidy_all, "no_progress": no_progress, "self_test": self_test,
                                     "stylo": False}
         suites["wpt"]["kwargs"] = {"release": release}
         suites["unit"]["kwargs"] = {}
-        suites["compiletest"]["kwargs"] = {"release": release}
 
         selected_suites = OrderedDict()
 
         if params is None:
             if all_suites:
                 params = suites.keys()
             else:
                 print("Specify a test path or suite name, or pass --all to run all test suites.\n\nAvailable suites:")
@@ -297,73 +293,16 @@ class MachCommands(CommandBase):
         env["RUST_BACKTRACE"] = "1"
         env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8")
 
         args = (["cargo", "test", "-p", "stylo_tests"] +
                 (["--release"] if release else []) + (test_name or []))
         with cd(path.join("ports", "geckolib")):
             return call(args, env=env)
 
-    @Command('test-compiletest',
-             description='Run compiletests',
-             category='testing')
-    @CommandArgument('--package', '-p', default=None, help="Specific package to test")
-    @CommandArgument('test_name', nargs=argparse.REMAINDER,
-                     help="Only run tests that match this pattern or file path")
-    @CommandArgument('--release', default=False, action="store_true",
-                     help="Run with a release build of servo")
-    def test_compiletest(self, test_name=None, package=None, release=False):
-        if test_name is None:
-            test_name = []
-
-        self.ensure_bootstrapped()
-
-        if package:
-            packages = {package}
-        else:
-            packages = set()
-
-        test_patterns = []
-        for test in test_name:
-            # add package if 'tests/compiletest/<package>'
-            match = re.search("tests/compiletest/(\\w+)/?$", test)
-            if match:
-                packages.add(match.group(1))
-            # add package & test if '<package>/<test>', 'tests/compiletest/<package>/<test>.rs', or similar
-            elif re.search("\\w/\\w", test):
-                tokens = test.split("/")
-                packages.add(tokens[-2])
-                test_prefix = tokens[-1]
-                if test_prefix.endswith(".rs"):
-                    test_prefix = test_prefix[:-3]
-                test_prefix += "::"
-                test_patterns.append(test_prefix)
-            # add test as-is otherwise
-            else:
-                test_patterns.append(test)
-
-        if not packages:
-            packages = set(os.listdir(path.join(self.context.topdir, "tests", "compiletest"))) - set(['.DS_Store'])
-
-        packages.remove("helper")
-
-        args = ["cargo", "test"]
-        for crate in packages:
-            args += ["-p", "%s_compiletest" % crate]
-        args += test_patterns
-
-        env = self.build_env()
-        if release:
-            env["BUILD_MODE"] = "release"
-            args += ["--release"]
-        else:
-            env["BUILD_MODE"] = "debug"
-
-        return call(args, env=env, cwd=self.servo_crate())
-
     @Command('test-content',
              description='Run the content tests',
              category='testing')
     def test_content(self):
         print("Content tests have been replaced by web-platform-tests under "
               "tests/wpt/mozilla/.")
         return 0
 
deleted file mode 100644
--- a/servo/tests/compiletest/helper/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[package]
-name = "compiletest_helper"
-version = "0.0.1"
-authors = ["The Servo Project Developers"]
-license = "MPL-2.0"
-
-[lib]
-name = "compiletest_helper"
-path = "lib.rs"
-doctest = false
-
-[dependencies]
-compiletest_rs = "0.2.0"
deleted file mode 100644
--- a/servo/tests/compiletest/helper/lib.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-/* 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/. */
-
-extern crate compiletest_rs as compiletest;
-
-use std::env;
-use std::path::PathBuf;
-
-pub fn run_mode(mode: &'static str) {
-    let mut config = compiletest::default_config();
-    let cfg_mode = mode.parse().ok().expect("Invalid mode");
-
-    config.mode = cfg_mode;
-    config.src_base = PathBuf::from(format!("{}", mode));
-
-    let mut base_path = env::current_dir().expect("Current directory is invalid");
-    base_path.pop();
-    base_path.pop();
-    base_path.pop();
-
-    let mode = env::var("BUILD_MODE").expect("BUILD_MODE environment variable must be set");
-    let debug_path = base_path.join(PathBuf::from(format!("target/{}", mode)));
-    let deps_path = base_path.join(PathBuf::from(format!("target/{}/deps", mode)));
-
-    config.target_rustcflags = Some(format!("-L {} -L {}",  debug_path.display(), deps_path.display()));
-    compiletest::run_tests(&config);
-}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "plugin_compiletest"
-version = "0.0.1"
-authors = ["The Servo Project Developers"]
-license = "MPL-2.0"
-
-[lib]
-name = "plugin_compiletest"
-path = "lib.rs"
-doctest = false
-
-[dependencies]
-compiletest_helper = {path = "../helper"}
-deny_public_fields = {path = "../../../components/deny_public_fields"}
-script = {path = "../../../components/script"}
-script_plugins = {path = "../../../components/script_plugins"}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/compile-fail/arc_rc_must_not_derive_malloc_size_of.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-/* 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/. */
-
-extern crate malloc_size_of;
-extern crate servo_arc;
-
-use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf};
-
-fn sizeable<T: MallocSizeOf>() {
-}
-
-fn shallow_sizeable<T: MallocShallowSizeOf>() {
-}
-
-fn main() {
-    sizeable::<::servo_arc::Arc<i32>>();
-    //~^ ERROR the trait bound `servo_arc::Arc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
-
-    sizeable::<::std::sync::Arc<i32>>();
-    //~^ ERROR the trait bound `std::sync::Arc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
-
-    sizeable::<::std::rc::Rc<i32>>();
-    //~^ ERROR the trait bound `std::rc::Rc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
-
-    shallow_sizeable::<::servo_arc::Arc<i32>>();
-    //~^ ERROR the trait bound `servo_arc::Arc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
-
-    shallow_sizeable::<::std::sync::Arc<i32>>();
-    //~^ ERROR the trait bound `std::sync::Arc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
-
-    shallow_sizeable::<::std::rc::Rc<i32>>();
-    //~^ ERROR the trait bound `std::rc::Rc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
-}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/compile-fail/deny_public_fields.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-/* 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/. */
-
-#![allow(dead_code)]
-
-#[macro_use]
-extern crate deny_public_fields;
-
-#[derive(DenyPublicFields)]
-//~^ ERROR proc-macro derive panicked
-//~| HELP Field `v1` should not be public
-struct Foo {
-    pub v1: i32,
-    v2: i32
-}
-
-fn main() {}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/compile-fail/trustedpromise_mustnot_deriveclone.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-/* 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/. */
-
-extern crate script;
-
-use script::test::TrustedPromise;
-
-fn cloneable<T: Clone>() {
-}
-
-fn main() {
-    cloneable::<TrustedPromise>();
-    //~^ ERROR the trait bound `script::test::TrustedPromise: std::clone::Clone` is not satisfied
-}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/compile-fail/unrooted_must_root.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-/* 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/. */
-
-#![allow(dead_code)]
-#![feature(plugin)]
-#![plugin(script_plugins)]
-
-#[must_root]
-struct Foo {
-    v: i32
-}
-
-struct Bar {
-    f: Foo
-    //~^ ERROR Type must be rooted, use #[must_root] on the struct definition to propagate
-}
-
-fn foo1(_: Foo) {} //~ ERROR Type must be rooted
-
-
-fn foo2() -> Foo { //~ ERROR Type must be rooted
-    Foo { v: 10 }
-}
-
-
-fn main() {}
deleted file mode 100644
--- a/servo/tests/compiletest/plugin/lib.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-/* 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/. */
-
-extern crate compiletest_helper;
-
-#[test]
-fn compile_test() {
-    compiletest_helper::run_mode("compile-fail");
-}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/deny_public_fields/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "deny_public_fields_tests"
+version = "0.0.1"
+authors = ["The Servo Project Developers"]
+license = "MPL-2.0"
+
+[lib]
+path = "lib.rs"
+test = false
+
+[dependencies]
+deny_public_fields = {path = "../../../components/deny_public_fields"}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/deny_public_fields/lib.rs
@@ -0,0 +1,33 @@
+/* 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/. */
+
+/**
+```compile_fail
+#[macro_use] extern crate deny_public_fields;
+
+#[derive(DenyPublicFields)]
+struct Foo {
+    pub v1: i32,
+    v2: i32
+}
+
+fn main() {}
+```
+*/
+pub fn deny_public_fields_failing() {}
+
+/**
+```
+#[macro_use] extern crate deny_public_fields;
+
+#[derive(DenyPublicFields)]
+struct Foo {
+    v1: i32,
+    v2: i32
+}
+
+fn main() {}
+```
+*/
+pub fn deny_public_fields_ok() {}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/malloc_size_of/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "malloc_size_of_tests"
+version = "0.0.1"
+authors = ["The Servo Project Developers"]
+license = "MPL-2.0"
+
+[lib]
+path = "lib.rs"
+test = false
+
+[dependencies]
+malloc_size_of = {path = "../../../components/malloc_size_of"}
+servo_arc = {path = "../../../components/servo_arc"}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/malloc_size_of/lib.rs
@@ -0,0 +1,109 @@
+/* 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/. */
+
+/**
+```
+extern crate malloc_size_of;
+extern crate servo_arc;
+
+fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
+fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
+fn cloneable<T: Clone>() {}
+
+fn main() {
+    cloneable::<servo_arc::Arc<i32>>();
+    cloneable::<std::sync::Arc<i32>>();
+    cloneable::<std::rc::Rc<i32>>();
+}
+```
+*/
+pub fn imports_ok() {}
+
+pub mod does_not_impl_malloc_size_of {
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+    extern crate servo_arc;
+
+    fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
+
+    fn main() {
+        sizeable::<servo_arc::Arc<i32>>();
+    }
+    ```
+    */
+    pub fn servo_arc() {}
+
+
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+
+    fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
+
+    fn main() {
+        sizeable::<std::sync::Arc<i32>>();
+    }
+    ```
+    */
+    pub fn std_arc() {}
+
+
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+
+    fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
+
+    fn main() {
+        sizeable::<std::rc::Rc<i32>>();
+    }
+    ```
+    */
+    pub fn rc() {}
+}
+
+pub mod does_not_impl_malloc_shallow_size_of {
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+    extern crate servo_arc;
+
+    fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
+
+    fn main() {
+        shallow_sizeable::<servo_arc::Arc<i32>>();
+    }
+    ```
+    */
+    pub fn servo_arc() {}
+
+
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+
+    fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
+
+    fn main() {
+        shallow_sizeable::<std::sync::Arc<i32>>();
+    }
+    ```
+    */
+    pub fn std_arc() {}
+
+
+    /**
+    ```compile_fail,E0277
+    extern crate malloc_size_of;
+
+    fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
+
+    fn main() {
+        shallow_sizeable::<std::rc::Rc<i32>>();
+    }
+    ```
+    */
+    pub fn rc() {}
+}
--- a/servo/tests/unit/script/Cargo.toml
+++ b/servo/tests/unit/script/Cargo.toml
@@ -2,16 +2,15 @@
 name = "script_tests"
 version = "0.0.1"
 authors = ["The Servo Project Developers"]
 license = "MPL-2.0"
 
 [lib]
 name = "script_tests"
 path = "lib.rs"
-doctest = false
 
 [dependencies]
 euclid = "0.15"
 msg = {path = "../../../components/msg"}
 script = {path = "../../../components/script"}
 servo_url = {path = "../../../components/url"}
 style = {path = "../../../components/style"}
--- a/servo/tests/unit/script/lib.rs
+++ b/servo/tests/unit/script/lib.rs
@@ -1,17 +1,29 @@
 /* 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/. */
 
-extern crate euclid;
-extern crate msg;
-extern crate script;
-extern crate servo_url;
-extern crate style;
+#[cfg(test)] extern crate euclid;
+#[cfg(test)] extern crate msg;
+#[cfg(test)] extern crate script;
+#[cfg(test)] extern crate servo_url;
+#[cfg(test)] extern crate style;
 
 #[cfg(test)] mod origin;
 #[cfg(all(test, target_pointer_width = "64"))] mod size_of;
 #[cfg(test)] mod textinput;
 #[cfg(test)] mod headers;
 #[cfg(test)] mod htmlareaelement;
 #[cfg(test)] mod htmlimageelement;
 
+/**
+```compile_fail,E0277
+extern crate script;
+
+fn cloneable<T: Clone>() {}
+
+fn main() {
+    cloneable::<script::test::TrustedPromise>();
+}
+```
+*/
+pub fn trustedpromise_does_not_impl_clone() {}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/script_plugins/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "script_plugins_tests"
+version = "0.0.1"
+authors = ["The Servo Project Developers"]
+license = "MPL-2.0"
+
+[lib]
+path = "lib.rs"
+test = false
+
+[dependencies]
+script_plugins = {path = "../../../components/script_plugins"}
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/script_plugins/lib.rs
@@ -0,0 +1,63 @@
+/* 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/. */
+
+pub mod unrooted_must_root {
+    /**
+    ```
+    #![feature(plugin)]
+    #![plugin(script_plugins)]
+
+    #[must_root] struct Foo(i32);
+    #[must_root] struct Bar(Foo);
+
+    fn foo1(_: &Foo) {}
+    fn foo2(_: &()) -> &Foo { unimplemented!() }
+
+    fn main() {}
+    ```
+    */
+    pub fn ok() {}
+
+    /**
+    ```compile_fail
+    #![feature(plugin)]
+    #![plugin(script_plugins)]
+
+    #[must_root] struct Foo(i32);
+    struct Bar(Foo);
+
+    fn main() {}
+    ```
+    */
+    pub fn struct_field() {}
+
+    /**
+    ```compile_fail
+    #![feature(plugin)]
+    #![plugin(script_plugins)]
+
+    #[must_root] struct Foo(i32);
+
+    fn foo1(_: Foo) {}
+
+    fn main() {}
+    ```
+    */
+    pub fn parameter() {}
+
+    /**
+    ```compile_fail
+    #![feature(plugin)]
+    #![plugin(script_plugins)]
+
+    #[must_root] struct Foo(i32);
+
+    fn foo2() -> Foo { unimplemented!() }
+
+    fn main() {}
+    ```
+    */
+    pub fn return_type() {}
+
+}