diff --git a/tests/compiler/dart2js/dart2js.status b/tests/compiler/dart2js/dart2js.status index c5b740087f2..eef4d216665 100644 --- a/tests/compiler/dart2js/dart2js.status +++ b/tests/compiler/dart2js/dart2js.status @@ -39,7 +39,6 @@ deferred/load_mapping_test: Slow, Pass end_to_end/dart2js_batch_test: Slow, Pass end_to_end/exit_code_test: Slow, Pass end_to_end/in_user_code_test: Slow, Pass -end_to_end/show_package_warnings_test: Slow, Pass [ $checked ] codegen/value_range_kernel_test: Slow, Pass diff --git a/tests/compiler/dart2js/end_to_end/show_package_warnings_test.dart b/tests/compiler/dart2js/end_to_end/show_package_warnings_test.dart deleted file mode 100644 index dd7c73bdb01..00000000000 --- a/tests/compiler/dart2js/end_to_end/show_package_warnings_test.dart +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// @dart = 2.7 - -// Test that the '--show-package-warnings' option works as intended. - -import 'dart:async'; -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; -import 'package:compiler/src/commandline_options.dart'; -import '../helpers/memory_compiler.dart'; - -/// Error code that creates 1 warning, 1 hint, and 1 info. -const ERROR_CODE = """ -m(Object o) { - if (o is String) { - o = o.length; - } -}"""; - -const SOURCE = const { - 'main.dart': """ -import 'package:pkg_error1/pkg_error1.dart' as pkg1; -import 'package:pkg_error2/pkg_error2.dart' as pkg2; -import 'package:pkg_noerror/pkg_noerror.dart' as pkg3; -import 'error.dart' as error; - -main() { - pkg1.m(null); - pkg2.m(null); - pkg3.m(null); - error.m(null); -} -""", - 'error.dart': ERROR_CODE, - 'pkg/pkg_error1/pkg_error1.dart': """ -import 'package:pkg_error2/pkg_error2.dart' as pkg2; -import 'package:pkg_noerror/pkg_noerror.dart' as pkg3; -$ERROR_CODE - -main() { - m(null); - pkg2.m(null); - pkg3.m(null); -} -""", - 'pkg/pkg_error2/pkg_error2.dart': """ -import 'package:pkg_error1/pkg_error1.dart' as pkg1; -import 'package:pkg_noerror/pkg_noerror.dart' as pkg3; -$ERROR_CODE - -main() { - pkg1.m(null); - m(null); - pkg3.m(null); -} -""", - 'pkg/pkg_noerror/pkg_noerror.dart': """ -import 'package:pkg_error1/pkg_error1.dart' as pkg1; -import 'package:pkg_error2/pkg_error2.dart' as pkg2; -m(o) {} - -main() { - pkg1.m(null); - m(null); - pkg2.m(null); -} -""", - '.packages': """ -pkg_error1:pkg/pkg_error1/ -pkg_error2:pkg/pkg_error2/ -pkg_noerror:pkg/pkg_noerror/ -""" -}; - -Future test(Uri entryPoint, - {List showPackageWarnings: null, - int warnings: 0, - int hints: 0, - int infos: 0}) async { - List options = []; - if (showPackageWarnings != null) { - if (showPackageWarnings.isEmpty) { - options.add(Flags.showPackageWarnings); - } else { - options - .add('${Flags.showPackageWarnings}=${showPackageWarnings.join(',')}'); - } - } - var collector = new DiagnosticCollector(); - print('=================================================================='); - print('test: $entryPoint showPackageWarnings=$showPackageWarnings'); - print('------------------------------------------------------------------'); - await runCompiler( - entryPoint: entryPoint, - memorySourceFiles: SOURCE, - options: options, - packageConfig: Uri.parse('memory:.packages'), - diagnosticHandler: collector); - Expect.equals( - 0, collector.errors.length, 'Unexpected errors: ${collector.errors}'); - Expect.equals(warnings, collector.warnings.length, - 'Unexpected warnings: ${collector.warnings}'); - checkUriSchemes(collector.warnings); - Expect.equals( - hints, collector.hints.length, 'Unexpected hints: ${collector.hints}'); - checkUriSchemes(collector.hints); - Expect.equals( - infos, collector.infos.length, 'Unexpected infos: ${collector.infos}'); - checkUriSchemes(collector.infos); -} - -void checkUriSchemes(Iterable messages) { - for (CollectedMessage message in messages) { - if (message.uri != null) { - Expect.notEquals('package', message.uri.scheme, - "Unexpected package uri `${message.uri}` in message: $message"); - } - } -} - -void main() { - asyncTest(() async { - await test(Uri.parse('memory:main.dart'), - showPackageWarnings: [], - // From error.dart, package:pkg_error1 and package:pkg_error2: - warnings: 3, - hints: 3, - infos: 3); - await test(Uri.parse('memory:main.dart'), - showPackageWarnings: ['pkg_error1'], - // From error.dart and package:pkg_error1: - warnings: 2, - hints: 2 + 1 /* from summary */, - infos: 2); - await test(Uri.parse('memory:main.dart'), - showPackageWarnings: ['pkg_error1', 'pkg_error2'], - // From error.dart, package:pkg_error1 and package:pkg_error2: - warnings: 3, - hints: 3, - infos: 3); - await test(Uri.parse('memory:main.dart'), - showPackageWarnings: [], - // From error.dart, package:pkg_error1 and package:pkg_error2: - warnings: 3, - hints: 3, - infos: 3); - await test(Uri.parse('memory:main.dart'), - showPackageWarnings: null, - // From error.dart only: - warnings: 1, - hints: 1 + 2 /* from summary */, - infos: 1); - await test(Uri.parse('package:pkg_error1/pkg_error1.dart'), - showPackageWarnings: [], - // From package:pkg_error1 and package:pkg_error2: - warnings: 2, - hints: 2, - infos: 2); - await test(Uri.parse('package:pkg_error1/pkg_error1.dart'), - showPackageWarnings: null, - // From package:pkg_error1/pkg_error1.dart only: - warnings: 1, - hints: 1 + 1 /* from summary */, - infos: 1); - await test(Uri.parse('package:pkg_noerror/pkg_noerror.dart'), - showPackageWarnings: [], - // From package:pkg_error1 and package:pkg_error2: - warnings: 2, - hints: 2, - infos: 2); - await test(Uri.parse('package:pkg_noerror/pkg_noerror.dart'), - showPackageWarnings: ['pkg_error1'], - // From package:pkg_error1: - warnings: 1, - hints: 1 + 1 /* from summary */, - infos: 1); - await test(Uri.parse('package:pkg_noerror/pkg_noerror.dart'), - showPackageWarnings: null, hints: 2 /* from summary */); - }); -} diff --git a/tests/compiler/dart2js/sourcemaps/d2js_validity_test.dart b/tests/compiler/dart2js/sourcemaps/d2js_validity_test.dart deleted file mode 100644 index 7fea711e3c8..00000000000 --- a/tests/compiler/dart2js/sourcemaps/d2js_validity_test.dart +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// @dart = 2.7 - -import 'dart:async'; -import 'dart:io'; - -import 'package:async_helper/async_helper.dart'; -import 'package:compiler/src/dart2js.dart' as entry; -import 'package:compiler/src/apiimpl.dart'; -import 'package:compiler/compiler_new.dart'; - -import 'helpers/source_map_validator_helper.dart'; - -import '../helpers/memory_compiler.dart'; - -void main() { - String mainFile = - 'tests/compiler/dart2js/sourcemaps/test_files/validator_test_file.dart'; - asyncTest(() => createTempDir().then((Directory tmpDir) { - print('Compiling $mainFile'); - Future result = entry.internalMain([ - mainFile, - '-o${tmpDir.path}/out.js', - '--platform-binaries=$sdkPlatformBinariesPath', - '--libraries-spec=$sdkLibrariesSpecificationPath', - ]); - return result.then((CompilationResult result) { - CompilerImpl compiler = result.compiler; - Uri uri = new Uri.file('${tmpDir.path}/out.js', - windows: Platform.isWindows); - validateSourceMap(uri, - mainUri: Uri.base.resolve(mainFile), - mainPosition: const Position(13, 1), - compiler: compiler); - - print("Deleting '${tmpDir.path}'."); - tmpDir.deleteSync(recursive: true); - }); - })); -} diff --git a/tests/compiler/dart2js/sourcemaps/deferred_d2js_validity_test.dart b/tests/compiler/dart2js/sourcemaps/deferred_d2js_validity_test.dart deleted file mode 100644 index 4b9229ef421..00000000000 --- a/tests/compiler/dart2js/sourcemaps/deferred_d2js_validity_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// @dart = 2.7 - -import 'dart:io'; - -import 'package:async_helper/async_helper.dart'; -import 'package:compiler/src/dart2js.dart' as entry; -import 'package:compiler/src/apiimpl.dart'; -import 'package:compiler/compiler_new.dart'; - -import 'helpers/source_map_validator_helper.dart'; - -import '../helpers/memory_compiler.dart'; - -void main() { - asyncTest(() => createTempDir().then((Directory tmpDir) { - String file = 'tests/compiler/dart2js/sourcemaps/test_files/' - 'deferred_validator_test_file.dart'; - print("Compiling $file"); - var result = entry.internalMain([ - file, - '-o${tmpDir.path}/out.js', - '--platform-binaries=$sdkPlatformBinariesPath', - '--libraries-spec=$sdkLibrariesSpecificationPath', - ]); - return result.then((CompilationResult result) { - CompilerImpl compiler = result.compiler; - Uri mainUri = new Uri.file('${tmpDir.path}/out.js', - windows: Platform.isWindows); - Uri deferredUri = new Uri.file('${tmpDir.path}/out.js_1.part.js', - windows: Platform.isWindows); - validateSourceMap(mainUri, - mainUri: Uri.base.resolve(file), - mainPosition: const Position(7, 1), - compiler: compiler); - validateSourceMap(deferredUri, compiler: compiler); - - print("Deleting '${tmpDir.path}'."); - tmpDir.deleteSync(recursive: true); - }); - })); -} diff --git a/tests/compiler/dart2js/sourcemaps/helpers/source_map_validator_helper.dart b/tests/compiler/dart2js/sourcemaps/helpers/source_map_validator_helper.dart deleted file mode 100644 index 158276b4625..00000000000 --- a/tests/compiler/dart2js/sourcemaps/helpers/source_map_validator_helper.dart +++ /dev/null @@ -1,325 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// @dart = 2.7 - -import 'dart:io'; -import 'dart:convert'; -import 'dart:async'; - -import 'package:path/path.dart' as path; -import 'package:expect/expect.dart'; -import 'package:source_maps/source_maps.dart'; -import 'package:compiler/src/apiimpl.dart'; - -validateSourceMap(Uri targetUri, - {Uri mainUri, Position mainPosition, CompilerImpl compiler}) { - Uri mapUri = getMapUri(targetUri); - List targetLines = new File.fromUri(targetUri).readAsLinesSync(); - SingleMapping sourceMap = getSourceMap(mapUri); - checkFileReferences(targetUri, mapUri, sourceMap); - checkIndexReferences(targetLines, mapUri, sourceMap); - checkRedundancy(sourceMap); - if (compiler != null) { - checkNames(targetUri, mapUri, sourceMap, compiler); - } - if (mainUri != null && mainPosition != null) { - checkMainPosition(targetUri, targetLines, sourceMap, mainUri, mainPosition); - } -} - -checkIndexReferences( - List targetLines, Uri mapUri, SingleMapping sourceMap) { - int urlsLength = sourceMap.urls.length; - List> sources = new List(urlsLength); - print('Reading sources'); - for (int i = 0; i < urlsLength; i++) { - sources[i] = new File.fromUri(mapUri.resolve(sourceMap.urls[i])) - .readAsStringSync() - .split('\n'); - } - - sourceMap.lines.forEach((TargetLineEntry line) { - Expect.isTrue(line.line >= 0); - Expect.isTrue(line.line < targetLines.length); - for (TargetEntry entry in line.entries) { - int urlIndex = entry.sourceUrlId; - - // TODO(zarah): Entry columns sometimes point one or more characters too - // far. Incomment this check when this is fixed. - // - // Expect.isTrue(entry.column < target[line.line].length); - Expect.isTrue(entry.column >= 0); - Expect.isTrue( - urlIndex == null || (urlIndex >= 0 && urlIndex < urlsLength)); - Expect.isTrue(entry.sourceLine == null || - (entry.sourceLine >= 0 && - entry.sourceLine < sources[urlIndex].length)); - Expect.isTrue(entry.sourceColumn == null || - (entry.sourceColumn >= 0 && - entry.sourceColumn < sources[urlIndex][entry.sourceLine].length)); - Expect.isTrue(entry.sourceNameId == null || - (entry.sourceNameId >= 0 && - entry.sourceNameId < sourceMap.names.length)); - } - }); -} - -checkFileReferences(Uri targetUri, Uri mapUri, SingleMapping sourceMap) { - Expect.equals(targetUri, mapUri.resolve(sourceMap.targetUrl)); - print('Checking sources'); - sourceMap.urls.forEach((String url) { - Expect.isTrue(new File.fromUri(mapUri.resolve(url)).existsSync()); - }); -} - -checkRedundancy(SingleMapping sourceMap) { - sourceMap.lines.forEach((TargetLineEntry line) { - TargetEntry previous = null; - for (TargetEntry next in line.entries) { - if (previous != null) { - Expect.isFalse( - sameSourcePoint(previous, next), - '$previous and $next are consecutive entries on line $line in the ' - 'source map but point to same source locations'); - } - previous = next; - } - }); -} - -checkNames( - Uri targetUri, Uri mapUri, SingleMapping sourceMap, CompilerImpl compiler) { - // TODO(johnniwinther): Port this to work on kernel based elements. - /* - Map compilationUnitMap = {}; - - void mapCompilationUnits(LibraryElement library) { - library.compilationUnits.forEach((CompilationUnitElement compilationUnit) { - compilationUnitMap[compilationUnit.script.readableUri] = compilationUnit; - }); - } - - compiler.libraryLoader.libraries.forEach((_library) { - LibraryElement library = _library; - mapCompilationUnits(library); - if (library.patch != null) { - mapCompilationUnits(library.patch); - } - }); - - sourceMap.lines.forEach((TargetLineEntry line) { - for (TargetEntry entry in line.entries) { - if (entry.sourceNameId != null) { - Uri uri = mapUri.resolve(sourceMap.urls[entry.sourceUrlId]); - Position sourcePosition = - new Position(entry.sourceLine, entry.sourceColumn); - String name = sourceMap.names[entry.sourceNameId]; - - CompilationUnitElement compilationUnit = compilationUnitMap[uri]; - Expect.isNotNull( - compilationUnit, "No compilation unit found for $uri."); - - SourceFile sourceFile = compilationUnit.script.file; - - Position positionFromOffset(int offset) { - Location location = sourceFile.getLocation(offset); - int line = location.line - 1; - int column = location.column - 1; - return new Position(line, column); - } - - Interval intervalFromElement(AstElement element) { - if (!element.hasNode) return null; - - var begin = 0; - int end = 0; - return new Interval( - positionFromOffset(begin), positionFromOffset(end)); - } - - AstElement findInnermost(AstElement element) { - bool isInsideElement(FunctionElement closure) { - Element enclosing = closure; - while (enclosing != null) { - if (enclosing == element) return true; - enclosing = enclosing.enclosingElement; - } - return false; - } - - if (element is MemberElement) { - MemberElement member = element; - member.nestedClosures.forEach((dynamic closure) { - var localFunction = closure.expression; - Interval interval = intervalFromElement(localFunction); - if (interval != null && - interval.contains(sourcePosition) && - isInsideElement(localFunction)) { - element = localFunction; - } - }); - } - return element; - } - - void match(Element _element) { - AstElement element = _element; - Interval interval = intervalFromElement(element); - if (interval != null && interval.contains(sourcePosition)) { - AstElement innerElement = findInnermost(element); - String expectedName = computeElementNameForSourceMaps(innerElement); - int stubIndex = name.indexOf('[function-entry'); - if (stubIndex != -1) { - Expect.isTrue(innerElement is FunctionElement, - "Unexpected element $innerElement for stub '$name'."); - name = name.substring(0, stubIndex); - } - if (name != expectedName) { - // For the code - // (){}(); - // ^ - // the indicated position is within the scope of the local - // function but it is also the position for the invocation of it. - // Allow name to be either from the local or from its calling - // context. - if (innerElement.isLocal && innerElement.isFunction) { - var enclosingElement = innerElement.enclosingElement; - String expectedName2 = - computeElementNameForSourceMaps(enclosingElement); - Expect.isTrue( - name == expectedName2, - "Unexpected name '${name}', " - "expected '${expectedName}' for $innerElement " - "or '${expectedName2}' for $enclosingElement."); - } else { - Expect.equals( - expectedName, - name, - "Unexpected name '${name}', " - "expected '${expectedName}' or for $innerElement."); - } - } - } - } - - compilationUnit.forEachLocalMember((Element element) { - if (element.isClass) { - ClassElement classElement = element; - classElement.forEachLocalMember(match); - } else { - match(element); - } - }); - } - } - });*/ -} - -RegExp mainSignaturePrefix = new RegExp(r'main: \[?function\('); - -// Check that the line pointing to by [mainPosition] in [mainUri] contains -// the main function signature. -checkMainPosition(Uri targetUri, List targetLines, - SingleMapping sourceMap, Uri mainUri, Position mainPosition) { - bool mainPositionFound = false; - sourceMap.lines.forEach((TargetLineEntry lineEntry) { - lineEntry.entries.forEach((TargetEntry entry) { - if (entry.sourceLine == null || entry.sourceUrlId == null) return; - Uri sourceUri = targetUri.resolve(sourceMap.urls[entry.sourceUrlId]); - if (sourceUri != mainUri) return; - if (entry.sourceLine + 1 == mainPosition.line && - entry.sourceColumn + 1 == mainPosition.column) { - Expect.isNotNull(entry.sourceNameId, "Main position has no name."); - String name = sourceMap.names[entry.sourceNameId]; - Expect.equals( - 'main', name, "Main position name is not '$name', not 'main'."); - String line = targetLines[lineEntry.line]; - Expect.isTrue( - line.contains(mainSignaturePrefix), - "Line mapped to main position " - "([${lineEntry.line + 1},${entry.column + 1}]) " - "expected to contain '${mainSignaturePrefix.pattern}':\n$line\n"); - mainPositionFound = true; - } - }); - }); - Expect.isTrue( - mainPositionFound, 'No main position $mainPosition found in $mainUri'); -} - -sameSourcePoint(TargetEntry entry, TargetEntry otherEntry) { - return (entry.sourceUrlId == otherEntry.sourceUrlId) && - (entry.sourceLine == otherEntry.sourceLine) && - (entry.sourceColumn == otherEntry.sourceColumn) && - (entry.sourceNameId == otherEntry.sourceNameId); -} - -Uri getMapUri(Uri targetUri) { - print('Accessing $targetUri'); - File targetFile = new File.fromUri(targetUri); - Expect.isTrue(targetFile.existsSync(), "File '$targetUri' doesn't exist."); - List target = targetFile.readAsStringSync().split('\n'); - String mapReference = target[target.length - 2]; // #sourceMappingURL= - Expect.isTrue(mapReference.startsWith('//# sourceMappingURL=')); - String mapName = mapReference.substring(mapReference.indexOf('=') + 1); - return targetUri.resolve(mapName); -} - -SingleMapping getSourceMap(Uri mapUri) { - print('Accessing $mapUri'); - File mapFile = new File.fromUri(mapUri); - Expect.isTrue(mapFile.existsSync()); - return new SingleMapping.fromJson(json.decode(mapFile.readAsStringSync())); -} - -copyDirectory(Directory sourceDir, Directory destinationDir) { - sourceDir.listSync().forEach((FileSystemEntity element) { - String newPath = - path.join(destinationDir.path, path.basename(element.path)); - if (element is File) { - element.copySync(newPath); - } else if (element is Directory) { - Directory newDestinationDir = new Directory(newPath); - newDestinationDir.createSync(); - copyDirectory(element, newDestinationDir); - } - }); -} - -Future createTempDir() { - return Directory.systemTemp - .createTemp('sourceMap_test-') - .then((Directory dir) { - return dir; - }); -} - -class Position { - final int line; - final int column; - - const Position(this.line, this.column); - - bool operator <=(Position other) { - return line < other.line || line == other.line && column <= other.column; - } - - @override - String toString() => '[${line + 1},${column + 1}]'; -} - -class Interval { - final Position begin; - final Position end; - - Interval(this.begin, this.end); - - bool contains(Position other) { - return begin <= other && other <= end; - } - - @override - String toString() => '$begin-$end'; -} diff --git a/tests/legacy_status_dart2js.csv b/tests/legacy_status_dart2js.csv index 8d779d650b2..416cb2042e7 100644 --- a/tests/legacy_status_dart2js.csv +++ b/tests/legacy_status_dart2js.csv @@ -4,12 +4,9 @@ Condition,Test,Expectations,Comment,Issue,Issue state ,codegen/logical_expression_test,Fail,Issue 17027,https://dartbug.com/17027,open ,codegen/side_effect_tdiv_regression_test,Fail,Issue 33050,https://dartbug.com/33050,open ,codegen/simple_function_subtype_test,Fail,simple_function_subtype_test is temporarily(?) disabled due to new method for building function type tests.,, -,end_to_end/show_package_warnings_test,RuntimeError,missing errors from the FE,, ,inference/simple_inferrer_const_closure2_test,Fail,Issue 16507,https://dartbug.com/16507,open ,inference/simple_inferrer_const_closure_test,Fail,Issue 16507,https://dartbug.com/16507,open ,inference/simple_inferrer_global_field_closure_test,Fail,Issue 16507,https://dartbug.com/16507,open -,sourcemaps/d2js_validity_test,RuntimeError,Issue 33072,https://dartbug.com/33072,open -,sourcemaps/deferred_d2js_validity_test,RuntimeError,Issue 33072,https://dartbug.com/33072,open $compiler == dart2js,bounds_check4a_test,RuntimeError,Issue 32741,https://dartbug.com/32741,open $compiler == dart2js,bounds_check4b_test,RuntimeError,Issue 32741,https://dartbug.com/32741,open $compiler == dart2js,generic_class_is_test,Fail,Issue 32004,https://dartbug.com/32004,open