Skip to content

Commit

Permalink
Update to mojo e172885c9058b3c4fad14302c22462b01fe61293
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccutchan committed Jul 30, 2015
1 parent 26d3132 commit 57ce2a4
Show file tree
Hide file tree
Showing 93 changed files with 237 additions and 103 deletions.
17 changes: 9 additions & 8 deletions mojo/dart/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ source_set("dart_controller_no_snapshot") {
"//mojo/public/c/system",
"//mojo/public/cpp/system",
"//mojo/services/network/public/interfaces",
"//tonic",
]

defines = []
Expand Down Expand Up @@ -84,22 +85,22 @@ group("dart_embedder_packages") {

dart_embedder_package("dart_embedder_package_application") {
package = "mojo/public/interfaces/application"
destination = "mojom/mojo"
destination = "mojo/mojo"
}

dart_embedder_package("dart_embedder_package_bindings") {
package = "mojo/public/interfaces/bindings"
destination = "mojom/mojo"
destination = "mojo/mojo"
}

dart_embedder_package("dart_embedder_package_network") {
package = "mojo/public/interfaces/network"
destination = "mojom/mojo"
destination = "mojo/mojo"
}

dart_embedder_package("dart_embedder_package_network_service") {
package = "mojo/services/network/public/interfaces"
destination = "mojom/mojo"
destination = "mojo_services/mojo"
}

action_foreach("dart_embedder_package_sdk") {
Expand Down Expand Up @@ -351,10 +352,10 @@ action("generate_snapshot_bin") {
rebase_path("$root_gen_dir/dart_embedder_packages"),

# Embedder package directories.
"$application_mojoms,mojom/mojo",
"$bindings_mojoms,mojom/mojo",
"$network_mojoms,mojom/mojo",
"$network_service_mojoms,mojom/mojo",
"$application_mojoms,mojo/mojo",
"$bindings_mojoms,mojo/mojo",
"$network_mojoms,mojo/mojo",
"$network_service_mojoms,mojo_services/mojo",
],
"list lines")

Expand Down
14 changes: 7 additions & 7 deletions mojo/dart/embedder/io/mojo_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import 'dart:_mojo/application.dart';
import 'dart:_mojo/bindings.dart';
import 'dart:_mojo/core.dart';
import 'dart:_mojom/mojo/host_resolver.mojom.dart';
import 'dart:_mojom/mojo/net_address.mojom.dart';
import 'dart:_mojom/mojo/network_error.mojom.dart';
import 'dart:_mojom/mojo/network_service.mojom.dart';
import 'dart:_mojom/mojo/tcp_bound_socket.mojom.dart';
import 'dart:_mojom/mojo/tcp_connected_socket.mojom.dart';
import 'dart:_mojom/mojo/tcp_server_socket.mojom.dart';
import 'dart:_mojo/mojo/network_error.mojom.dart';
import 'dart:_mojo_services/mojo/host_resolver.mojom.dart';
import 'dart:_mojo_services/mojo/net_address.mojom.dart';
import 'dart:_mojo_services/mojo/network_service.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_bound_socket.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_connected_socket.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_server_socket.mojom.dart';

//
// Mojo objects and helper functions used by the 'dart:io' library.
Expand Down
14 changes: 7 additions & 7 deletions mojo/dart/embedder/packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ library dart_embedder_packages;
import 'dart:_mojo/application.dart';
import 'dart:_mojo/bindings.dart';
import 'dart:_mojo/core.dart';
import 'dart:_mojom/mojo/host_resolver.mojom.dart';
import 'dart:_mojom/mojo/net_address.mojom.dart';
import 'dart:_mojom/mojo/network_error.mojom.dart';
import 'dart:_mojom/mojo/network_service.mojom.dart';
import 'dart:_mojom/mojo/tcp_bound_socket.mojom.dart';
import 'dart:_mojom/mojo/tcp_connected_socket.mojom.dart';
import 'dart:_mojom/mojo/tcp_server_socket.mojom.dart';
import 'dart:_mojo/mojo/network_error.mojom.dart';
import 'dart:_mojo_services/mojo/host_resolver.mojom.dart';
import 'dart:_mojo_services/mojo/net_address.mojom.dart';
import 'dart:_mojo_services/mojo/network_service.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_bound_socket.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_connected_socket.mojom.dart';
import 'dart:_mojo_services/mojo/tcp_server_socket.mojom.dart';
1 change: 0 additions & 1 deletion mojo/dart/mojo_services/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ dart_pkg("mojo_services") {

deps = [
"//mojo/services",
"//mojo/public/interfaces",
]
}
4 changes: 3 additions & 1 deletion mojo/dart/mojo_services/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
author: Chromium Authors <[email protected]>
dependencies:
mojo: any
description: Generated bindings for mojo services
homepage: https://github.com/domokit/mojo
name: mojo_services
version: 0.0.19
version: 0.0.21
2 changes: 1 addition & 1 deletion mojo/dart/mojom/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ environment:
sdk: '>=1.9.0 <2.0.0'
homepage: https://github.com/domokit/mojo
name: mojom
version: 0.0.19
version: 0.0.21
42 changes: 31 additions & 11 deletions mojo/devtools/common/devtoolslib/android_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,40 @@ def Run(self, arguments):
p.wait()
return None

def RunAndGetOutput(self, arguments):
"""Runs the shell with given arguments until shell exits.
def RunAndGetOutput(self, arguments, timeout=None):
"""Runs the shell with given arguments until shell exits and returns the
output.
Args:
arguments: list of arguments for the shell
timeout: maximum running time in seconds, after which the shell will be
terminated
Returns:
A tuple of (return_code, output). |return_code| is the exit code returned
by the shell or None if the exit code cannot be retrieved. |output| is the
stdout mingled with the stderr produced by the shell.
A tuple of (return_code, output, did_time_out). |return_code| is the exit
code returned by the shell or None if the exit code cannot be retrieved.
|output| is the stdout mingled with the stderr produced by the shell.
|did_time_out| is True iff the shell was terminated because it exceeded
the |timeout| and False otherwise.
"""
(r, w) = os.pipe()
with os.fdopen(r, "r") as rf:
with os.fdopen(w, "w") as wf:
self.StartShell(arguments, wf, wf.close)
output = rf.read()
return None, output
class Results:
"""Workaround for Python scoping rules that prevent assigning to variables
from the outer scope.
"""
output = None

def do_run():
(r, w) = os.pipe()
with os.fdopen(r, "r") as rf:
with os.fdopen(w, "w") as wf:
self.StartShell(arguments, wf, wf.close)
Results.output = rf.read()

run_thread = threading.Thread(target=do_run)
run_thread.start()
run_thread.join(timeout)

if run_thread.is_alive():
self.StopShell()
return None, Results.output, True
return None, Results.output, False
9 changes: 6 additions & 3 deletions mojo/devtools/common/devtoolslib/apptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def _build_shell_arguments(shell_args, apptest_url, apptest_args):
return result


def run_apptest(shell, shell_args, apptest_url, apptest_args, output_test):
def run_apptest(shell, shell_args, apptest_url, apptest_args, timeout,
output_test):
"""Runs shell with the given arguments, retrieves the output and applies
|output_test| to determine if the run was successful.
Expand All @@ -52,18 +53,20 @@ def run_apptest(shell, shell_args, apptest_url, apptest_args, output_test):

_logger.debug("Starting: " + command_line)
start_time = time.time()
(exit_code, output) = shell.RunAndGetOutput(arguments)
(exit_code, output, did_time_out) = shell.RunAndGetOutput(arguments, timeout)
run_time = time.time() - start_time
_logger.debug("Completed: " + command_line)

# Only log if it took more than 3 second.
if run_time >= 3:
_logger.info("Test took %.3f seconds: %s" % (run_time, command_line))

if exit_code or not output_test(output):
if exit_code or did_time_out or not output_test(output):
print 'Failed test: %r' % command_line
if exit_code:
print ' due to shell exit code %d' % exit_code
elif did_time_out:
print ' due to exceeded timeout of %fs' % timeout
else:
print ' due to test results'
print 72 * '-'
Expand Down
7 changes: 4 additions & 3 deletions mojo/devtools/common/devtoolslib/apptest_dart.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

SUCCESS_PATTERN = re.compile('^.+ .+: All tests passed!', re.MULTILINE)


def _dart_apptest_output_test(output):
return SUCCESS_PATTERN.search(output) != None
return SUCCESS_PATTERN.search(output) is not None


# TODO(erg): Support android, launched services and fixture isolation.
def run_dart_apptest(shell, shell_args, apptest_url, apptest_args):
def run_dart_apptest(shell, shell_args, apptest_url, apptest_args, timeout):
"""Runs a dart apptest.
Args:
Expand All @@ -30,5 +31,5 @@ def run_dart_apptest(shell, shell_args, apptest_url, apptest_args):
Returns:
True iff the test succeeded, False otherwise.
"""
return run_apptest(shell, shell_args, apptest_url, apptest_args,
return run_apptest(shell, shell_args, apptest_url, apptest_args, timeout,
_dart_apptest_output_test)
11 changes: 6 additions & 5 deletions mojo/devtools/common/devtoolslib/apptest_gtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def _gtest_apptest_output_test(output):
return True


def run_gtest_apptest(shell, shell_args, apptest_url, apptest_args, isolate):
def run_gtest_apptest(shell, shell_args, apptest_url, apptest_args, timeout,
isolate):
"""Runs a gtest apptest.
Args:
Expand All @@ -41,7 +42,7 @@ def run_gtest_apptest(shell, shell_args, apptest_url, apptest_args, isolate):
"""

if not isolate:
return run_apptest(shell, shell_args, apptest_url, apptest_args,
return run_apptest(shell, shell_args, apptest_url, apptest_args, timeout,
_gtest_apptest_output_test)

# List the apptest fixtures so they can be run independently for isolation.
Expand All @@ -54,7 +55,7 @@ def run_gtest_apptest(shell, shell_args, apptest_url, apptest_args, isolate):
for fixture in fixtures:
isolated_apptest_args = apptest_args + ["--gtest_filter=%s" % fixture]
success = run_apptest(shell, shell_args, apptest_url, isolated_apptest_args,
_gtest_apptest_output_test)
timeout, _gtest_apptest_output_test)

if not success:
apptest_result = False
Expand All @@ -78,8 +79,8 @@ def get_fixtures(shell, shell_args, apptest):
arguments.append("--args-for=%s %s" % (apptest, "--gtest_list_tests"))
arguments.append(apptest)

(exit_code, output) = shell.RunAndGetOutput(arguments)
if exit_code:
(exit_code, output, did_time_out) = shell.RunAndGetOutput(arguments)
if exit_code or did_time_out:
command_line = "mojo_shell " + " ".join(["%r" % x for x in arguments])
print "Failed to get test fixtures: %r" % command_line
print 72 * '-'
Expand Down
36 changes: 29 additions & 7 deletions mojo/devtools/common/devtoolslib/linux_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

import subprocess
import threading

from devtoolslib.shell import Shell
from devtoolslib import http_server
Expand Down Expand Up @@ -61,19 +62,40 @@ def Run(self, arguments):
command = self.command_prefix + [self.executable_path] + arguments
return subprocess.call(command, stderr=subprocess.STDOUT)

def RunAndGetOutput(self, arguments):
"""Runs the shell with given arguments until shell exits.
def RunAndGetOutput(self, arguments, timeout=None):
"""Runs the shell with given arguments until shell exits and returns the
output.
Args:
arguments: list of arguments for the shell
timeout: maximum running time in seconds, after which the shell will be
terminated
Returns:
A tuple of (return_code, output). |return_code| is the exit code returned
by the shell or None if the exit code cannot be retrieved. |output| is the
stdout mingled with the stderr produced by the shell.
A tuple of (return_code, output, did_time_out). |return_code| is the exit
code returned by the shell or None if the exit code cannot be retrieved.
|output| is the stdout mingled with the stderr produced by the shell.
|did_time_out| is True iff the shell was terminated because it exceeded
the |timeout| and False otherwise.
"""
command = self.command_prefix + [self.executable_path] + arguments
p = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
(output, _) = p.communicate()
return p.returncode, output

class Results:
"""Workaround for Python scoping rules that prevent assigning to variables
from the outer scope.
"""
output = None

def do_run():
(Results.output, _) = p.communicate()

run_thread = threading.Thread(target=do_run)
run_thread.start()
run_thread.join(timeout)

if run_thread.is_alive():
p.terminate()
return p.returncode, Results.output, True
return p.returncode, Results.output, False
12 changes: 8 additions & 4 deletions mojo/devtools/common/devtoolslib/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ def Run(self, arguments):
"""
raise NotImplementedError()

def RunAndGetOutput(self, arguments):
def RunAndGetOutput(self, arguments, timeout=None):
"""Runs the shell with given arguments until shell exits and returns the
output.
Args:
arguments: list of arguments for the shell
timeout: maximum running time in seconds, after which the shell will be
terminated
Returns:
A tuple of (return_code, output). |return_code| is the exit code returned
by the shell or None if the exit code cannot be retrieved. |output| is the
stdout mingled with the stderr produced by the shell.
A tuple of (return_code, output, did_time_out). |return_code| is the exit
code returned by the shell or None if the exit code cannot be retrieved.
|output| is the stdout mingled with the stderr produced by the shell.
|did_time_out| is True iff the shell was terminated because it exceeded
the |timeout| and False otherwise.
"""
raise NotImplementedError()
Loading

0 comments on commit 57ce2a4

Please sign in to comment.