Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: mojo/dart/http_load_test/bin/tester.dart

Issue 1545483003: Dart: Reorganize files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix build file Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/dart/http_load_test/BUILD.gn ('k') | mojo/dart/http_load_test/lib/main.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/http_load_test/bin/tester.dart
diff --git a/mojo/dart/http_load_test/bin/tester.dart b/mojo/dart/http_load_test/bin/tester.dart
deleted file mode 100644
index e26927215fc4892e68a314f9bedf010aacac3adb..0000000000000000000000000000000000000000
--- a/mojo/dart/http_load_test/bin/tester.dart
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library http_load_test;
-
-import 'dart:async';
-import 'dart:convert';
-import 'dart:io';
-
-class Launcher {
- /// Launch [executable] with [arguments]. Returns a [String] containing
- /// the standard output from the launched executable.
- static Future<String> launch(String executable,
- List<String> arguments) async {
- var process = await Process.start(executable, arguments);
-
- // Completer completes once the child process exits.
- var completer = new Completer();
- String output = '';
- process.stdout.transform(UTF8.decoder)
- .transform(new LineSplitter()).listen((line) {
- output = '$output\n$line';
- print(line);
- });
- process.stderr.transform(UTF8.decoder)
- .transform(new LineSplitter()).listen((line) {
- output = '$output\n$line';
- print(line);
- });
- process.exitCode.then((ec) {
- output = '$output\nEXIT_CODE=$ec\n';
- completer.complete(output);
- });
- return completer.future;
- }
-}
-
-main(List<String> args) async {
- var mojo_shell_executable = args[0];
- var directory = args[1];
-
- HttpServer server = await HttpServer.bind('127.0.0.1', 0);
-
- server.listen((HttpRequest request) async {
- final String path = request.uri.toFilePath();
- final File file = new File('${directory}/${path}');
- if (await file.exists()) {
- try {
- await file.openRead().pipe(request.response);
- } catch (e) {
- print(e);
- }
- } else {
- request.response.statusCode = HttpStatus.NOT_FOUND;
- request.response.close();
- }
- });
-
- var launchUrl = 'http://127.0.0.1:${server.port}/lib/main.dart';
- var output = await Launcher.launch(mojo_shell_executable, [launchUrl]);
-
- server.close();
-
- if (output.contains("ERROR")) {
- throw "test failed.";
- }
- if (!output.contains("\nEXIT_CODE=0\n")) {
- throw "Test failed.";
- }
- if (!output.contains("\nPASS")) {
- throw "Test failed.";
- }
-}
« no previous file with comments | « mojo/dart/http_load_test/BUILD.gn ('k') | mojo/dart/http_load_test/lib/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698