Chromium Code Reviews| Index: tests/compiler/dart2js/kernel/visitor_test.dart |
| diff --git a/tests/compiler/dart2js/kernel/visitor_test.dart b/tests/compiler/dart2js/kernel/visitor_test.dart |
| index 8e91c199d5b59e2a19cb48e670807f381d382aee..2dfa61f16cc47b65e5454965e2918447b3ecf494 100644 |
| --- a/tests/compiler/dart2js/kernel/visitor_test.dart |
| +++ b/tests/compiler/dart2js/kernel/visitor_test.dart |
| @@ -20,59 +20,77 @@ import 'package:test/test.dart'; |
| import '../memory_compiler.dart'; |
| -const String TESTCASE_DIR = 'pkg/kernel/testcases/'; |
| +const String TESTCASE_DIR = 'pkg/front_end/testcases/'; |
| -const List<String> SKIP_TESTS = const <String>[ |
| - /// The test expects an unpatched api. |
| - 'external', |
| +const List<String> TESTS = const <String>[ |
| + 'DeltaBlue', |
| + 'argument', |
| + 'arithmetic', |
| + 'async_function', |
| + 'bad_store', |
| + 'call', |
| + 'closure', |
| + 'covariant_generic', |
| + 'escape', |
| + 'fallthrough', |
| + 'micro', |
| + 'named_parameters', |
| + 'null_aware', |
| + 'optional', |
| + 'override', |
| + 'prefer_baseclass', |
| + 'redirecting_factory', |
| + 'static_setter', |
| + 'store_load', |
| + 'stringliteral', |
| + 'uninitialized_fields', |
| + 'unused_methods', |
| + 'void-methods', |
| ]; |
| -main(List<String> arguments) async { |
| - Directory directory = new Directory('${TESTCASE_DIR}/input'); |
| - for (FileSystemEntity file in directory.listSync()) { |
| - if (file is File && file.path.endsWith('.dart')) { |
| - String name = pathlib.basenameWithoutExtension(file.path); |
| - bool selected = arguments.contains(name); |
| - if (!selected) { |
| - if (arguments.isNotEmpty) continue; |
| - if (SKIP_TESTS.contains(name)) continue; |
| - } |
| - |
| - test(name, () async { |
| - var compiler = await newCompiler(); |
| - await compiler.run(file.absolute.uri); |
| - var loadedLibraries = |
| - await compiler.libraryLoader.loadLibrary(file.absolute.uri); |
| - compiler.processLoadedLibraries(loadedLibraries); |
| - var library = loadedLibraries.rootLibrary; |
| - JavaScriptBackend backend = compiler.backend; |
| - StringBuffer buffer = new StringBuffer(); |
| - Program program = backend.kernelTask.buildProgram(library); |
| - new MixinFullResolution().transform(program); |
| - new Printer(buffer) |
| - .writeLibraryFile(program.mainMethod.enclosingLibrary); |
| - String actual = buffer.toString(); |
| - String expected = |
| - new File('${TESTCASE_DIR}/spec-mode/$name.baseline.txt') |
| - .readAsStringSync(); |
| - if (selected) { |
| - String input = |
| - new File('${TESTCASE_DIR}/input/$name.dart').readAsStringSync(); |
| - print('============================================================'); |
| - print(name); |
| - print('--input-----------------------------------------------------'); |
| - print(input); |
| - print('--expected--------------------------------------------------'); |
| - print(expected); |
| - print('--actual----------------------------------------------------'); |
| - print(actual); |
| - } |
| - expect(actual, equals(expected)); |
| - }); |
| +main(List<String> arguments) { |
| + if (arguments.isEmpty) { |
| + for (String testName in TESTS) { |
| + runTest(testName, selected: false); |
| + } |
| + } else { |
| + for (String testName in arguments) { |
| + runTest(testName, selected: true); |
|
ahe
2017/04/19 09:41:03
This doesn't run the test. The test is executed la
Johnni Winther
2017/04/19 09:43:32
Renamed to [scheduleTest]
|
| } |
| } |
| } |
| +runTest(String name, {bool selected}) async { |
| + test(name, () async { |
| + Uri uri = Uri.base.resolve(TESTCASE_DIR).resolve('$name.dart'); |
| + var compiler = await newCompiler(); |
| + await compiler.run(uri); |
| + var loadedLibraries = await compiler.libraryLoader.loadLibrary(uri); |
| + compiler.processLoadedLibraries(loadedLibraries); |
| + var library = loadedLibraries.rootLibrary; |
| + JavaScriptBackend backend = compiler.backend; |
| + StringBuffer buffer = new StringBuffer(); |
| + Program program = backend.kernelTask.buildProgram(library); |
| + new MixinFullResolution().transform(program); |
| + new Printer(buffer).writeLibraryFile(program.mainMethod.enclosingLibrary); |
| + String actual = buffer.toString(); |
| + String expected = |
| + new File('${TESTCASE_DIR}/$name.dart.direct.expect').readAsStringSync(); |
| + if (selected) { |
| + String input = new File('${TESTCASE_DIR}/$name.dart').readAsStringSync(); |
| + print('============================================================'); |
| + print(name); |
| + print('--input-----------------------------------------------------'); |
| + print(input); |
| + print('--expected--------------------------------------------------'); |
| + print(expected); |
| + print('--actual----------------------------------------------------'); |
| + print(actual); |
| + } |
| + expect(actual, equals(expected)); |
| + }); |
| +} |
| + |
| Future<Compiler> newCompiler() async { |
| var compiler = compilerFor( |
| options: [Flags.analyzeOnly, Flags.analyzeAll, Flags.useKernel]); |