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

Unified Diff: tests/compiler/dart2js/exit_code_test.dart

Issue 2123073003: remove dependency on compiler from resolution (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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: tests/compiler/dart2js/exit_code_test.dart
diff --git a/tests/compiler/dart2js/exit_code_test.dart b/tests/compiler/dart2js/exit_code_test.dart
index ff419c7fce67db29d8626b60a6c6ec9becb404c3..517a65625c6acb947c5121e1ea0966e564e2fe59 100644
--- a/tests/compiler/dart2js/exit_code_test.dart
+++ b/tests/compiler/dart2js/exit_code_test.dart
@@ -4,7 +4,6 @@
// Test the exit code of dart2js in case of exceptions, errors, warnings, etc.
-
import 'dart:async';
import 'dart:io' show Platform;
@@ -37,13 +36,14 @@ class TestCompiler extends apiimpl.CompilerImpl {
final Function onTest;
TestDiagnosticReporter reporter;
- TestCompiler(api.CompilerInput inputProvider,
- api.CompilerOutput outputProvider,
- api.CompilerDiagnostics handler,
- CompilerOptions options,
- String this.testMarker,
- String this.testType,
- Function this.onTest)
+ TestCompiler(
+ api.CompilerInput inputProvider,
+ api.CompilerOutput outputProvider,
+ api.CompilerDiagnostics handler,
+ CompilerOptions options,
+ String this.testMarker,
+ String this.testType,
+ Function this.onTest)
: reporter = new TestDiagnosticReporter(),
super(inputProvider, outputProvider, handler, options) {
reporter.compiler = this;
@@ -87,37 +87,35 @@ class TestCompiler extends apiimpl.CompilerImpl {
test(String marker) {
if (marker == testMarker) {
switch (testType) {
- case 'assert':
- onTest(testMarker, testType);
- assert(false);
- break;
- case 'invariant':
- onTest(testMarker, testType);
- invariant(NO_LOCATION_SPANNABLE, false, message: marker);
- break;
- case 'warning':
- onTest(testMarker, testType);
- reporter.reportWarningMessage(
- NO_LOCATION_SPANNABLE,
- MessageKind.GENERIC, {'text': marker});
- break;
- case 'error':
- onTest(testMarker, testType);
- reporter.reportErrorMessage(
- NO_LOCATION_SPANNABLE,
- MessageKind.GENERIC, {'text': marker});
- break;
- case 'internalError':
- onTest(testMarker, testType);
- reporter.internalError(NO_LOCATION_SPANNABLE, marker);
- break;
- case 'NoSuchMethodError':
- onTest(testMarker, testType);
- null.foo;
- break;
- case '':
- onTest(testMarker, testType);
- break;
+ case 'assert':
+ onTest(testMarker, testType);
+ assert(false);
+ break;
+ case 'invariant':
+ onTest(testMarker, testType);
+ invariant(NO_LOCATION_SPANNABLE, false, message: marker);
+ break;
+ case 'warning':
+ onTest(testMarker, testType);
+ reporter.reportWarningMessage(
+ NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker});
+ break;
+ case 'error':
+ onTest(testMarker, testType);
+ reporter.reportErrorMessage(
+ NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker});
+ break;
+ case 'internalError':
+ onTest(testMarker, testType);
+ reporter.internalError(NO_LOCATION_SPANNABLE, marker);
+ break;
+ case 'NoSuchMethodError':
+ onTest(testMarker, testType);
+ null.foo;
+ break;
+ case '':
+ onTest(testMarker, testType);
+ break;
}
}
}
@@ -150,10 +148,13 @@ class TestScanner extends ScannerTask {
}
class TestResolver extends ResolverTask {
+ final TestCompiler _compiler;
TestResolver(TestCompiler compiler, ConstantCompiler constantCompiler)
- : super(compiler, constantCompiler);
+ : this._compiler = compiler,
+ super(compiler.resolution, constantCompiler, compiler.world,
+ compiler.measurer);
- TestCompiler get compiler => super.compiler;
+ TestCompiler get compiler => this._compiler;
void computeClassMembers(ClassElement element) {
compiler.test('ResolverTask.computeClassMembers');
@@ -181,14 +182,8 @@ Future testExitCode(
compilerOutput = const NullCompilerOutput();
// Use this to silence the test when debugging:
// handler = (uri, begin, end, message, kind) {};
- Compiler compiler = new TestCompiler(
- compilerInput,
- compilerOutput,
- compilerDiagnostics,
- compilerOptions,
- marker,
- type,
- onTest);
+ Compiler compiler = new TestCompiler(compilerInput, compilerOutput,
+ compilerDiagnostics, compilerOptions, marker, type, onTest);
return compiler.run(compilerOptions.entryPoint).then((bool success) {
return new api.CompilationResult(compiler, isSuccess: success);
});
@@ -200,8 +195,10 @@ Future testExitCode(
Expect.isTrue(testOccurred, 'testExitCode($marker, $type) did not occur');
if (foundExitCode == null) foundExitCode = 0;
print('testExitCode($marker, $type) '
- 'exitCode=$foundExitCode expected=$expectedExitCode');
- Expect.equals(expectedExitCode, foundExitCode,
+ 'exitCode=$foundExitCode expected=$expectedExitCode');
+ Expect.equals(
+ expectedExitCode,
+ foundExitCode,
'testExitCode($marker, $type) '
'exitCode=$foundExitCode expected=${expectedExitCode}');
checkedResults++;
@@ -211,14 +208,15 @@ Future testExitCode(
if (foundExitCode == null) {
foundExitCode = exitCode;
}
- };
+ }
+ ;
entry.exitFunc = exit;
entry.compileFunc = compile;
List<String> args = new List<String>.from(options)
- ..add("--library-root=${Platform.script.resolve('../../../sdk/')}")
- ..add("tests/compiler/dart2js/data/exit_code_helper.dart");
+ ..add("--library-root=${Platform.script.resolve('../../../sdk/')}")
+ ..add("tests/compiler/dart2js/data/exit_code_helper.dart");
Future result = entry.internalMain(args);
return result.catchError((e, s) {
// Capture crashes.
@@ -227,7 +225,7 @@ Future testExitCode(
}
Future testExitCodes(
- String marker, Map<String,int> expectedExitCodes, List<String> options) {
+ String marker, Map<String, int> expectedExitCodes, List<String> options) {
return Future.forEach(expectedExitCodes.keys, (String type) {
return testExitCode(marker, type, expectedExitCodes[type], options);
});
@@ -280,8 +278,8 @@ void main() {
totalExpectedErrors += expected.length;
await testExitCodes(marker, expected, []);
- expected = _expectedExitCode(
- beforeRun: tests[marker], fatalWarnings: true);
+ expected =
+ _expectedExitCode(beforeRun: tests[marker], fatalWarnings: true);
totalExpectedErrors += expected.length;
await testExitCodes(marker, expected, ['--fatal-warnings']);
}

Powered by Google App Engine
This is Rietveld 408576698