Skip to content

Commit

Permalink
makes tests faster, see #304
Browse files Browse the repository at this point in the history
this doesn't completely address the issue, but it knocks off some of the time.
also attempt to stabilize error message order.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1321103002 .
  • Loading branch information
John Messerly committed Aug 28, 2015
1 parent c4b754b commit 9c832d6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 75 deletions.
16 changes: 12 additions & 4 deletions pkg/dev_compiler/lib/src/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class BatchCompiler extends AbstractCompiler {

/// Already compiled sources, so we don't compile them again.
final _compiled = new HashSet<LibraryElement>();
bool _sdkCopied = false;

bool _failure = false;
bool get failure => _failure;
Expand All @@ -101,6 +102,7 @@ class BatchCompiler extends AbstractCompiler {

void reset() {
_compiled.clear();
_sdkCopied = false;
}

/// Compiles every file in [options.inputs].
Expand Down Expand Up @@ -178,11 +180,17 @@ class BatchCompiler extends AbstractCompiler {
}

void _copyDartRuntime() {
if (_sdkCopied) return;
_sdkCopied = true;
for (var file in defaultRuntimeFiles) {
var input = path.join(options.runtimeDir, file);
var output = path.join(_runtimeOutputDir, file);
new Directory(path.dirname(output)).createSync(recursive: true);
new File(input).copySync(output);
var input = new File(path.join(options.runtimeDir, file));
var output = new File(path.join(_runtimeOutputDir, file));
if (output.existsSync() &&
output.lastModifiedSync() == input.lastModifiedSync()) {
continue;
}
new Directory(path.dirname(output.path)).createSync(recursive: true);
input.copySync(output.path);
}
}

Expand Down
16 changes: 9 additions & 7 deletions pkg/dev_compiler/lib/src/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ class ErrorCollector implements AnalysisErrorListener {
var severity1 = _strongModeErrorSeverity(error1);
var severity2 = _strongModeErrorSeverity(error2);
int compare = severity2.compareTo(severity1);
if (compare != 0) {
return compare;
}
if (compare != 0) return compare;

// path
compare = Comparable.compare(error1.source.fullName.toLowerCase(),
error2.source.fullName.toLowerCase());
if (compare != 0) {
return compare;
}
if (compare != 0) return compare;

// offset
return error1.offset - error2.offset;
compare = error1.offset - error2.offset;
if (compare != 0) return compare;

// compare message, in worst case.
return error1.message.compareTo(error2.message);
});

_errors.forEach(listener.onError);
Expand Down
18 changes: 9 additions & 9 deletions pkg/dev_compiler/test/codegen/expect/js_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -562,24 +562,24 @@ info: [DynamicInvoke] expect(jsObject['a'][0], object['a'][0]) requires dynamic
info: [DynamicInvoke] jsObject['a'][0] requires dynamic invoke (test/codegen/js_test.dart, line 495, col 14)
info: [DynamicInvoke] object['a'][0] requires dynamic invoke (test/codegen/js_test.dart, line 495, col 32)
info: [DynamicInvoke] expect(jsObject['a'][1][0], object['a'][1][0]) requires dynamic invoke (test/codegen/js_test.dart, line 496, col 7)
info: [DynamicInvoke] jsObject['a'][1][0] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 14)
info: [DynamicInvoke] jsObject['a'][1] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 14)
info: [DynamicInvoke] object['a'][1][0] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 35)
info: [DynamicInvoke] jsObject['a'][1][0] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 14)
info: [DynamicInvoke] object['a'][1] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 35)
info: [DynamicInvoke] object['a'][1][0] requires dynamic invoke (test/codegen/js_test.dart, line 496, col 35)
info: [DynamicInvoke] expect(jsObject['a'][1][1], object['a'][1][1]) requires dynamic invoke (test/codegen/js_test.dart, line 497, col 7)
info: [DynamicInvoke] jsObject['a'][1][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 14)
info: [DynamicInvoke] jsObject['a'][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 14)
info: [DynamicInvoke] object['a'][1][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 35)
info: [DynamicInvoke] jsObject['a'][1][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 14)
info: [DynamicInvoke] object['a'][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 35)
info: [DynamicInvoke] object['a'][1][1] requires dynamic invoke (test/codegen/js_test.dart, line 497, col 35)
info: [DynamicInvoke] expect(jsObject['b']['c'], object['b']['c']) requires dynamic invoke (test/codegen/js_test.dart, line 498, col 7)
info: [DynamicInvoke] jsObject['b']['c'] requires dynamic invoke (test/codegen/js_test.dart, line 498, col 14)
info: [DynamicInvoke] object['b']['c'] requires dynamic invoke (test/codegen/js_test.dart, line 498, col 34)
info: [DynamicInvoke] expect(jsObject['b']['d'], object['b']['d']) requires dynamic invoke (test/codegen/js_test.dart, line 499, col 7)
info: [DynamicInvoke] jsObject['b']['d'] requires dynamic invoke (test/codegen/js_test.dart, line 499, col 14)
info: [DynamicInvoke] object['b']['d'] requires dynamic invoke (test/codegen/js_test.dart, line 499, col 34)
info: [DynamicInvoke] expect(jsObject['b']['d'].callMethod('bar'), 42) requires dynamic invoke (test/codegen/js_test.dart, line 500, col 7)
info: [DynamicInvoke] jsObject['b']['d'].callMethod('bar') requires dynamic invoke (test/codegen/js_test.dart, line 500, col 14)
info: [DynamicInvoke] jsObject['b']['d'] requires dynamic invoke (test/codegen/js_test.dart, line 500, col 14)
info: [DynamicInvoke] jsObject['b']['d'].callMethod('bar') requires dynamic invoke (test/codegen/js_test.dart, line 500, col 14)
info: [DynamicInvoke] expect(jsObject['e'], null) requires dynamic invoke (test/codegen/js_test.dart, line 501, col 7)
info: [DynamicInvoke] test('throws if object is not a Map or Iterable', () {expect(() => new JsObject.jsify('a'), throwsA((a) => a is ArgumentError));}) requires dynamic invoke (test/codegen/js_test.dart, line 504, col 5)
info: [DynamicInvoke] expect(() => new JsObject.jsify('a'), throwsA((a) => a is ArgumentError)) requires dynamic invoke (test/codegen/js_test.dart, line 505, col 7)
Expand Down Expand Up @@ -607,14 +607,14 @@ info: [DynamicInvoke] expect(foo.instanceof(context['String']), false) requires
info: [DynamicCast] context['String'] (dynamic) will need runtime check to cast to type JsFunction (test/codegen/js_test.dart, line 538, col 29)
info: [DynamicInvoke] test('deleteProperty', () {var object = new JsObject.jsify({}); object['a'] = 1; expect(context['Object'].callMethod('keys', [object])['length'], 1); expect(context['Object'].callMethod('keys', [object])[0], "a"); object.deleteProperty("a"); expect(context['Object'].callMethod('keys', [object])['length'], 0);}) requires dynamic invoke (test/codegen/js_test.dart, line 541, col 5)
info: [DynamicInvoke] expect(context['Object'].callMethod('keys', [object])['length'], 1) requires dynamic invoke (test/codegen/js_test.dart, line 544, col 7)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])['length'] requires dynamic invoke (test/codegen/js_test.dart, line 544, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object]) requires dynamic invoke (test/codegen/js_test.dart, line 544, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])['length'] requires dynamic invoke (test/codegen/js_test.dart, line 544, col 14)
info: [DynamicInvoke] expect(context['Object'].callMethod('keys', [object])[0], "a") requires dynamic invoke (test/codegen/js_test.dart, line 545, col 7)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])[0] requires dynamic invoke (test/codegen/js_test.dart, line 545, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object]) requires dynamic invoke (test/codegen/js_test.dart, line 545, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])[0] requires dynamic invoke (test/codegen/js_test.dart, line 545, col 14)
info: [DynamicInvoke] expect(context['Object'].callMethod('keys', [object])['length'], 0) requires dynamic invoke (test/codegen/js_test.dart, line 547, col 7)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])['length'] requires dynamic invoke (test/codegen/js_test.dart, line 547, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object]) requires dynamic invoke (test/codegen/js_test.dart, line 547, col 14)
info: [DynamicInvoke] context['Object'].callMethod('keys', [object])['length'] requires dynamic invoke (test/codegen/js_test.dart, line 547, col 14)
info: [DynamicInvoke] test('hasProperty', () {var object = new JsObject.jsify({}); object['a'] = 1; expect(object.hasProperty('a'), true); expect(object.hasProperty('b'), false);}) requires dynamic invoke (test/codegen/js_test.dart, line 550, col 5)
info: [DynamicInvoke] expect(object.hasProperty('a'), true) requires dynamic invoke (test/codegen/js_test.dart, line 553, col 7)
info: [DynamicInvoke] expect(object.hasProperty('b'), false) requires dynamic invoke (test/codegen/js_test.dart, line 554, col 7)
Expand All @@ -638,8 +638,8 @@ info: [DynamicInvoke] test('window', () {expect(context['window'] is Window, tru
info: [DynamicInvoke] expect(context['window'] is Window, true) requires dynamic invoke (test/codegen/js_test.dart, line 582, col 9)
info: [DynamicInvoke] test('foreign browser objects should be proxied', () {var iframe = document.createElement('iframe'); document.body.appendChild(iframe); var proxy = new JsObject.fromBrowserObject(iframe); var contentWindow = proxy['contentWindow']; expect(contentWindow, isNot((a) => a is Window)); expect(contentWindow, (a) => a is JsObject); var foreignDoc = contentWindow['document']; expect(foreignDoc, isNot((a) => a is Node)); expect(foreignDoc, (a) => a is JsObject); var clicked = false; foreignDoc['onclick'] = (e) {expect(e, isNot((a) => a is Event)); expect(e, (a) => a is JsObject); clicked = true;}; context.callMethod('fireClickEvent', [contentWindow]); expect(clicked, true);}) requires dynamic invoke (test/codegen/js_test.dart, line 585, col 7)
info: [DynamicInvoke] document.createElement('iframe') requires dynamic invoke (test/codegen/js_test.dart, line 586, col 22)
info: [DynamicInvoke] document.body.appendChild(iframe) requires dynamic invoke (test/codegen/js_test.dart, line 587, col 9)
info: [DynamicInvoke] document.body requires dynamic invoke (test/codegen/js_test.dart, line 587, col 9)
info: [DynamicInvoke] document.body.appendChild(iframe) requires dynamic invoke (test/codegen/js_test.dart, line 587, col 9)
info: [DynamicInvoke] expect(contentWindow, isNot((a) => a is Window)) requires dynamic invoke (test/codegen/js_test.dart, line 592, col 9)
info: [DynamicInvoke] isNot((a) => a is Window) requires dynamic invoke (test/codegen/js_test.dart, line 592, col 31)
info: [DynamicInvoke] expect(contentWindow, (a) => a is JsObject) requires dynamic invoke (test/codegen/js_test.dart, line 593, col 9)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/test/codegen/expect/opassign.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ info: [DynamicInvoke] ++f[index] requires dynamic invoke (test/codegen/opassign.
info: [DynamicInvoke] f[index]++ requires dynamic invoke (test/codegen/opassign.dart, line 22, col 16)
info: [DynamicInvoke] ++foo.x requires dynamic invoke (test/codegen/opassign.dart, line 25, col 3)
info: [DynamicInvoke] foo.x requires dynamic invoke (test/codegen/opassign.dart, line 25, col 5)
info: [DynamicInvoke] foo.x++ requires dynamic invoke (test/codegen/opassign.dart, line 26, col 16)
info: [DynamicInvoke] foo.x requires dynamic invoke (test/codegen/opassign.dart, line 26, col 16)
info: [DynamicInvoke] foo.x++ requires dynamic invoke (test/codegen/opassign.dart, line 26, col 16)
info: [DynamicInvoke] f[index] += f[index] requires dynamic invoke (test/codegen/opassign.dart, line 29, col 3)
Loading

0 comments on commit 9c832d6

Please sign in to comment.