Ensure that all tests are run via test_all and add a test to ensure that it stays that way
Change-Id: I4a531179823a985f14307cbd444b31605d453d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97161
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/test/src/dart/constant/test_all.dart b/pkg/analyzer/test/src/dart/constant/test_all.dart
index 022da95..95c1b2e 100644
--- a/pkg/analyzer/test/src/dart/constant/test_all.dart
+++ b/pkg/analyzer/test/src/dart/constant/test_all.dart
@@ -5,13 +5,14 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'evaluation_test.dart' as evaluation;
+import 'potentially_constant_test.dart' as potentially_constant;
import 'utilities_test.dart' as utilities;
import 'value_test.dart' as value;
-/// Utility for manually running all tests.
main() {
defineReflectiveSuite(() {
evaluation.main();
+ potentially_constant.main();
utilities.main();
value.main();
}, name: 'constant');
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index 9701036..ccbc919 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -1,53 +1,57 @@
-// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2018, 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.
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'assignment_test.dart' as assignment_test;
-import 'class_test.dart' as class_test;
-import 'comment_test.dart' as comment_test;
-import 'constant_test.dart' as constant_test;
-import 'enum_test.dart' as enum_test;
-import 'flow_analysis_test.dart' as flow_analysis_test;
-import 'for_element_test.dart' as for_element_test;
-import 'for_in_test.dart' as for_in_test;
-import 'generic_type_alias_test.dart' as generic_type_alias_test;
-import 'import_prefix_test.dart' as import_prefix_test;
-import 'instance_creation_test.dart' as instance_creation_test;
+import 'assignment_test.dart' as assignment;
+import 'class_alias_test.dart' as class_alias;
+import 'class_test.dart' as class_resolution;
+import 'comment_test.dart' as comment;
+import 'constant_test.dart' as constant;
+import 'definite_assignment_test.dart' as definite_assignment;
+import 'enum_test.dart' as enum_resolution;
+import 'flow_analysis_test.dart' as flow_analysis;
+import 'for_element_test.dart' as for_element;
+import 'for_in_test.dart' as for_in;
+import 'generic_type_alias_test.dart' as generic_type_alias;
+import 'import_prefix_test.dart' as import_prefix;
+import 'instance_creation_test.dart' as instance_creation;
import 'instance_member_inference_class_test.dart'
- as instance_member_inference_class_test;
+ as instance_member_inference_class;
import 'instance_member_inference_mixin_test.dart'
- as instance_member_inference_mixin_test;
-import 'method_invocation_test.dart' as method_invocation_test;
-import 'mixin_test.dart' as mixin_test;
-import 'non_nullable_test.dart' as non_nullable_test;
-import 'optional_const_test.dart' as optional_const_test;
-import 'property_access_test.dart' as property_access_test;
-import 'top_type_inference_test.dart' as top_type_inference_test;
+ as instance_member_inference_mixin;
+import 'method_invocation_test.dart' as method_invocation;
+import 'mixin_test.dart' as mixin_resolution;
+import 'non_nullable_test.dart' as non_nullable;
+import 'optional_const_test.dart' as optional_const;
+import 'property_access_test.dart' as property_access;
+import 'top_type_inference_test.dart' as top_type_inference;
import 'type_inference/test_all.dart' as type_inference;
main() {
defineReflectiveSuite(() {
- assignment_test.main();
- class_test.main();
- comment_test.main();
- constant_test.main();
- enum_test.main();
- flow_analysis_test.main();
- for_element_test.main();
- for_in_test.main();
- generic_type_alias_test.main();
- import_prefix_test.main();
- instance_creation_test.main();
- instance_member_inference_class_test.main();
- instance_member_inference_mixin_test.main();
- method_invocation_test.main();
- mixin_test.main();
- non_nullable_test.main();
- optional_const_test.main();
- property_access_test.main();
- top_type_inference_test.main();
+ assignment.main();
+ class_alias.main();
+ class_resolution.main();
+ comment.main();
+ constant.main();
+ definite_assignment.main();
+ enum_resolution.main();
+ flow_analysis.main();
+ for_element.main();
+ for_in.main();
+ generic_type_alias.main();
+ import_prefix.main();
+ instance_creation.main();
+ instance_member_inference_class.main();
+ instance_member_inference_mixin.main();
+ method_invocation.main();
+ mixin_resolution.main();
+ non_nullable.main();
+ optional_const.main();
+ property_access.main();
+ top_type_inference.main();
type_inference.main();
}, name: 'resolution');
}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index b060c83..f1f3b5f 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -9,6 +9,8 @@
import 'can_be_null_after_null_aware_test.dart' as can_be_null_after_null_aware;
import 'const_constructor_param_type_mismatch_test.dart'
as const_constructor_param_type_mismatch;
+import 'const_constructor_with_mixin_with_field_test.dart'
+ as const_constructor_with_mixin_with_field;
import 'const_eval_throws_exception_test.dart' as const_eval_throws_exception;
import 'const_map_key_expression_type_implements_equals_test.dart'
as const_map_key_expression_type_implements_equals;
@@ -32,6 +34,8 @@
as invalid_override_different_default_values_positional;
import 'invalid_required_param_test.dart' as invalid_required_param;
import 'invalid_sealed_annotation_test.dart' as invalid_sealed_annotation;
+import 'invalid_visibility_annotation_test.dart'
+ as invalid_visibility_annotation;
import 'list_element_type_not_assignable_test.dart'
as list_element_type_not_assignable;
import 'map_entry_not_in_map_test.dart' as map_entry_not_in_map;
@@ -55,6 +59,8 @@
import 'top_level_instance_method_test.dart' as top_level_instance_method;
import 'type_check_is_not_null_test.dart' as type_check_is_not_null;
import 'type_check_is_null_test.dart' as type_check_is_null;
+import 'unchecked_use_of_nullable_value_test.dart'
+ as unchecked_use_of_nullable_value;
import 'undefined_getter_test.dart' as undefined_getter;
import 'undefined_hidden_name_test.dart' as undefined_hidden_name;
import 'undefined_operator_test.dart' as undefined_operator;
@@ -83,6 +89,7 @@
argument_type_not_assignable.main();
can_be_null_after_null_aware.main();
const_constructor_param_type_mismatch.main();
+ const_constructor_with_mixin_with_field.main();
const_eval_throws_exception.main();
const_map_key_expression_type_implements_equals.main();
const_set_element_type_implements_equals.main();
@@ -101,6 +108,7 @@
invalid_override_different_default_values_positional.main();
invalid_required_param.main();
invalid_sealed_annotation.main();
+ invalid_visibility_annotation.main();
list_element_type_not_assignable.main();
map_entry_not_in_map.main();
map_key_type_not_assignable.main();
@@ -121,6 +129,7 @@
top_level_instance_method.main();
type_check_is_not_null.main();
type_check_is_null.main();
+ unchecked_use_of_nullable_value.main();
undefined_getter.main();
undefined_hidden_name.main();
undefined_operator.main();
diff --git a/pkg/analyzer/test/src/fasta/test_all.dart b/pkg/analyzer/test/src/fasta/test_all.dart
index 91b1a9c..adb1d99 100644
--- a/pkg/analyzer/test/src/fasta/test_all.dart
+++ b/pkg/analyzer/test/src/fasta/test_all.dart
@@ -7,11 +7,13 @@
import 'ast_builder_test.dart' as ast_builder;
import 'message_coverage_test.dart' as message_coverage;
import 'recovery/test_all.dart' as recovery;
+import 'token_utils_test.dart' as token_utils;
main() {
defineReflectiveSuite(() {
ast_builder.main();
message_coverage.main();
recovery.main();
+ token_utils.main();
}, name: 'fasta');
}
diff --git a/pkg/analyzer/test/src/services/test_all.dart b/pkg/analyzer/test/src/services/test_all.dart
new file mode 100644
index 0000000..95e0ef4
--- /dev/null
+++ b/pkg/analyzer/test/src/services/test_all.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2017, 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.
+
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'available_declarations_test.dart' as available_declarations;
+
+main() {
+ defineReflectiveSuite(() {
+ available_declarations.main();
+ }, name: 'services');
+}
diff --git a/pkg/analyzer/test/src/summary2/test_all.dart b/pkg/analyzer/test/src/summary2/test_all.dart
new file mode 100644
index 0000000..f77acf5
--- /dev/null
+++ b/pkg/analyzer/test/src/summary2/test_all.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2017, 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.
+
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'ast_binary_writer_test.dart' as ast_binary_writer;
+
+main() {
+ defineReflectiveSuite(() {
+ ast_binary_writer.main();
+ }, name: 'summary2');
+}
diff --git a/pkg/analyzer/test/src/test_all.dart b/pkg/analyzer/test/src/test_all.dart
index 011e198..32548b3 100644
--- a/pkg/analyzer/test/src/test_all.dart
+++ b/pkg/analyzer/test/src/test_all.dart
@@ -9,15 +9,18 @@
import 'dart/test_all.dart' as dart;
import 'diagnostics/test_all.dart' as diagnostics;
import 'fasta/test_all.dart' as fasta;
+import 'hint/test_all.dart' as hint;
import 'lint/test_all.dart' as lint;
import 'options/test_all.dart' as options;
import 'pubspec/test_all.dart' as pubspec;
+import 'services/test_all.dart' as services;
import 'source/test_all.dart' as source;
import 'summary/test_all.dart' as summary;
+import 'summary2/test_all.dart' as summary2;
import 'task/test_all.dart' as task;
import 'util/test_all.dart' as util;
+import 'workspace/test_all.dart' as workspace;
-/// Utility for manually running all tests.
main() {
defineReflectiveSuite(() {
command_line.main();
@@ -25,12 +28,16 @@
dart.main();
diagnostics.main();
fasta.main();
+ hint.main();
lint.main();
options.main();
pubspec.main();
+ services.main();
source.main();
summary.main();
+ summary2.main();
task.main();
util.main();
+ workspace.main();
}, name: 'src');
}
diff --git a/pkg/analyzer/test/src/workspace/test_all.dart b/pkg/analyzer/test/src/workspace/test_all.dart
index c2e0512..edf5bd0 100644
--- a/pkg/analyzer/test/src/workspace/test_all.dart
+++ b/pkg/analyzer/test/src/workspace/test_all.dart
@@ -1,19 +1,21 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// 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.
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'basic_test.dart' as basic_test;
-import 'bazel_test.dart' as bazel_test;
-import 'gn_test.dart' as gn_test;
-import 'package_build_test.dart' as package_build_test;
+import 'basic_test.dart' as basic;
+import 'bazel_test.dart' as bazel;
+import 'gn_test.dart' as gn;
+import 'package_build_test.dart' as package_build;
+import 'pub_test.dart' as pub;
main() {
defineReflectiveSuite(() {
- basic_test.main();
- bazel_test.main();
- gn_test.main();
- package_build_test.main();
+ basic.main();
+ bazel.main();
+ gn.main();
+ package_build.main();
+ pub.main();
}, name: 'workspace');
}
diff --git a/pkg/analyzer/test/test_all.dart b/pkg/analyzer/test/test_all.dart
index d0c8dfd..a27c273 100644
--- a/pkg/analyzer/test/test_all.dart
+++ b/pkg/analyzer/test/test_all.dart
@@ -1,10 +1,10 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// 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.
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'cancelable_future_test.dart' as cancelable_future_test;
+import 'cancelable_future_test.dart' as cancelable_future;
import 'dart/test_all.dart' as dart;
import 'error/test_all.dart' as error;
import 'file_system/test_all.dart' as file_system;
@@ -13,11 +13,11 @@
import 'parse_compilation_unit_test.dart' as parse_compilation_unit;
import 'source/test_all.dart' as source;
import 'src/test_all.dart' as src;
+import 'verify_tests_test.dart' as verify_tests;
-/// Utility for manually running all tests.
main() {
defineReflectiveSuite(() {
- cancelable_future_test.main();
+ cancelable_future.main();
dart.main();
error.main();
file_system.main();
@@ -26,5 +26,6 @@
parse_compilation_unit.main();
source.main();
src.main();
+ verify_tests.main();
}, name: 'analyzer');
}
diff --git a/pkg/analyzer/test/verify_tests_test.dart b/pkg/analyzer/test/verify_tests_test.dart
new file mode 100644
index 0000000..d22aa57
--- /dev/null
+++ b/pkg/analyzer/test/verify_tests_test.dart
@@ -0,0 +1,82 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/analysis/analysis_context.dart';
+import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/dart/analysis/results.dart';
+import 'package:analyzer/dart/analysis/session.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/file_system/physical_file_system.dart';
+import 'package:front_end/src/testing/package_root.dart' as package_root;
+import 'package:path/path.dart' as path;
+import 'package:test/test.dart';
+
+main() {
+ PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE;
+ String packageRoot = provider.pathContext.normalize(package_root.packageRoot);
+ String analyzerPath = provider.pathContext.join(packageRoot, 'analyzer');
+ String testDirPath = provider.pathContext.join(analyzerPath, 'test');
+
+ AnalysisContextCollection collection = new AnalysisContextCollection(
+ includedPaths: <String>[testDirPath], resourceProvider: provider);
+ List<AnalysisContext> contexts = collection.contexts;
+ if (contexts.length != 1) {
+ fail('The test directory contains multiple analysis contexts.');
+ }
+
+ buildTestsIn(
+ contexts[0].currentSession, testDirPath, provider.getFolder(testDirPath));
+}
+
+void buildTestsIn(
+ AnalysisSession session, String testDirPath, Folder directory) {
+ List<String> testFileNames = [];
+ File testAllFile;
+ List<Resource> children = directory.getChildren();
+ children.sort((first, second) => first.shortName.compareTo(second.shortName));
+ for (Resource child in children) {
+ if (child is Folder) {
+ if (child.getChildAssumingFile('test_all.dart').exists) {
+ testFileNames.add('${child.shortName}/test_all.dart');
+ }
+ buildTestsIn(session, testDirPath, child);
+ } else if (child is File) {
+ String name = child.shortName;
+ if (name == 'test_all.dart') {
+ testAllFile = child;
+ } else if (name.endsWith('_test.dart')) {
+ testFileNames.add(name);
+ }
+ }
+ }
+ String relativePath = path.relative(directory.path, from: testDirPath);
+ test(relativePath, () {
+ if (testFileNames.isEmpty) {
+ return;
+ }
+ if (testAllFile == null) {
+ fail('Missing "test_all.dart" in $relativePath');
+ }
+ ParsedUnitResult result = session.getParsedUnit(testAllFile.path);
+ if (result.state != ResultState.VALID) {
+ fail('Could not parse ${testAllFile.path}');
+ }
+ List<String> importedFiles = [];
+ for (var directive in result.unit.directives) {
+ if (directive is ImportDirective) {
+ importedFiles.add(directive.uri.stringValue);
+ }
+ }
+ List<String> missingFiles = [];
+ for (String testFileName in testFileNames) {
+ if (!importedFiles.contains(testFileName)) {
+ missingFiles.add(testFileName);
+ }
+ }
+ if (missingFiles.isNotEmpty) {
+ fail('Tests missing from "test_all.dart": ${missingFiles.join(', ')}');
+ }
+ });
+}