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

Unified Diff: test/codegen_test.dart

Issue 1322333003: DDC: mostly incremental compilation, fixes #223 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 3 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
Index: test/codegen_test.dart
diff --git a/test/codegen_test.dart b/test/codegen_test.dart
index 70993a6794f52b5cb8cf9aa9659c5bf7dac2fa3f..352f65abea57e708e3396f15c6dc19c096b4e9a2 100644
--- a/test/codegen_test.dart
+++ b/test/codegen_test.dart
@@ -39,20 +39,6 @@ main(arguments) {
if (arguments == null) arguments = [];
ArgResults args = argParser.parse(arguments);
var filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.');
- var compilerMessages = new StringBuffer();
- var loggerSub;
-
- setUp(() {
- compilerMessages.clear();
- loggerSub = setupLogger(Level.CONFIG, compilerMessages.writeln);
- });
-
- tearDown(() {
- if (loggerSub != null) {
- loggerSub.cancel();
- loggerSub = null;
- }
- });
var inputDir = path.join(testDirectory, 'codegen');
var expectDir = path.join(inputDir, 'expect');
@@ -72,7 +58,8 @@ main(arguments) {
checkSdk: checkSdk,
runtimeDir: runtimeDir,
inputs: [entryPoint],
- inputBaseDir: inputDir);
+ inputBaseDir: inputDir,
+ saveMessages: true);
var reporter = createErrorReporter(context, options);
return new BatchCompiler(context, options, reporter: reporter).run();
}
@@ -110,10 +97,14 @@ main(arguments) {
}
});
+ var modifyTime = new File(filePath).lastModifiedSync();
var filename = path.basenameWithoutExtension(filePath);
tests.forEach((name, contents) {
- new File(path.join(languageDir, '${filename}_${name}_multi.dart'))
- .writeAsStringSync(contents);
+ var f = new File(
+ path.join(languageDir, '${filename}_${name}_multi.dart'));
+ if (!f.existsSync() || f.lastModifiedSync().isBefore(modifyTime)) {
+ f.writeAsStringSync(contents);
+ }
});
}
}
@@ -128,23 +119,25 @@ main(arguments) {
var filename = path.basenameWithoutExtension(filePath);
test('$filename.dart', () {
- compilerMessages.writeln('// Messages from compiling $filename.dart');
-
// TODO(jmesserly): this was added to get some coverage of source maps
// and closure annotations.
// We need a more comprehensive strategy to test them.
var sourceMaps = filename == 'map_keys';
var closure = filename == 'closure';
- var success = compile(filePath, realSdkContext,
+ compile(filePath, realSdkContext,
sourceMaps: sourceMaps, closure: closure);
- // Write compiler messages to disk.
- new File(path.join(outDir, '$filename.txt'))
- .writeAsStringSync('$compilerMessages');
+ var messageFile = new File(path.join(outDir, '$filename.txt'));
+ var jsFile = new File(path.join(outDir, '$filename.js'));
- var outFile = new File(path.join(outDir, '$filename.js'));
- expect(outFile.existsSync(), success,
- reason: '${outFile.path} was created iff compilation succeeds');
+ bool error = false;
+ if (messageFile.existsSync()) {
+ var messageContents = messageFile.readAsStringSync();
+ error = messageContents.contains('severe');
+ }
+
+ expect(jsFile.existsSync() == !error, true,
+ reason: 'JS file should exist iff no errors were found.');
});
}
});
@@ -188,32 +181,19 @@ main(arguments) {
test('devc jscodegen sunflower.html', () {
var filePath = path.join(inputDir, 'sunflower', 'sunflower.html');
- compilerMessages.writeln('// Messages from compiling sunflower.html');
-
- var success = compile(filePath, realSdkContext);
-
- // Write compiler messages to disk.
- new File(path.join(expectDir, 'sunflower', 'sunflower.txt'))
- .writeAsStringSync(compilerMessages.toString());
+ compile(filePath, realSdkContext);
var expectedFiles = ['sunflower.html', 'sunflower.js',];
for (var filepath in expectedFiles) {
var outFile = new File(path.join(expectDir, 'sunflower', filepath));
- expect(outFile.existsSync(), success,
- reason: '${outFile.path} was created iff compilation succeeds');
+ expect(outFile.existsSync(), true, reason: '${outFile.path} was created');
}
});
test('devc jscodegen html_input.html', () {
var filePath = path.join(inputDir, 'html_input.html');
- compilerMessages.writeln('// Messages from compiling html_input.html');
-
- var success = compile(filePath, realSdkContext);
-
- // Write compiler messages to disk.
- new File(path.join(expectDir, 'html_input.txt'))
- .writeAsStringSync(compilerMessages.toString());
+ compile(filePath, realSdkContext);
var expectedFiles = [
'html_input.html',
@@ -226,8 +206,7 @@ main(arguments) {
for (var filepath in expectedFiles) {
var outFile = new File(path.join(expectDir, filepath));
- expect(outFile.existsSync(), success,
- reason: '${outFile.path} was created iff compilation succeeds');
+ expect(outFile.existsSync(), true, reason: '${outFile.path} was created');
}
});
}
« lib/src/options.dart ('K') | « test/codegen/js_test.dart ('k') | test/end_to_end_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698