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

Side by Side Diff: tools/testing/dart/html_test.dart

Issue 695893002: Working SimpleHTML test front end (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Classes and methods for running HTML tests.
7 *
8 * HTML tests are valid HTML files whose names end in _htmltest.html, and that
9 * contain annotations specifying the scripts in the test and the
10 * messages the test should post to its window, in order to pass.
11 */
12 library html_test;
13
14 import "dart:convert";
15 import "dart:io";
16
17 import "test_suite.dart";
18 import "utils.dart";
19
20 RegExp htmlAnnotation =
21 new RegExp("START_HTML_DART_TEST([\\s\\S]*?)END_HTML_DART_TEST");
22
23 HtmlTestInformation getInformation(String filename) {
24 if (!filename.endsWith("_htmltest.html")) {
25 DebugLogger.warning("File $filename is not an HTML test."
26 " Should end in _htmltest.html.");
27 return null;
28 }
29 String contents = new File(filename).readAsStringSync();
30 var match = htmlAnnotation.firstMatch(contents);
31 if (match == null) return null;
32 var annotation = JSON.decode(match[1]);
33 if (annotation is! Map || annotation['expectedMessages'] is! List ||
34 annotation['scripts'] is! List) {
35 DebugLogger.warning("File $filename does not have expected annotation."
36 " Should have {'scripts':[...], 'expectedMessages':[...]}");
37 return null;
38 }
39 return new HtmlTestInformation(new Path(filename),
40 annotation['expectedMessages'],
41 annotation['scripts']);
42 }
43
44 String getContents(HtmlTestInformation info) {
45 String contents = new File(info.filePath.toNativePath()).readAsStringSync();
46 return contents.replaceFirst(htmlAnnotation, '');
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698