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

Unified Diff: test/codegen_test.dart

Issue 1056613002: reduce diff churn due to server_mode test (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months 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 | « test/codegen/expect/server_mode/html_input.txt ('k') | tool/test.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
});
}
}
« no previous file with comments | « test/codegen/expect/server_mode/html_input.txt ('k') | tool/test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698