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

Side by Side Diff: pkg/dart_messages/test/parser_test.dart

Issue 1514333002: Add dart_messages package. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Minor fixes (long line...) 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 unified diff | Download patch
OLDNEW
(Empty)
1 import 'dart:async';
2 import 'dart:io';
3
4 Future testJsParser(serverUrl) async {
5 String drt = "../../../client/tests/drt/content_shell";
Johnni Winther 2015/12/11 11:27:29 What is this? (I don't have a file at that locatio
floitsch 2015/12/14 18:56:41 The file is downloaded when running any test with
6 String drtPath = Platform.script.resolve(drt).toFilePath();
7 String testPage = "$serverUrl/test/parser_test.html";
8 print("running drt $testPage");
9 ProcessResult result =
10 await Process.run(drtPath, ['--dump-render-tree', testPage]);
11 if (!result.stdout.contains("SUCCESS") || result.stdout.contains("FAILED")) {
12 throw "Test failed";
13 }
14 print(result.stdout);
15 print(result.stderr);
16 }
17
18 Uri pathOfData = Platform.script.resolve('../');
19
20 _sendNotFound(HttpResponse response) {
21 response.statusCode = HttpStatus.NOT_FOUND;
22 response.close();
23 }
24
25 Future handleRequest(HttpRequest request) {
26 final String path = request.uri.path.substring(1);
27 final Uri requestPath = pathOfData.resolve(path);
28 final File file = new File(requestPath.toFilePath());
29 print("serving $requestPath");
30 if (path.endsWith("html")) {
31 request.response.headers.add('Content-Type', 'text/html');
32 } else if (path.endsWith("js")) {
33 request.response.headers.add('Content-Type', 'application/javascript');
34 }
35 return file.exists().then((bool found) {
36 if (found) {
37 file.openRead()
38 .pipe(request.response)
39 .catchError((e) { _sendNotFound(request.response); });
40 } else {
41 _sendNotFound(request.response);
42 }
43 });
44 }
45
46 serverRunning(HttpServer server, String scheme) async {
47 int port = server.port;
48 String serverUrl = "$scheme://127.0.0.1:$port";
49
50 server.listen(handleRequest);
51
52 try {
53 await testJsParser(serverUrl);
54 } finally {
55 server.close();
56 }
57 }
58
59 Future runServerAndTests() {
60 return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0)
61 .then((HttpServer server) => serverRunning(server, "http"));
62 }
63
64 main() {
65 runServerAndTests();
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698