dart2js: fix tests after moving to .packages in the SDK repo

R=sigmund@google.com

Review URL: https://codereview.chromium.org/2346053002 .
This commit is contained in:
Harry Terkelsen 2016-09-16 12:07:31 -07:00
parent b961fc01ad
commit 67ab213718
6 changed files with 40 additions and 53 deletions

View file

@ -14,6 +14,7 @@ Future<CompilerImpl> reuseCompiler(
CompilerImpl cachedCompiler,
Uri libraryRoot,
Uri packageRoot,
Uri packageConfig,
bool packagesAreImmutable: false,
Map<String, dynamic> environment,
Future<bool> reuseLibrary(LibraryElement library)}) {
@ -60,6 +61,7 @@ Future<CompilerImpl> reuseCompiler(
new CompilerOptions.parse(
libraryRoot: libraryRoot,
packageRoot: packageRoot,
packageConfig: packageConfig,
options: options,
environment: environment));
JavaScriptBackend backend = compiler.backend;

View file

@ -54,6 +54,7 @@ const List<String> INCREMENTAL_OPTIONS = const <String>[
class IncrementalCompiler {
final Uri libraryRoot;
final Uri packageRoot;
final Uri packageConfig;
final CompilerInput inputProvider;
final CompilerDiagnostics diagnosticHandler;
final List<String> options;
@ -67,6 +68,7 @@ class IncrementalCompiler {
IncrementalCompiler({
this.libraryRoot,
this.packageRoot,
this.packageConfig,
this.inputProvider,
this.diagnosticHandler,
this.options,
@ -107,6 +109,7 @@ class IncrementalCompiler {
cachedCompiler: _compiler,
libraryRoot: libraryRoot,
packageRoot: packageRoot,
packageConfig: packageConfig,
inputProvider: inputProvider,
diagnosticHandler: diagnosticHandler,
options: options,

View file

@ -26,7 +26,7 @@ import 'memory_compiler.dart';
*/
// TODO(johnniwinther): Support canonical URIs as keys.
const Map<String, List/*<String|MessageKind>*/> WHITE_LIST = const {
"/test/src/util/": const [
"/test/lib/src/util/": const [
"Library 'package:async/async.dart' doesn't export a "
"'ForkableStream' declaration.",
],

View file

@ -74,7 +74,7 @@ testMissingImports() async {
collector.checkMessages([
const Expected.error(MessageKind.READ_SCRIPT_ERROR),
const Expected.error(MessageKind.LIBRARY_NOT_FOUND),
const Expected.error(MessageKind.READ_SCRIPT_ERROR),
const Expected.error(MessageKind.LIBRARY_NOT_FOUND),
const Expected.error(MessageKind.READ_SCRIPT_ERROR),
const Expected.warning(MessageKind.NOT_ASSIGNABLE)]);
}

View file

@ -5,68 +5,56 @@
// Test a sequence of modifications to hello-world which used to cause problems
// on Try Dart.
import 'dart:io' show
Platform;
import 'dart:io' show Platform;
import 'dart:async' show
Future;
import 'dart:async' show Future;
import 'package:dart2js_incremental/dart2js_incremental.dart' show
IncrementalCompiler;
import 'package:dart2js_incremental/dart2js_incremental.dart'
show IncrementalCompiler;
import 'package:compiler/compiler.dart' show
Diagnostic;
import 'package:compiler/compiler.dart' show Diagnostic;
import 'package:compiler/src/null_compiler_output.dart' show
NullCompilerOutput;
import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput;
import 'package:compiler/src/old_to_new_api.dart' show
LegacyCompilerDiagnostics;
import 'package:compiler/src/old_to_new_api.dart'
show LegacyCompilerDiagnostics;
import 'package:async_helper/async_helper.dart' show
asyncTest;
import 'package:async_helper/async_helper.dart' show asyncTest;
import 'package:expect/expect.dart' show
Expect;
import 'package:expect/expect.dart' show Expect;
import '../memory_source_file_helper.dart' show
MemorySourceFileProvider;
import '../memory_source_file_helper.dart' show MemorySourceFileProvider;
var tests = {
'/test1.dart':
'''
'/test1.dart': '''
var greeting = "Hello, World!";
void main() {
print(greeting);
}
''',
'/test2.dart':
'''
'/test2.dart': '''
va greeting = "Hello, World!";
void main() {
print(greeting);
}
''',
'/test3.dart':
'''
'/test3.dart': '''
greeting = "Hello, World!";
void main() {
print(greeting);
}
''',
'/test4.dart':
'''
'/test4.dart': '''
in greeting = "Hello, World!";
void main() {
print(greeting);
}
''',
'/test5.dart':
'''
'/test5.dart': '''
int greeting = "Hello, World!";
void main() {
@ -85,39 +73,31 @@ var testResults = {
main() {
Uri libraryRoot = Uri.base.resolve('sdk/');
Uri packageRoot = Uri.base.resolve(Platform.packageRoot);
MemorySourceFileProvider provider =
new MemorySourceFileProvider(tests);
asyncTest(() => runTests(libraryRoot, packageRoot, provider));
Uri packageConfig = Uri.base.resolve('.packages');
MemorySourceFileProvider provider = new MemorySourceFileProvider(tests);
asyncTest(() => runTests(libraryRoot, packageConfig, provider));
}
Future runTests(
Uri libraryRoot,
Uri packageRoot,
MemorySourceFileProvider provider) {
Uri libraryRoot, Uri packageConfig, MemorySourceFileProvider provider) {
IncrementalCompiler compiler = new IncrementalCompiler(
diagnosticHandler: new LegacyCompilerDiagnostics(handler),
inputProvider: provider,
outputProvider: const NullCompilerOutput(),
options: ['--analyze-main'],
libraryRoot: libraryRoot,
packageRoot: packageRoot);
packageConfig: packageConfig);
return Future.forEach(tests.keys, (String testName) {
Uri testUri = Uri.parse('memory:$testName');
return compiler.compile(testUri).then((bool success) {
Expect.equals(
testResults[testName], success,
Expect.equals(testResults[testName], success,
'Compilation unexpectedly ${success ? "succeed" : "failed"}.');
});
});
}
void handler(Uri uri,
int begin,
int end,
String message,
Diagnostic kind) {
void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
if (kind != Diagnostic.VERBOSE_INFO) {
print('$uri:$begin:$end:$message:$kind');
}

View file

@ -32,15 +32,17 @@ Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart");
Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart");
class CustomCompiler extends CompilerImpl {
CustomCompiler(provider, handler, libraryRoot, packageRoot)
: super(provider, const NullCompilerOutput(), handler,
CustomCompiler(provider, handler, libraryRoot, packageConfig)
: super(
provider,
const NullCompilerOutput(),
handler,
new CompilerOptions(
libraryRoot: libraryRoot,
packageRoot: packageRoot));
libraryRoot: libraryRoot, packageConfig: packageConfig));
}
main() async {
Uri packageRoot = Uri.base.resolve(Platform.packageRoot);
Uri packageConfig = Uri.base.resolve('.packages');
var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
var handler = new FormattingDiagnosticHandler(provider);
@ -55,8 +57,8 @@ main() async {
return provider.readStringFromUri(uri);
}
String expectedMessage = MessageTemplate.TEMPLATES[
MessageKind.LIBRARY_NOT_FOUND]
String expectedMessage = MessageTemplate
.TEMPLATES[MessageKind.LIBRARY_NOT_FOUND]
.message({'resolvedUri': 'dart:mock2.dart'}).computeMessage();
int actualMessageCount = 0;
@ -77,7 +79,7 @@ main() async {
new LegacyCompilerInput(wrappedProvider),
new LegacyCompilerDiagnostics(wrappedHandler),
sdkRoot,
packageRoot);
packageConfig);
asyncStart();
await compiler.setupSdk();