diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/servo/build_commands.py | 52 | ||||
-rw-r--r-- | python/servo/devenv_commands.py | 9 | ||||
-rw-r--r-- | python/servo/testing_commands.py | 24 |
3 files changed, 66 insertions, 19 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index ad8e58d04c2..285f24d2534 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -1,5 +1,6 @@ from __future__ import print_function, unicode_literals +import sys import os import os.path as path import subprocess @@ -16,6 +17,48 @@ from servo.command_base import CommandBase, cd def is_headless_build(): return int(os.getenv('SERVO_HEADLESS', 0)) == 1 +# Function to generate desktop notification once build is completed & limit exceeded! +def notify(elapsed): + if elapsed < 300: + return + + if sys.platform.startswith('linux'): + try: + import dbus + bus = dbus.SessionBus() + notify_obj = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') + method = notify_obj.get_dbus_method('Notify', 'org.freedesktop.Notifications') + method('Servo Build System', 0, '', ' Servo build complete!', '', [], [], -1) + except: + print("[Warning] Could not generate notification! Please make sure that the python dbus module is installed!") + + elif sys.platform.startswith('win'): + try: + from ctypes import Structure, windll, POINTER, sizeof + from ctypes.wintypes import DWORD, HANDLE, WINFUNCTYPE, BOOL, UINT + class FLASHWINDOW(Structure): + _fields_ = [("cbSize", UINT), + ("hwnd", HANDLE), + ("dwFlags", DWORD), + ("uCount", UINT), + ("dwTimeout", DWORD)] + FlashWindowExProto = WINFUNCTYPE(BOOL, POINTER(FLASHWINDOW)) + FlashWindowEx = FlashWindowExProto(("FlashWindowEx", windll.user32)) + FLASHW_CAPTION = 0x01 + FLASHW_TRAY = 0x02 + FLASHW_TIMERNOFG = 0x0C + params = FLASHWINDOW(sizeof(FLASHWINDOW), + windll.kernel32.GetConsoleWindow(), + FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0) + FlashWindowEx(params) + except: + print("[Warning] Could not generate notification! Please make sure that the required libraries are installed!") + + elif sys.platform.startswith('darwin'): + # Notification code for Darwin here! For the time being printing simple msg + print("[Warning] : Darwin System! Notifications not supported currently!") + + @CommandProvider class MachCommands(CommandBase): @Command('build', @@ -102,6 +145,9 @@ class MachCommands(CommandBase): env=env, cwd=self.servo_crate()) elapsed = time() - build_start + # Generate Desktop Notification if elapsed-time > some threshold value + notify(elapsed) + print("Build completed in %0.2fs" % elapsed) return status @@ -135,6 +181,9 @@ class MachCommands(CommandBase): env=self.build_env()) elapsed = time() - build_start + # Generate Desktop Notification if elapsed-time > some threshold value + notify(elapsed) + print("CEF build completed in %0.2fs" % elapsed) return ret @@ -170,6 +219,9 @@ class MachCommands(CommandBase): ret = subprocess.call(["cargo", "build"] + opts, env=env) elapsed = time() - build_start + # Generate Desktop Notification if elapsed-time > some threshold value + notify(elapsed) + print("Gonk build completed in %0.2fs" % elapsed) return ret diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index cab3f7ba81f..7caac6e33bd 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -31,6 +31,15 @@ class MachCommands(CommandBase): return subprocess.call(['cargo'] + params, env=self.build_env()) + @Command('cargo-update', + description='Same as update-cargo', + category='devenv') + @CommandArgument( + 'params', default=None, nargs='...', + help='Command-line arguments to be passed through to cargo update') + def cargo_update(self, params=None): + self.update_cargo(params) + @Command('update-cargo', description='Update Cargo dependencies', category='devenv') diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index e538c79c789..b93d3689700 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -64,7 +64,6 @@ class MachCommands(CommandBase): test_dirs = [ # path, mach test command, optional flag for path argument - (path.join("tests", "content"), "test-content", None), (path.join("tests", "wpt"), "test-wpt", None), (path.join("tests", "ref"), "test-ref", ["--name"]), ] @@ -93,7 +92,7 @@ class MachCommands(CommandBase): return self.infer_test_by_dir(params) test_start = time() - for t in ["tidy", "ref", "content", "wpt", "css", "unit"]: + for t in ["tidy", "ref", "wpt", "css", "unit"]: Registrar.dispatch("test-%s" % t, context=self.context) elapsed = time() - test_start @@ -163,23 +162,10 @@ class MachCommands(CommandBase): @Command('test-content', description='Run the content tests', category='testing') - @CommandArgument('test_name', default=None, nargs="?", - help="Only run tests that match this pattern") - def test_content(self, test_name=None): - self.ensure_bootstrapped() - self.ensure_built_tests() - test_path = path.join(self.context.topdir, "tests", "content") - test_args = ["--source-dir=%s" % test_path] - - if test_name is not None: - test_args.append(test_name) - - test_start = time() - ret = self.run_test("contenttest", test_args) - elapsed = time() - test_start - - print("Content tests completed in %0.2fs" % elapsed) - return ret + def test_content(self): + print("Content tests have been replaced by web-platform-tests under " + "tests/wpt/mozilla/.") + return 0 @Command('test-tidy', description='Run the source code tidiness check', |