Chromium Code Reviews| Index: test/codegen_test.dart |
| diff --git a/test/codegen_test.dart b/test/codegen_test.dart |
| index a23a58b2476ae1e1130aecd82f8acb055d7d4041..80ed7fa0206e09afe17aff30f0d4b59d18a07038 100644 |
| --- a/test/codegen_test.dart |
| +++ b/test/codegen_test.dart |
| @@ -20,6 +20,9 @@ import 'package:dev_compiler/devc.dart'; |
| import 'package:dev_compiler/src/options.dart'; |
| import 'package:dev_compiler/src/dependency_graph.dart' |
| show defaultRuntimeFiles; |
| +import 'package:dev_compiler/src/utils.dart' |
| + show computeHash, computeHashFromFile; |
| +import 'package:html/parser.dart' as html; |
| final ArgParser argParser = new ArgParser() |
| ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) |
| @@ -227,7 +230,6 @@ main(arguments) { |
| .writeAsStringSync(compilerMessages.toString()); |
| var expectedFiles = [ |
| - 'html_input.html', |
| 'dir/html_input_a.js', |
| 'dir/html_input_b.js', |
| 'dir/html_input_c.js', |
| @@ -237,11 +239,37 @@ main(arguments) { |
| 'dev_compiler/runtime/messages.css' |
| ]..addAll(expectedRuntime); |
| + // Parse the HTML file and verify its contents were expected. |
| + var htmlPath = path.join(actualDir, 'server_mode', 'html_input.html'); |
| + var doc = html.parse(new File(htmlPath).readAsStringSync()); |
| + |
| for (var filepath in expectedFiles) { |
| - var outFile = new File(path.join(actualDir, 'server_mode', filepath)); |
| - expect(outFile.existsSync(), success, |
| - reason: '${outFile.path} was created iff compilation succeeds'); |
| + var outPath = path.join(actualDir, 'server_mode', filepath); |
| + expect(new File(outPath).existsSync(), success, |
| + reason: '$outPath was created iff compilation succeeds'); |
| + |
| + var query; |
| + if (filepath.endsWith('js')) { |
| + var hash; |
| + if (filepath.startsWith('dev_compiler')) { |
| + hash = computeHashFromFile(outPath); |
| + } else { |
| + // TODO(jmesserly): see if we can get this to return the same |
| + // answer as computeHashFromFile. |
| + hash = computeHash(new File(outPath).readAsStringSync()); |
| + } |
| + query = 'script[src="cached/$hash/$filepath"]'; |
| + } else { |
| + var hash = computeHashFromFile(outPath); |
| + query = 'link[href="cached/$hash/$filepath"]'; |
| + } |
| + expect(doc.querySelector(query), isNotNull, |
| + reason: "should find `$query` in $htmlPath for $outPath"); |
| } |
| + |
| + // Clean up the server mode folder, otherwise it causes diff churn. |
| + var dir = new Directory(path.join(actualDir, 'server_mode')); |
| + if (dir.existsSync()) dir.deleteSync(recursive: true); |
|
Siggi Cherem (dart-lang)
2015/04/01 21:28:20
minor nit: maybe just assert that it exists?
expe
|
| }); |
| } |
| } |