Chromium Code Reviews| Index: tools/testing/dart/html_test.dart |
| diff --git a/tools/testing/dart/html_test.dart b/tools/testing/dart/html_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..51c6b10c827ae7c4de8c24f2521e73308e1d6017 |
| --- /dev/null |
| +++ b/tools/testing/dart/html_test.dart |
| @@ -0,0 +1,44 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * Classes and methods for running HTML tests. |
| + * |
| + * HTML tests are valid HTML files whose name ends in _test.html, and that |
|
ricow1
2014/11/04 09:18:03
this is not really what you say in the other files
Bill Hesse
2014/11/04 16:29:01
Done.
|
| + * contain an annotation specifying the scripts in the test and the |
| + * messages the test should post to its window, when passing. |
| + */ |
| +library html_test; |
| + |
| +import "dart:convert"; |
| +import "dart:io"; |
| + |
| +import "test_suite.dart"; |
| +import "utils.dart"; |
| + |
| +RegExp htmlAnnotation = |
| + new RegExp("START_HTML_DART_TEST([\\s\\S]*?)END_HTML_DART_TEST"); |
| + |
| +HtmlTestInformation getInformation(String filename) { |
| + String contents = new File(filename).readAsStringSync(); |
|
ricow1
2014/11/04 09:18:03
assert that the file ending is correct
Bill Hesse
2014/11/04 16:29:01
Done. But this is not really a concern of the HTM
|
| + var match = htmlAnnotation.firstMatch(contents); |
| + print(match); |
|
ricow1
2014/11/04 09:18:03
remove debug print
Bill Hesse
2014/11/04 16:29:01
Done.
|
| + if (match == null) return null; |
| + print(match[1]); |
|
ricow1
2014/11/04 09:18:03
remove debug print
Bill Hesse
2014/11/04 16:29:01
Done.
|
| + var annotation = JSON.decode(match[1]); |
| + if (annotation is! Map || annotation['expectedMessages'] is! List || |
| + annotation['scripts'] is! List) { |
| + DebugLogger.warning("File $filename does not have expected annotation." |
| + " Should have {'scripts':[...], 'expectedMessages':[...]}"); |
| + return null; |
| + } |
| + return new HtmlTestInformation(new Path(filename), |
| + annotation['expectedMessages'], |
| + annotation['scripts']); |
| +} |
| + |
| +String getContents(HtmlTestInformation info) { |
| + String contents = new File(info.filePath.toNativePath()).readAsStringSync(); |
| + return contents.replaceFirst(htmlAnnotation, ''); |
| +} |