Version 2.16.0-33.0.dev
Merge commit 'e277d691b4efd99bd577a10b04b97af5c09cef85' into 'dev'
diff --git a/DEPS b/DEPS
index e29b322..9dab5da 100644
--- a/DEPS
+++ b/DEPS
@@ -127,7 +127,7 @@
"lints_tag": "f9670df2a66e0ec12eb51554e70c1cbf56c8f5d0",
"logging_rev": "575781ef196e4fed4fb737e38fb4b73d62727187",
"markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
- "markdown_rev": "9c4beaac96d8f008078e00b027915f81b665d2de",
+ "markdown_rev": "7479783f0493f6717e1d7ae31cb37d39a91026b2",
"matcher_rev": "6ba4a6d68bdfacff3d572c9ea98333dfc66fd6bf",
"mime_rev": "c931f4bed87221beaece356494b43731445ce7b8",
"mockito_rev": "d39ac507483b9891165e422ec98d9fb480037c8b",
diff --git a/pkg/analysis_server/lib/src/cider/rename.dart b/pkg/analysis_server/lib/src/cider/rename.dart
index 980ace6..4c38533 100644
--- a/pkg/analysis_server/lib/src/cider/rename.dart
+++ b/pkg/analysis_server/lib/src/cider/rename.dart
@@ -74,7 +74,7 @@
if (node == null || element == null) {
return null;
}
- if (element.source != null && element.source!.isInSystemLibrary) {
+ if (element.source != null && element.source!.uri.isScheme('dart')) {
return null;
}
if (element is MethodElement && element.isOperator) {
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 1f568f7..7f494be 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -18,7 +18,6 @@
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/lint/linter.dart';
import 'package:analyzer/src/lint/pub.dart';
import 'package:analyzer/src/manifest/manifest_validator.dart';
diff --git a/pkg/analysis_server/lib/src/domain_execution.dart b/pkg/analysis_server/lib/src/domain_execution.dart
index c96814e..5550f0b 100644
--- a/pkg/analysis_server/lib/src/domain_execution.dart
+++ b/pkg/analysis_server/lib/src/domain_execution.dart
@@ -8,7 +8,6 @@
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/generated/source.dart';
/// Instances of the class [ExecutionDomainHandler] implement a [RequestHandler]
/// that handles requests in the `execution` domain.
@@ -122,7 +121,7 @@
}
var source = driver.fsState.getFileForPath(file).source;
- if (source.uriKind != UriKind.FILE_URI) {
+ if (!source.uri.isScheme('file')) {
uri = source.uri.toString();
} else {
uri = sourceFactory.pathToUri(file).toString();
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_field.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_field.dart
index ec42942..3073989 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_field.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_field.dart
@@ -96,7 +96,7 @@
if (targetClassElement == null) {
return;
}
- if (targetClassElement.librarySource.isInSystemLibrary) {
+ if (targetClassElement.librarySource.uri.isScheme('dart')) {
return;
}
utils.targetClassElement = targetClassElement;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
index 3c9c661..cdc8339 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
@@ -74,7 +74,7 @@
return;
}
var targetSource = targetElement.source;
- if (targetSource == null || targetSource.isInSystemLibrary) {
+ if (targetSource == null || targetSource.uri.isScheme('dart')) {
return;
}
// prepare target declaration
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
index 9009561..1774efe 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
@@ -139,7 +139,7 @@
return;
}
targetElement = targetClassElement;
- if (targetClassElement.librarySource.isInSystemLibrary) {
+ if (targetClassElement.librarySource.uri.isScheme('dart')) {
return;
}
// prepare target ClassDeclaration
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
index 8958731..569e134 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
@@ -73,7 +73,7 @@
return;
}
var targetSource = targetElement.source;
- if (targetSource == null || targetSource.isInSystemLibrary) {
+ if (targetSource == null || targetSource.uri.isScheme('dart')) {
return;
}
// prepare target declaration
diff --git a/pkg/analysis_server/lib/src/services/refactoring/rename.dart b/pkg/analysis_server/lib/src/services/refactoring/rename.dart
index 3ca9d77..8fbe15a 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename.dart
@@ -73,7 +73,7 @@
@override
Future<RefactoringStatus> checkInitialConditions() {
var result = RefactoringStatus();
- if (element.source!.isInSystemLibrary) {
+ if (element.source!.uri.isScheme('dart')) {
var message = format(
"The {0} '{1}' is defined in the SDK, so cannot be renamed.",
getElementKindName(element),
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 2aa64b4..260fbd1 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -4,6 +4,9 @@
* Deprecated `path` and `uri` from `AnalysisResult`.
* Deprecated `UriResolver.restoreAbsolute`, use `pathToUri` instead.
* Deprecated `SourceFactory.restoreAbsolute`, use `pathToUri` instead.
+* Deprecated `UriKind` and `Source.uriKind`.
+* Deprecated `Source.modificationStamp`.
+* Deprecated `Source.isInSystemLibrary`, use `uri.isScheme('dart')` instead.
* Fixed #47715.
## 2.7.0
diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart
index f6d3b10..ce09cee 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -7,7 +7,7 @@
import 'dart:typed_data';
import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/source/source_resource.dart';
import 'package:path/path.dart' as pathos;
import 'package:watcher/watcher.dart';
diff --git a/pkg/analyzer/lib/file_system/overlay_file_system.dart b/pkg/analyzer/lib/file_system/overlay_file_system.dart
index dbac07b..559d80e 100644
--- a/pkg/analyzer/lib/file_system/overlay_file_system.dart
+++ b/pkg/analyzer/lib/file_system/overlay_file_system.dart
@@ -6,7 +6,7 @@
import 'dart:typed_data';
import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/source/source_resource.dart';
import 'package:path/path.dart' as pathos;
import 'package:watcher/watcher.dart';
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index 9824499..3f16df1 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -6,7 +6,7 @@
import 'dart:typed_data';
import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/source/source_resource.dart';
import 'package:path/path.dart';
import 'package:watcher/watcher.dart';
diff --git a/pkg/analyzer/lib/src/dart/sdk/sdk.dart b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
index 3520c90..60cfa66 100644
--- a/pkg/analyzer/lib/src/dart/sdk/sdk.dart
+++ b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
@@ -13,7 +13,7 @@
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_engine_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
diff --git a/pkg/analyzer/lib/src/error/imports_verifier.dart b/pkg/analyzer/lib/src/error/imports_verifier.dart
index 88d8a87..0ec6f98 100644
--- a/pkg/analyzer/lib/src/error/imports_verifier.dart
+++ b/pkg/analyzer/lib/src/error/imports_verifier.dart
@@ -790,6 +790,6 @@
if (source2 == null) {
return false;
}
- return !source1.isInSystemLibrary && source2.isInSystemLibrary;
+ return !source1.uri.isScheme('dart') && source2.uri.isScheme('dart');
}
}
diff --git a/pkg/analyzer/lib/src/error/inheritance_override.dart b/pkg/analyzer/lib/src/error/inheritance_override.dart
index 9977e73..b6d1951 100644
--- a/pkg/analyzer/lib/src/error/inheritance_override.dart
+++ b/pkg/analyzer/lib/src/error/inheritance_override.dart
@@ -327,7 +327,7 @@
// The SDK implementation may implement disallowed types. For example,
// JSNumber in dart2js and _Smi in Dart VM both implement int.
- if (library.source.isInSystemLibrary) {
+ if (library.source.uri.isScheme('dart')) {
return false;
}
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 3dea90e..115365f 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -260,7 +260,7 @@
_requiredParametersVerifier = RequiredParametersVerifier(errorReporter),
_duplicateDefinitionVerifier =
DuplicateDefinitionVerifier(_currentLibrary, errorReporter) {
- _isInSystemLibrary = _currentLibrary.source.isInSystemLibrary;
+ _isInSystemLibrary = _currentLibrary.source.uri.isScheme('dart');
_isInCatchClause = false;
_isInStaticVariableDeclaration = false;
_isInConstructorInitializer = false;
@@ -2506,7 +2506,7 @@
}
// The SDK implementation may implement disallowed types. For example,
// JSNumber in dart2js and _Smi in Dart VM both implement int.
- if (_currentLibrary.source.isInSystemLibrary) {
+ if (_currentLibrary.source.uri.isScheme('dart')) {
return false;
}
var type = namedType.type;
diff --git a/pkg/analyzer/lib/src/generated/java_engine_io.dart b/pkg/analyzer/lib/src/generated/java_engine_io.dart
index 5ee3c34..96e9e51 100644
--- a/pkg/analyzer/lib/src/generated/java_engine_io.dart
+++ b/pkg/analyzer/lib/src/generated/java_engine_io.dart
@@ -4,14 +4,6 @@
import "dart:io";
-import "package:analyzer/src/generated/java_io.dart";
-
-class FileUtilities2 {
- static JavaFile createFile(String path) {
- return JavaFile(path).getAbsoluteFile();
- }
-}
-
class OSUtilities {
static String LINE_SEPARATOR = isWindows() ? '\r\n' : '\n';
static bool isMac() => Platform.operatingSystem == 'macos';
diff --git a/pkg/analyzer/lib/src/generated/java_io.dart b/pkg/analyzer/lib/src/generated/java_io.dart
index 3ab4863..4751bc4 100644
--- a/pkg/analyzer/lib/src/generated/java_io.dart
+++ b/pkg/analyzer/lib/src/generated/java_io.dart
@@ -6,6 +6,7 @@
import 'package:path/path.dart' as path;
+@Deprecated('Use ResourceProvider and path context instead.')
class JavaFile {
@deprecated
static path.Context pathContext = path.context;
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 78ad085..ed375ff 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -29,6 +29,7 @@
@override
int get hashCode => uri.hashCode;
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary => uri.scheme == 'dart';
@@ -79,7 +80,9 @@
/// An implementation of an non-existing [Source].
class NonExistingSource extends Source {
static final unknown = NonExistingSource(
- '/unknown.dart', pathos.toUri('/unknown.dart'), UriKind.FILE_URI);
+ '/unknown.dart',
+ pathos.toUri('/unknown.dart'),
+ );
@override
final String fullName;
@@ -87,10 +90,7 @@
@override
final Uri uri;
- @override
- final UriKind uriKind;
-
- NonExistingSource(this.fullName, this.uri, this.uriKind);
+ NonExistingSource(this.fullName, this.uri);
@override
TimestampedData<String> get contents {
@@ -104,19 +104,27 @@
@override
int get hashCode => fullName.hashCode;
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary => false;
+ @Deprecated('Not used anymore')
@override
int get modificationStamp => -1;
@override
String get shortName => pathos.basename(fullName);
+ @Deprecated('Use Source.uri instead')
+ @override
+ UriKind get uriKind {
+ return UriKind.FILE_URI;
+ }
+
@override
bool operator ==(Object other) {
if (other is NonExistingSource) {
- return other.uriKind == uriKind && other.fullName == fullName;
+ return other.uri == uri && other.fullName == fullName;
}
return false;
}
@@ -186,6 +194,7 @@
/// Return `true` if this source is in one of the system libraries.
///
/// @return `true` if this is in a system library
+ @Deprecated('Use uri.isScheme("dart") instead')
bool get isInSystemLibrary;
/// Return the modification stamp for this source, or a negative value if the
@@ -199,6 +208,7 @@
/// Clients should consider using the method
/// [AnalysisContext.getModificationStamp] because contexts can have local
/// overrides of the content of a source that the source is not aware of.
+ @Deprecated('Not used anymore')
int get modificationStamp;
/// Return a short version of the name that can be displayed to the user to
@@ -220,6 +230,7 @@
/// against which the relative URI was resolved.
///
/// @return the kind of URI from which this source was originally derived
+ @Deprecated('Use Source.uri instead')
UriKind get uriKind;
/// Return `true` if the given object is a source that represents the same
@@ -342,6 +353,7 @@
/// The enumeration `UriKind` defines the different kinds of URI's that are
/// known to the analysis engine. These are used to keep track of the kind of
/// URI associated with a given source.
+@Deprecated('Use Source.uri instead')
class UriKind implements Comparable<UriKind> {
/// A 'dart:' URI.
static const UriKind DART_URI = UriKind('DART_URI', 0, 0x64);
diff --git a/pkg/analyzer/lib/src/generated/source_io.dart b/pkg/analyzer/lib/src/generated/source_io.dart
index d4d7610..1eb71fb 100644
--- a/pkg/analyzer/lib/src/generated/source_io.dart
+++ b/pkg/analyzer/lib/src/generated/source_io.dart
@@ -2,113 +2,5 @@
// 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 'dart:collection';
-
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/java_io.dart';
-import 'package:analyzer/src/generated/source.dart';
-
+@Deprecated('Import source.dart instead')
export 'package:analyzer/src/generated/source.dart';
-
-/// Instances of the class `FileBasedSource` implement a source that represents
-/// a file.
-class FileBasedSource extends Source {
- /// Map from encoded URI/filepath pair to a unique integer identifier. This
- /// identifier is used for equality tests and hash codes.
- ///
- /// The URI and filepath are joined into a pair by separating them with an '@'
- /// character.
- static final Map<String, int> _idTable = HashMap<String, int>();
-
- /// The URI from which this source was originally derived.
- @override
- final Uri uri;
-
- /// The unique ID associated with this [FileBasedSource].
- final int id;
-
- /// The file represented by this source.
- final JavaFile file;
-
- /// The cached absolute path of this source.
- String? _absolutePath;
-
- /// The cached encoding for this source.
- String? _encoding;
-
- /// Initialize a newly created source object to represent the given [file]. If
- /// a [uri] is given, then it will be used as the URI from which the source
- /// was derived, otherwise a `file:` URI will be created based on the [file].
- FileBasedSource(JavaFile file, [Uri? uri])
- : uri = uri ?? file.toURI(),
- file = file,
- id = _idTable.putIfAbsent(
- '${uri ?? file.toURI()}@${file.getPath()}', () => _idTable.length);
-
- @override
- TimestampedData<String> get contents {
- return contentsFromFile;
- }
-
- /// Get the contents and timestamp of the underlying file.
- ///
- /// Clients should consider using the method [AnalysisContext.getContents]
- /// because contexts can have local overrides of the content of a source that
- /// the source is not aware of.
- ///
- /// @return the contents of the source paired with the modification stamp of
- /// the source
- /// @throws Exception if the contents of this source could not be accessed
- /// See [contents].
- TimestampedData<String> get contentsFromFile {
- return TimestampedData<String>(
- file.lastModified(), file.readAsStringSync());
- }
-
- @Deprecated('Not used anymore')
- @override
- String get encoding {
- return _encoding ??= uri.toString();
- }
-
- @override
- String get fullName {
- return _absolutePath ??= file.getAbsolutePath();
- }
-
- @override
- int get hashCode => uri.hashCode;
-
- @override
- bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME;
-
- @override
- int get modificationStamp => file.lastModified();
-
- @override
- String get shortName => file.getName();
-
- @override
- UriKind get uriKind {
- String scheme = uri.scheme;
- return UriKind.fromScheme(scheme);
- }
-
- @override
- bool operator ==(Object object) {
- if (object is FileBasedSource) {
- return id == object.id;
- } else if (object is Source) {
- return uri == object.uri;
- }
- return false;
- }
-
- @override
- bool exists() => file.isFile();
-
- @override
- String toString() {
- return file.getAbsolutePath();
- }
-}
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index dec8133..5a0663c 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -90,8 +90,7 @@
static CompilationUnitElementImpl compilationUnit(String fileName,
[Source? librarySource]) {
- Source source =
- NonExistingSource(fileName, toUri(fileName), UriKind.FILE_URI);
+ Source source = NonExistingSource(fileName, toUri(fileName));
CompilationUnitElementImpl unit = CompilationUnitElementImpl();
unit.source = source;
librarySource ??= source;
diff --git a/pkg/analyzer/lib/src/source/source_resource.dart b/pkg/analyzer/lib/src/source/source_resource.dart
index e6db733..9334b31 100644
--- a/pkg/analyzer/lib/src/source/source_resource.dart
+++ b/pkg/analyzer/lib/src/source/source_resource.dart
@@ -65,7 +65,7 @@
/// See [contents].
TimestampedData<String> get contentsFromFile {
return TimestampedData<String>(
- modificationStamp, fileReadMode(file.readAsStringSync()));
+ file.modificationStamp, fileReadMode(file.readAsStringSync()));
}
@Deprecated('Not used anymore')
@@ -78,9 +78,11 @@
@override
int get hashCode => uri.hashCode;
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME;
+ @Deprecated('Not used anymore')
@override
int get modificationStamp {
try {
@@ -93,6 +95,7 @@
@override
String get shortName => file.shortName;
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind => UriKind.fromScheme(uri.scheme);
diff --git a/pkg/analyzer/lib/src/string_source.dart b/pkg/analyzer/lib/src/string_source.dart
index bb774d8..a8e55db 100644
--- a/pkg/analyzer/lib/src/string_source.dart
+++ b/pkg/analyzer/lib/src/string_source.dart
@@ -36,12 +36,14 @@
@override
int get hashCode => _contents.hashCode ^ fullName.hashCode;
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary => false;
@override
String get shortName => fullName;
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind => UriKind.FILE_URI;
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index d39d264..99372ae 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -72,9 +72,11 @@
@override
TimestampedData<String> get contents => TimestampedData<String>(0, '');
+ @Deprecated('Not used anymore')
@override
int get modificationStamp => 0;
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind => UriKind.PACKAGE_URI;
diff --git a/pkg/analyzer/test/file_system/file_system_test_support.dart b/pkg/analyzer/test/file_system/file_system_test_support.dart
index 722474a..0550aa1 100644
--- a/pkg/analyzer/test/file_system/file_system_test_support.dart
+++ b/pkg/analyzer/test/file_system/file_system_test_support.dart
@@ -103,7 +103,6 @@
Source source = file.createSource();
expect(source, isNotNull);
expect(source.fullName, defaultFilePath);
- expect(source.uriKind, UriKind.FILE_URI);
expect(source.uri, Uri.file(defaultFilePath));
expect(source.exists(), isTrue);
expect(source.contents.data, defaultFileContent);
diff --git a/pkg/analyzer/test/file_system/memory_file_system_test.dart b/pkg/analyzer/test/file_system/memory_file_system_test.dart
index 9eecb33..873dc18 100644
--- a/pkg/analyzer/test/file_system/memory_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/memory_file_system_test.dart
@@ -216,6 +216,7 @@
expect(source.fullName, sourcePath);
}
+ @Deprecated('Not used anymore')
test_modificationStamp() {
expect(source.modificationStamp, -1);
}
diff --git a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
index 9ae396e..61f06df 100644
--- a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
+++ b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
@@ -72,8 +72,8 @@
var source = resolver.resolveAbsolute(uri)!;
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(NonExistingSource(
- source.fullName, Uri.parse('dart:math'), UriKind.DART_URI)),
+ resolver.restoreAbsolute(
+ NonExistingSource(source.fullName, Uri.parse('dart:math'))),
uri);
}
}
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 1785d44..532fa53 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -5,10 +5,8 @@
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart' hide SdkLibrariesReader;
-import 'package:analyzer/src/generated/java_engine_io.dart';
-import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:test/test.dart';
@@ -18,7 +16,6 @@
defineReflectiveSuite(() {
defineReflectiveTests(DartUriResolverTest);
defineReflectiveTests(ErrorSeverityTest);
- defineReflectiveTests(FileBasedSourceTest);
defineReflectiveTests(ResolveRelativeUriTest);
defineReflectiveTests(UriKindTest);
});
@@ -142,134 +139,6 @@
}
@reflectiveTest
-class FileBasedSourceTest {
- test_equals_false_differentFiles() async {
- JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart");
- JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart");
- FileBasedSource source1 = FileBasedSource(file1);
- FileBasedSource source2 = FileBasedSource(file2);
- expect(source1 == source2, isFalse);
- }
-
- test_equals_false_null() async {
- JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart");
- FileBasedSource source1 = FileBasedSource(file);
- expect(source1, isNotNull);
- }
-
- test_equals_true() async {
- JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
- JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source1 = FileBasedSource(file1);
- FileBasedSource source2 = FileBasedSource(file2);
- expect(source1 == source2, isTrue);
- }
-
- test_getFullName() async {
- String fullPath = "/does/not/exist.dart";
- JavaFile file = FileUtilities2.createFile(fullPath);
- FileBasedSource source = FileBasedSource(file);
- expect(source.fullName, file.getAbsolutePath());
- }
-
- test_getShortName() async {
- JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = FileBasedSource(file);
- expect(source.shortName, "exist.dart");
- }
-
- test_hashCode() async {
- JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
- JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source1 = FileBasedSource(file1);
- FileBasedSource source2 = FileBasedSource(file2);
- expect(source2.hashCode, source1.hashCode);
- }
-
- test_isInSystemLibrary_contagious() async {
- DartSdk sdk = (_SimpleDartSdkTest()..setUp()).sdk;
- UriResolver resolver = DartUriResolver(sdk);
- SourceFactory factory = SourceFactory([resolver]);
- // resolve dart:core
- var result = resolver.resolveAbsolute(Uri.parse("dart:core"));
- expect(result, isNotNull);
- expect(result!.isInSystemLibrary, isTrue);
- // system libraries reference only other system libraries
- var partSource = factory.resolveUri(result, "num.dart");
- expect(partSource, isNotNull);
- expect(partSource!.isInSystemLibrary, isTrue);
- }
-
- test_isInSystemLibrary_false() async {
- JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = FileBasedSource(file);
- expect(source, isNotNull);
- expect(source.fullName, file.getAbsolutePath());
- expect(source.isInSystemLibrary, isFalse);
- }
-
- test_issue14500() async {
- // see https://code.google.com/p/dart/issues/detail?id=14500
- FileBasedSource source = FileBasedSource(
- FileUtilities2.createFile("/some/packages/foo:bar.dart"));
- expect(source, isNotNull);
- expect(source.exists(), isFalse);
- }
-
- test_resolveRelative_file_fileName() async {
- if (OSUtilities.isWindows()) {
- // On Windows, the URI that is produced includes a drive letter,
- // which I believe is not consistent across all machines that might run
- // this test.
- return;
- }
- JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = FileBasedSource(file);
- expect(source, isNotNull);
- Uri relative = resolveRelativeUri(source.uri, Uri.parse("lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "file:///a/b/lib.dart");
- }
-
- test_resolveRelative_file_filePath() async {
- if (OSUtilities.isWindows()) {
- // On Windows, the URI that is produced includes a drive letter,
- // which I believe is not consistent across all machines that might run
- // this test.
- return;
- }
- JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = FileBasedSource(file);
- expect(source, isNotNull);
- Uri relative = resolveRelativeUri(source.uri, Uri.parse("c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "file:///a/b/c/lib.dart");
- }
-
- test_resolveRelative_file_filePathWithParent() async {
- if (OSUtilities.isWindows()) {
- // On Windows, the URI that is produced includes a drive letter, which I
- // believe is not consistent across all machines that might run this test.
- return;
- }
- JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = FileBasedSource(file);
- expect(source, isNotNull);
- Uri relative = resolveRelativeUri(source.uri, Uri.parse("../c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "file:///a/c/lib.dart");
- }
-
- test_system() async {
- JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = FileBasedSource(file, Uri.parse("dart:core"));
- expect(source, isNotNull);
- expect(source.fullName, file.getAbsolutePath());
- expect(source.isInSystemLibrary, isTrue);
- }
-}
-
-@reflectiveTest
class ResolveRelativeUriTest {
test_resolveRelative_dart_dartUri() async {
_assertResolve('dart:foo', 'dart:bar', 'dart:bar');
@@ -324,6 +193,7 @@
@reflectiveTest
class UriKindTest {
+ @deprecated
test_fromEncoding() async {
expect(UriKind.fromEncoding(0x64), same(UriKind.DART_URI));
expect(UriKind.fromEncoding(0x66), same(UriKind.FILE_URI));
@@ -331,6 +201,7 @@
expect(UriKind.fromEncoding(0x58), isNull);
}
+ @deprecated
test_getEncoding() async {
expect(UriKind.DART_URI.encoding, 0x64);
expect(UriKind.FILE_URI.encoding, 0x66);
diff --git a/pkg/analyzer/test/generated/java_io_test.dart b/pkg/analyzer/test/generated/java_io_test.dart
index 561b53a..35bfdeb 100644
--- a/pkg/analyzer/test/generated/java_io_test.dart
+++ b/pkg/analyzer/test/generated/java_io_test.dart
@@ -16,6 +16,7 @@
expect(path.context.isAbsolute(absolutePath), isTrue,
reason: '"$absolutePath" is not absolute');
// test that toURI() returns an absolute URI
+ // ignore: deprecated_member_use_from_same_package
Uri uri = JavaFile(absolutePath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
@@ -30,6 +31,7 @@
// it may be not on Windows, if "temp" is on other disk.
String relPath = path.context.relative(absolutePath);
// test that toURI() returns an absolute URI
+ // ignore: deprecated_member_use_from_same_package
Uri uri = JavaFile(relPath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
diff --git a/pkg/analyzer/test/generated/test_analysis_context.dart b/pkg/analyzer/test/generated/test_analysis_context.dart
index d2a9238..7d5eae6 100644
--- a/pkg/analyzer/test/generated/test_analysis_context.dart
+++ b/pkg/analyzer/test/generated/test_analysis_context.dart
@@ -9,7 +9,7 @@
import 'package:analyzer/src/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/test_utilities/mock_sdk_elements.dart';
class TestAnalysisContext implements AnalysisContext {
diff --git a/pkg/analyzer/test/generated/test_support.dart b/pkg/analyzer/test/generated/test_support.dart
index 060868d..927a542 100644
--- a/pkg/analyzer/test/generated/test_support.dart
+++ b/pkg/analyzer/test/generated/test_support.dart
@@ -466,11 +466,13 @@
@override
int get hashCode => 0;
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary {
return false;
}
+ @Deprecated('Not used anymore')
@override
int get modificationStamp =>
generateExceptionOnRead ? -1 : _modificationStamp;
@@ -483,6 +485,7 @@
@override
Uri get uri => Uri.file(_name);
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind {
throw UnsupportedError('uriKind');
@@ -524,6 +527,7 @@
@override
String get encoding => uri.toString();
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind {
if (uri.scheme == 'dart') {
diff --git a/pkg/analyzer/test/source/package_map_resolver_test.dart b/pkg/analyzer/test/source/package_map_resolver_test.dart
index 2cd49c3..27d7a9c 100644
--- a/pkg/analyzer/test/source/package_map_resolver_test.dart
+++ b/pkg/analyzer/test/source/package_map_resolver_test.dart
@@ -97,14 +97,14 @@
Uri uri = Uri.parse('package:pkgA/libA.dart');
var result = resolver.resolveAbsolute(uri)!;
expect(result.exists(), isTrue);
- expect(result.uriKind, UriKind.PACKAGE_URI);
+ expect(result.uri, uri);
expect(result.fullName, pkgFileA);
}
{
Uri uri = Uri.parse('package:pkgB/libB.dart');
var result = resolver.resolveAbsolute(uri)!;
expect(result.exists(), isTrue);
- expect(result.uriKind, UriKind.PACKAGE_URI);
+ expect(result.uri, uri);
expect(result.fullName, pkgFileB);
}
}
@@ -201,7 +201,8 @@
}
}
+ @Deprecated('Use pathToUri() instead')
Source _createFileSource(String path) {
- return NonExistingSource(path, toUri(path), UriKind.FILE_URI);
+ return NonExistingSource(path, toUri(path));
}
}
diff --git a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
index 853eb50..82433a76 100644
--- a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
+++ b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
@@ -642,7 +642,7 @@
var reporter = ErrorReporter(
listener,
- NonExistingSource('/test.dart', toUri('/test.dart'), UriKind.FILE_URI),
+ NonExistingSource('/test.dart', toUri('/test.dart')),
isNonNullableByDefault: false,
);
diff --git a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
index 40d24dd..6e9b9ef 100644
--- a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
@@ -139,7 +139,6 @@
.getChildAssumingFile("core.dart")
.toUri())!;
expect(source, isNotNull);
- expect(source.isInSystemLibrary, isTrue);
expect(source.uri.toString(), "dart:core");
}
@@ -150,7 +149,6 @@
File file = dirDartium.getChildAssumingFile("html_dart2js.dart");
var source = sdk.fromFileUri(file.toUri())!;
expect(source, isNotNull);
- expect(source.isInSystemLibrary, isTrue);
expect(source.uri.toString(), "dart:html");
}
@@ -161,7 +159,6 @@
File file = dirCommon.getChildAssumingFile("html_common_dart2js.dart");
var source = sdk.fromFileUri(file.toUri())!;
expect(source, isNotNull);
- expect(source.isInSystemLibrary, isTrue);
expect(source.uri.toString(), "dart:html_common");
}
@@ -172,7 +169,6 @@
.getChildAssumingFile("num.dart")
.toUri())!;
expect(source, isNotNull);
- expect(source.isInSystemLibrary, isTrue);
expect(source.uri.toString(), "dart:core/num.dart");
}
diff --git a/pkg/analyzer/test/src/source/source_resource_test.dart b/pkg/analyzer/test/src/source/source_resource_test.dart
index fb3b7b8a..901d10f 100644
--- a/pkg/analyzer/test/src/source/source_resource_test.dart
+++ b/pkg/analyzer/test/src/source/source_resource_test.dart
@@ -83,6 +83,7 @@
expect(source2.hashCode, source1.hashCode);
}
+ @Deprecated('Use uri.isScheme("dart") instead')
void test_isInSystemLibrary_contagious() {
DartSdk sdk = _createSdk();
UriResolver resolver = DartUriResolver(sdk);
@@ -95,6 +96,7 @@
expect(partSource.isInSystemLibrary, isTrue);
}
+ @Deprecated('Use uri.isScheme("dart") instead')
void test_isInSystemLibrary_false() {
File file = getFile("/does/not/exist.dart");
FileSource source = FileSource(file);
@@ -159,7 +161,7 @@
FileSource source = FileSource(file, Uri.parse("dart:core"));
expect(source, isNotNull);
expect(source.fullName, file.path);
- expect(source.isInSystemLibrary, isTrue);
+ expect(source.uri.toString(), 'dart:core');
}
DartSdk _createSdk() {
diff --git a/pkg/analyzer/test/src/summary/in_summary_source_test.dart b/pkg/analyzer/test/src/summary/in_summary_source_test.dart
index 570ebce..2e8ef04 100644
--- a/pkg/analyzer/test/src/summary/in_summary_source_test.dart
+++ b/pkg/analyzer/test/src/summary/in_summary_source_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index e045770..6378283 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -62,7 +62,7 @@
for (var sdkLibrary in sdk.sdkLibraries) {
var source = sourceFactory.resolveUri(null, sdkLibrary.shortName)!;
var text = getFile(source.fullName).readAsStringSync();
- var unit = parseText(text, featureSet);
+ var unit = parseText(source, text, featureSet);
var inputUnits = <LinkInputUnit>[];
_addLibraryUnits(source, unit, inputUnits, featureSet);
@@ -180,7 +180,7 @@
if (partSource != null) {
var text = _readSafely(partSource.fullName);
- var unit = parseText(text, featureSet);
+ var unit = parseText(partSource, text, featureSet);
units.add(
LinkInputUnit(
partDirectiveIndex: partDirectiveIndex,
@@ -205,7 +205,7 @@
}
var text = _readSafely(source.fullName);
- var unit = parseText(text, featureSet);
+ var unit = parseText(source, text, featureSet);
var units = <LinkInputUnit>[];
_addLibraryUnits(source, unit, units, featureSet);
diff --git a/pkg/analyzer/test/src/summary/test_strategies.dart b/pkg/analyzer/test/src/summary/test_strategies.dart
index 5632a0a..8d21be1 100644
--- a/pkg/analyzer/test/src/summary/test_strategies.dart
+++ b/pkg/analyzer/test/src/summary/test_strategies.dart
@@ -14,22 +14,22 @@
import 'package:analyzer/src/generated/source.dart';
CompilationUnit parseText(
+ Source source,
String text,
FeatureSet featureSet,
) {
CharSequenceReader reader = CharSequenceReader(text);
- Scanner scanner =
- Scanner(_SourceMock.instance, reader, AnalysisErrorListener.NULL_LISTENER)
- ..configureFeatures(
- featureSetForOverriding: featureSet,
- featureSet: featureSet,
- );
+ Scanner scanner = Scanner(source, reader, AnalysisErrorListener.NULL_LISTENER)
+ ..configureFeatures(
+ featureSetForOverriding: featureSet,
+ featureSet: featureSet,
+ );
Token token = scanner.tokenize();
// Pass the feature set from the scanner to the parser
// because the scanner may have detected a language version comment
// and downgraded the feature set it holds.
Parser parser = Parser(
- NonExistingSource.unknown,
+ source,
AnalysisErrorListener.NULL_LISTENER,
featureSet: scanner.featureSet,
);
@@ -43,10 +43,3 @@
return unit;
}
-
-class _SourceMock implements Source {
- static final Source instance = _SourceMock();
-
- @override
- noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
-}
diff --git a/pkg/analyzer/test/src/workspace/bazel_test.dart b/pkg/analyzer/test/src/workspace/bazel_test.dart
index 460a696..0177638 100644
--- a/pkg/analyzer/test/src/workspace/bazel_test.dart
+++ b/pkg/analyzer/test/src/workspace/bazel_test.dart
@@ -92,8 +92,8 @@
var source = resolver.resolveAbsolute(uri)!;
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(NonExistingSource(source.fullName,
- Uri.parse('package:test/test.dart'), UriKind.PACKAGE_URI)),
+ resolver.restoreAbsolute(NonExistingSource(
+ source.fullName, Uri.parse('package:test/test.dart'))),
uri);
}
diff --git a/pkg/analyzer/test/src/workspace/package_build_test.dart b/pkg/analyzer/test/src/workspace/package_build_test.dart
index 6e2cf99..f262445 100644
--- a/pkg/analyzer/test/src/workspace/package_build_test.dart
+++ b/pkg/analyzer/test/src/workspace/package_build_test.dart
@@ -114,8 +114,8 @@
expect(source, isNotNull);
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(NonExistingSource(source.fullName,
- Uri.parse('package:test/test.dart'), UriKind.PACKAGE_URI)),
+ resolver.restoreAbsolute(NonExistingSource(
+ source.fullName, Uri.parse('package:test/test.dart'))),
uri);
}
diff --git a/pkg/analyzer_cli/lib/src/analyzer_impl.dart b/pkg/analyzer_cli/lib/src/analyzer_impl.dart
index 4b3846b..c52c6ee 100644
--- a/pkg/analyzer_cli/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer_cli/lib/src/analyzer_impl.dart
@@ -11,8 +11,6 @@
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/error_formatter.dart';
import 'package:analyzer_cli/src/error_severity.dart';
@@ -168,16 +166,15 @@
/// Returns true if we want to report diagnostics for this library.
bool _isAnalyzedLibrary(LibraryElement library) {
var source = library.source;
- switch (source.uriKind) {
- case UriKind.DART_URI:
- return options.showSdkWarnings;
- case UriKind.PACKAGE_URI:
- if (_isPathInPubCache(source.fullName)) {
- return false;
- }
- return _isAnalyzedPackage(source.uri);
- default:
- return true;
+ if (source.uri.isScheme('dart')) {
+ return options.showSdkWarnings;
+ } else if (source.uri.isScheme('package')) {
+ if (_isPathInPubCache(source.fullName)) {
+ return false;
+ }
+ return _isAnalyzedPackage(source.uri);
+ } else {
+ return true;
}
}
diff --git a/pkg/analyzer_cli/lib/src/error_formatter.dart b/pkg/analyzer_cli/lib/src/error_formatter.dart
index f496762..f43b471 100644
--- a/pkg/analyzer_cli/lib/src/error_formatter.dart
+++ b/pkg/analyzer_cli/lib/src/error_formatter.dart
@@ -297,9 +297,9 @@
// warning • 'foo' is not a bar. • lib/foo.dart:1:2 • foo_warning
String sourcePath;
- if (source.uriKind == UriKind.DART_URI) {
+ if (source.uri.isScheme('dart')) {
sourcePath = source.uri.toString();
- } else if (source.uriKind == UriKind.PACKAGE_URI) {
+ } else if (source.uri.isScheme('package')) {
sourcePath = _relative(source.fullName);
if (sourcePath == source.fullName) {
// If we weren't able to shorten the path name, use the package: version.
diff --git a/pkg/analyzer_cli/test/mocks.dart b/pkg/analyzer_cli/test/mocks.dart
index ca4475f..32e69bf 100644
--- a/pkg/analyzer_cli/test/mocks.dart
+++ b/pkg/analyzer_cli/test/mocks.dart
@@ -155,46 +155,13 @@
class MockSource implements Source {
@override
- String fullName;
-
- MockSource(this.fullName);
+ final String fullName;
@override
- TimestampedData<String> get contents {
- throw StateError('Unexpected invocation of contents');
- }
+ final Uri uri;
- @Deprecated('Not used anymore')
- @override
- String get encoding {
- throw StateError('Unexpected invocation of encoding');
- }
+ MockSource(this.fullName, this.uri);
@override
- bool get isInSystemLibrary {
- throw StateError('Unexpected invocation of isInSystemLibrary');
- }
-
- @override
- int get modificationStamp {
- throw StateError('Unexpected invocation of modificationStamp');
- }
-
- @override
- String get shortName {
- throw StateError('Unexpected invocation of shortName');
- }
-
- @override
- Uri get uri {
- throw StateError('Unexpected invocation of uri');
- }
-
- @override
- UriKind get uriKind => null; //UriKind.FILE_URI;
-
- @override
- bool exists() {
- throw StateError('Unexpected invocation of exists');
- }
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
diff --git a/pkg/analyzer_cli/test/reporter_test.dart b/pkg/analyzer_cli/test/reporter_test.dart
index e0edaba..3088a6c 100644
--- a/pkg/analyzer_cli/test/reporter_test.dart
+++ b/pkg/analyzer_cli/test/reporter_test.dart
@@ -7,6 +7,7 @@
import 'package:analyzer/src/dart/analysis/results.dart';
import 'package:analyzer_cli/src/ansi.dart' as ansi;
import 'package:analyzer_cli/src/error_formatter.dart';
+import 'package:path/path.dart' as package_path;
import 'package:test/test.dart' hide ErrorFormatter;
import 'mocks.dart';
@@ -102,7 +103,8 @@
// Details
var code = MockErrorCode(type, severity, 'mock_code');
- var source = MockSource('/foo/bar/baz.dart');
+ var path = '/foo/bar/baz.dart';
+ var source = MockSource(path, package_path.toUri(path));
var error = MockAnalysisError(source, code, 20, 'MSG');
return ErrorsResultImpl(
diff --git a/pkg/analyzer_cli/tool/perf.dart b/pkg/analyzer_cli/tool/perf.dart
index e4e3dcb..a16cb88 100644
--- a/pkg/analyzer_cli/tool/perf.dart
+++ b/pkg/analyzer_cli/tool/perf.dart
@@ -19,7 +19,6 @@
import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
import 'package:analyzer/src/generated/parser.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/source/package_map_resolver.dart';
void main(List<String> args) async {
diff --git a/pkg/analyzer_plugin/test/plugin/mocks.dart b/pkg/analyzer_plugin/test/plugin/mocks.dart
index 9e066ab..bf4de1d 100644
--- a/pkg/analyzer_plugin/test/plugin/mocks.dart
+++ b/pkg/analyzer_plugin/test/plugin/mocks.dart
@@ -166,9 +166,11 @@
@override
String get fullName => '/pkg/lib/test.dart';
+ @Deprecated('Use uri.isScheme("dart") instead')
@override
bool get isInSystemLibrary => false;
+ @Deprecated('Not used anymore')
@override
int get modificationStamp => 0;
@@ -178,6 +180,7 @@
@override
Uri get uri => Uri.parse('package:test/test.dart');
+ @Deprecated('Use Source.uri instead')
@override
UriKind get uriKind => UriKind.PACKAGE_URI;
diff --git a/pkg/dartdev/test/analytics_test.dart b/pkg/dartdev/test/analytics_test.dart
index 8314399..450db64 100644
--- a/pkg/dartdev/test/analytics_test.dart
+++ b/pkg/dartdev/test/analytics_test.dart
@@ -40,9 +40,9 @@
});
});
- test('Analytics control smoke test', () {
+ test('Analytics control smoke test', () async {
final p = project(logAnalytics: true);
- var result = p.runSync(['--disable-analytics']);
+ var result = await p.run(['--disable-analytics']);
expect(result.stdout, contains('''
╔════════════════════════════════════════════════════════════════════════════╗
║ Analytics reporting disabled. In order to enable it, run: ║
@@ -52,7 +52,7 @@
╚════════════════════════════════════════════════════════════════════════════╝
'''));
- result = p.runSync(['--enable-analytics']);
+ result = await p.run(['--enable-analytics']);
expect(result.stdout, contains('''
╔════════════════════════════════════════════════════════════════════════════╗
║ The Dart tool uses Google Analytics to report feature usage statistics ║
@@ -69,9 +69,9 @@
final experiments = await experimentsWithValidation();
group('Sending analytics', () {
- test('help', () {
+ test('help', () async {
final p = project(logAnalytics: true);
- final result = p.runSync(['help']);
+ final result = await p.run(['help']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
@@ -97,10 +97,10 @@
}
]);
});
- test('create', () {
+ test('create', () async {
final p = project(logAnalytics: true);
final result =
- p.runSync(['create', '--no-pub', '-tpackage-simple', 'name']);
+ await p.run(['create', '--no-pub', '-tpackage-simple', 'name']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
@@ -129,13 +129,13 @@
]);
});
- test('pub get dry run', () {
+ test('pub get dry run', () async {
final p = project(logAnalytics: true, pubspec: {
'name': 'foo',
'environment': {'sdk': '>=2.10.0 <3.0.0'},
'dependencies': {'_dummy_pkg': '0.0.1'}
});
- final result = p.runSync(['pub', 'get', '--dry-run']);
+ final result = await p.run(['pub', 'get', '--dry-run']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
@@ -164,13 +164,13 @@
]);
});
- test('pub get', () {
+ test('pub get', () async {
final p = project(logAnalytics: true, pubspec: {
'name': 'foo',
'environment': {'sdk': '>=2.10.0 <3.0.0'},
'dependencies': {'_dummy_pkg': '0.0.1'}
});
- final result = p.runSync(['pub', 'get']);
+ final result = await p.run(['pub', 'get']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
@@ -218,9 +218,9 @@
]);
});
- test('format', () {
+ test('format', () async {
final p = project(logAnalytics: true);
- final result = p.runSync(['format', '-l80', '.']);
+ final result = await p.run(['format', '-l80', '.']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
@@ -249,11 +249,11 @@
]);
});
- test('run', () {
+ test('run', () async {
final p = project(
mainSrc: 'void main(List<String> args) => print(args)',
logAnalytics: true);
- final result = p.runSync([
+ final result = await p.run([
'run',
'--no-pause-isolates-on-exit',
'--enable-asserts',
@@ -289,11 +289,11 @@
});
group('run --enable-experiments', () {
for (final experiment in experiments) {
- test(experiment.name, () {
+ test(experiment.name, () async {
final p = project(mainSrc: experiment.validation, logAnalytics: true);
{
for (final no in ['', 'no-']) {
- final result = p.runSync([
+ final result = await p.run([
'run',
'--enable-experiment=$no${experiment.name}',
'lib/main.dart',
@@ -330,12 +330,12 @@
}
});
- test('compile', () {
+ test('compile', () async {
final p = project(
mainSrc: 'void main(List<String> args) => print(args);',
logAnalytics: true);
- final result = p
- .runSync(['compile', 'kernel', 'lib/main.dart', '-o', 'main.kernel']);
+ final result = await p
+ .run(['compile', 'kernel', 'lib/main.dart', '-o', 'main.kernel']);
expect(extractAnalytics(result), [
{
'hitType': 'screenView',
diff --git a/pkg/dartdev/test/commands/analyze_test.dart b/pkg/dartdev/test/commands/analyze_test.dart
index af8984c..11613ef 100644
--- a/pkg/dartdev/test/commands/analyze_test.dart
+++ b/pkg/dartdev/test/commands/analyze_test.dart
@@ -178,9 +178,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['analyze', '--help']);
+ var result = await p.run(['analyze', '--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -188,9 +188,9 @@
expect(result.stdout, contains(_analyzeUsageText));
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['analyze', '--help', '--verbose']);
+ var result = await p.run(['analyze', '--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -203,10 +203,10 @@
tearDown(() => secondProject?.dispose());
- test('folder and file', () {
+ test('folder and file', () async {
p = project(mainSrc: "int get foo => 'str';\n");
secondProject = project(mainSrc: "int get foo => 'str';\n");
- var result = p.runSync(['analyze', p.dirPath, secondProject.mainPath]);
+ var result = await p.run(['analyze', p.dirPath, secondProject.mainPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -216,10 +216,10 @@
expect(result.stdout, contains('2 issues found.'));
});
- test('two folders', () {
+ test('two folders', () async {
p = project(mainSrc: "int get foo => 'str';\n");
secondProject = project(mainSrc: "int get foo => 'str';\n");
- var result = p.runSync(['analyze', p.dirPath, secondProject.dirPath]);
+ var result = await p.run(['analyze', p.dirPath, secondProject.dirPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -230,9 +230,9 @@
});
});
- test('no such directory', () {
+ test('no such directory', () async {
p = project();
- var result = p.runSync(['analyze', '/no/such/dir1/']);
+ var result = await p.run(['analyze', '/no/such/dir1/']);
expect(result.exitCode, 64);
expect(result.stdout, isEmpty);
@@ -241,10 +241,10 @@
expect(result.stderr, contains(_analyzeUsageText));
});
- test('current working directory', () {
+ test('current working directory', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['analyze'], workingDir: p.dirPath);
+ var result = await p.run(['analyze'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -252,18 +252,18 @@
});
group('single directory', () {
- test('no errors', () {
+ test('no errors', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['analyze', p.dirPath]);
+ var result = await p.run(['analyze', p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('No issues found!'));
});
- test('one error', () {
+ test('one error', () async {
p = project(mainSrc: "int get foo => 'str';\n");
- var result = p.runSync(['analyze', p.dirPath]);
+ var result = await p.run(['analyze', p.dirPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -273,9 +273,9 @@
expect(result.stdout, contains('1 issue found.'));
});
- test('two errors', () {
+ test('two errors', () async {
p = project(mainSrc: "int get foo => 'str';\nint get bar => 'str';\n");
- var result = p.runSync(['analyze', p.dirPath]);
+ var result = await p.run(['analyze', p.dirPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -284,18 +284,18 @@
});
group('single file', () {
- test('no errors', () {
+ test('no errors', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['analyze', p.mainPath]);
+ var result = await p.run(['analyze', p.mainPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('No issues found!'));
});
- test('one error', () {
+ test('one error', () async {
p = project(mainSrc: "int get foo => 'str';\n");
- var result = p.runSync(['analyze', p.mainPath]);
+ var result = await p.run(['analyze', p.mainPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -306,65 +306,65 @@
});
});
- test('warning --fatal-warnings', () {
+ test('warning --fatal-warnings', () async {
p = project(
mainSrc: _unusedImportCodeSnippet,
analysisOptions: _unusedImportAnalysisOptions);
- var result = p.runSync(['analyze', '--fatal-warnings', p.dirPath]);
+ var result = await p.run(['analyze', '--fatal-warnings', p.dirPath]);
expect(result.exitCode, equals(2));
expect(result.stderr, isEmpty);
expect(result.stdout, contains('1 issue found.'));
});
- test('warning implicit --fatal-warnings', () {
+ test('warning implicit --fatal-warnings', () async {
p = project(
mainSrc: _unusedImportCodeSnippet,
analysisOptions: _unusedImportAnalysisOptions);
- var result = p.runSync(['analyze', p.dirPath]);
+ var result = await p.run(['analyze', p.dirPath]);
expect(result.exitCode, equals(2));
expect(result.stderr, isEmpty);
expect(result.stdout, contains('1 issue found.'));
});
- test('warning --no-fatal-warnings', () {
+ test('warning --no-fatal-warnings', () async {
p = project(
mainSrc: _unusedImportCodeSnippet,
analysisOptions: _unusedImportAnalysisOptions);
- var result = p.runSync(['analyze', '--no-fatal-warnings', p.dirPath]);
+ var result = await p.run(['analyze', '--no-fatal-warnings', p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('1 issue found.'));
});
- test('info implicit no --fatal-infos', () {
+ test('info implicit no --fatal-infos', () async {
p = project(mainSrc: dartVersionFilePrefix2_9 + 'String foo() {}');
- var result = p.runSync(['analyze', p.dirPath]);
+ var result = await p.run(['analyze', p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('1 issue found.'));
});
- test('info --fatal-infos', () {
+ test('info --fatal-infos', () async {
p = project(mainSrc: dartVersionFilePrefix2_9 + 'String foo() {}');
- var result = p.runSync(['analyze', '--fatal-infos', p.dirPath]);
+ var result = await p.run(['analyze', '--fatal-infos', p.dirPath]);
expect(result.exitCode, 1);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('1 issue found.'));
});
- test('--verbose', () {
+ test('--verbose', () async {
p = project(mainSrc: '''
int f() {
var result = one + 2;
var one = 1;
return result;
}''');
- var result = p.runSync(['analyze', '--verbose', p.dirPath]);
+ var result = await p.run(['analyze', '--verbose', p.dirPath]);
expect(result.exitCode, 3);
expect(result.stderr, isEmpty);
@@ -377,7 +377,7 @@
});
group('--packages', () {
- test('existing', () {
+ test('existing', () async {
final foo = project(name: 'foo');
foo.file('lib/foo.dart', 'var my_foo = 0;');
@@ -399,7 +399,7 @@
]
}
''');
- var result = p.runSync([
+ var result = await p.run([
'analyze',
'--packages=${p.findFile('my_packages.json').path}',
p.dirPath,
@@ -410,9 +410,9 @@
expect(result.stdout, contains('No issues found!'));
});
- test('not existing', () {
+ test('not existing', () async {
p = project();
- var result = p.runSync([
+ var result = await p.run([
'analyze',
'--packages=no.such.file',
p.dirPath,
@@ -424,11 +424,11 @@
});
});
- test('--cache', () {
+ test('--cache', () async {
var cache = project(name: 'cache');
p = project(mainSrc: 'var v = 0;');
- var result = p.runSync([
+ var result = await p.run([
'analyze',
'--cache=${cache.dirPath}',
p.mainPath,
diff --git a/pkg/dartdev/test/commands/compile_test.dart b/pkg/dartdev/test/commands/compile_test.dart
index be43ac7..2facc8c 100644
--- a/pkg/dartdev/test/commands/compile_test.dart
+++ b/pkg/dartdev/test/commands/compile_test.dart
@@ -29,9 +29,9 @@
expect(binDir.path, contains('bin'));
});
- test('Implicit --help', () {
+ test('Implicit --help', () async {
final p = project();
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
],
@@ -40,9 +40,9 @@
expect(result.exitCode, compileErrorExitCode);
});
- test('--help', () {
+ test('--help', () async {
final p = project();
- final result = p.runSync(
+ final result = await p.run(
['compile', '--help'],
);
expect(result.stdout, contains('Compile Dart'));
@@ -61,9 +61,9 @@
expect(result.exitCode, 0);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
final p = project();
- final result = p.runSync(
+ final result = await p.run(
['compile', '--help', '--verbose'],
);
expect(result.stdout, contains('Compile Dart'));
@@ -76,10 +76,10 @@
expect(result.exitCode, 0);
});
- test('Compile and run jit snapshot', () {
+ test('Compile and run jit snapshot', () async {
final p = project(mainSrc: 'void main() { print("I love jit"); }');
final outFile = path.join(p.dirPath, 'main.jit');
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -93,18 +93,18 @@
expect(File(outFile).existsSync(), true,
reason: 'File not found: $outFile');
- result = p.runSync(['run', 'main.jit']);
+ result = await p.run(['run', 'main.jit']);
expect(result.stdout, contains('I love jit'));
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
});
- test('Compile and run executable', () {
+ test('Compile and run executable', () async {
final p = project(mainSrc: 'void main() { print("I love executables"); }');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'lib', 'main.exe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -127,11 +127,11 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile to executable disabled on IA32', () {
+ test('Compile to executable disabled on IA32', () async {
final p = project(mainSrc: 'void main() { print("I love executables"); }');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -144,11 +144,11 @@
expect(result.exitCode, 64);
}, skip: !isRunningOnIA32);
- test('Compile to AOT snapshot disabled on IA32', () {
+ test('Compile to AOT snapshot disabled on IA32', () async {
final p = project(mainSrc: 'void main() { print("I love executables"); }');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -161,13 +161,13 @@
expect(result.exitCode, 64);
}, skip: !isRunningOnIA32);
- test('Compile and run executable with options', () {
+ test('Compile and run executable with options', () async {
final p = project(
mainSrc: 'void main() {print(const String.fromEnvironment("life"));}');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -194,12 +194,12 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile and run aot snapshot', () {
+ test('Compile and run aot snapshot', () async {
final p = project(mainSrc: 'void main() { print("I love AOT"); }');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'main.aot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -225,10 +225,10 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile and run kernel snapshot', () {
+ test('Compile and run kernel snapshot', () async {
final p = project(mainSrc: 'void main() { print("I love kernel"); }');
final outFile = path.join(p.dirPath, 'main.dill');
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -242,13 +242,13 @@
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
- result = p.runSync(['run', 'main.dill']);
+ result = await p.run(['run', 'main.dill']);
expect(result.stdout, contains('I love kernel'));
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
});
- test('Compile JS', () {
+ test('Compile JS', () async {
final p = project(mainSrc: '''
void main() {
print('1: ' + const String.fromEnvironment('foo'));
@@ -257,7 +257,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'main.js'));
- final result = p.runSync([
+ final result = await p.run([
'compile',
'js',
'-m',
@@ -279,7 +279,7 @@
expect(contents.contains('2: foo'), true);
});
- test('Compile exe with error', () {
+ test('Compile exe with error', () async {
final p = project(mainSrc: '''
void main() {
int? i;
@@ -289,7 +289,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -309,7 +309,7 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile exe with warnings', () {
+ test('Compile exe with warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -319,7 +319,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -336,12 +336,12 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile exe with sound null safety', () {
+ test('Compile exe with sound null safety', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -358,7 +358,7 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile exe with unsound null safety', () {
+ test('Compile exe with unsound null safety', () async {
final p = project(mainSrc: '''
// @dart=2.9
void main() {}
@@ -366,7 +366,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -383,14 +383,14 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile and run exe with --sound-null-safety', () {
+ test('Compile and run exe with --sound-null-safety', () async {
final p = project(mainSrc: '''void main() {
print((<int?>[] is List<int>) ? 'oh no' : 'sound');
}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -417,14 +417,14 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile and run exe with --no-sound-null-safety', () {
+ test('Compile and run exe with --no-sound-null-safety', () async {
final p = project(mainSrc: '''void main() {
print((<int?>[] is List<int>) ? 'unsound' : 'oh no');
}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -451,12 +451,12 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile exe without info', () {
+ test('Compile exe without info', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -475,7 +475,7 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile exe without warnings', () {
+ test('Compile exe without warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -485,7 +485,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'exe',
@@ -502,12 +502,12 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile JS with sound null safety', () {
+ test('Compile JS with sound null safety', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjs'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'js',
@@ -524,7 +524,7 @@
reason: 'File not found: $outFile');
});
- test('Compile JS with unsound null safety', () {
+ test('Compile JS with unsound null safety', () async {
final p = project(mainSrc: '''
// @dart=2.9
void main() {}
@@ -532,7 +532,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjs'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'js',
@@ -549,12 +549,12 @@
reason: 'File not found: $outFile');
});
- test('Compile JS without info', () {
+ test('Compile JS without info', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjs'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'js',
@@ -573,7 +573,7 @@
reason: 'File not found: $outFile');
});
- test('Compile JS without warnings', () {
+ test('Compile JS without warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -583,7 +583,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjs'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'js',
@@ -600,12 +600,12 @@
expect(result.exitCode, 0);
});
- test('Compile AOT snapshot with sound null safety', () {
+ test('Compile AOT snapshot with sound null safety', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myaot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -622,7 +622,7 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile AOT snapshot with unsound null safety', () {
+ test('Compile AOT snapshot with unsound null safety', () async {
final p = project(mainSrc: '''
// @dart=2.9
void main() {}
@@ -630,7 +630,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myaot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -647,12 +647,12 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile AOT snapshot without info', () {
+ test('Compile AOT snapshot without info', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myaot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -671,7 +671,7 @@
reason: 'File not found: $outFile');
}, skip: isRunningOnIA32);
- test('Compile AOT snapshot without warnings', () {
+ test('Compile AOT snapshot without warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -681,7 +681,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myaot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -698,7 +698,7 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile AOT snapshot with warnings', () {
+ test('Compile AOT snapshot with warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -708,7 +708,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myaot'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'aot-snapshot',
@@ -726,12 +726,12 @@
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
- test('Compile kernel with invalid trailing argument', () {
+ test('Compile kernel with invalid trailing argument', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -754,12 +754,12 @@
expect(File(outFile).existsSync(), false, reason: 'File found: $outFile');
});
- test('Compile kernel with sound null safety', () {
+ test('Compile kernel with sound null safety', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -776,7 +776,7 @@
reason: 'File not found: $outFile');
});
- test('Compile kernel with unsound null safety', () {
+ test('Compile kernel with unsound null safety', () async {
final p = project(mainSrc: '''
// @dart=2.9
void main() {}
@@ -784,7 +784,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -801,12 +801,12 @@
reason: 'File not found: $outFile');
});
- test('Compile kernel without info', () {
+ test('Compile kernel without info', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -825,7 +825,7 @@
reason: 'File not found: $outFile');
});
- test('Compile kernel without warning', () {
+ test('Compile kernel without warning', () async {
final p = project(mainSrc: '''
void main() {
int i;
@@ -834,7 +834,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -851,7 +851,7 @@
expect(result.exitCode, 254);
});
- test('Compile kernel with warnings', () {
+ test('Compile kernel with warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -860,7 +860,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'mydill'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'kernel',
@@ -877,12 +877,12 @@
expect(result.exitCode, 0);
});
- test('Compile JIT snapshot with sound null safety', () {
+ test('Compile JIT snapshot with sound null safety', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -899,7 +899,7 @@
reason: 'File not found: $outFile');
});
- test('Compile JIT snapshot with unsound null safety', () {
+ test('Compile JIT snapshot with unsound null safety', () async {
final p = project(mainSrc: '''
// @dart=2.9
void main() {}
@@ -907,7 +907,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -924,13 +924,13 @@
reason: 'File not found: $outFile');
});
- test('Compile JIT snapshot with training args', () {
+ test('Compile JIT snapshot with training args', () async {
final p =
project(mainSrc: '''void main(List<String> args) => print(args);''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -948,12 +948,12 @@
reason: 'File not found: $outFile');
});
- test('Compile JIT snapshot without info', () {
+ test('Compile JIT snapshot without info', () async {
final p = project(mainSrc: '''void main() {}''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -972,7 +972,7 @@
reason: 'File not found: $outFile');
});
- test('Compile JIT snapshot without warnings', () {
+ test('Compile JIT snapshot without warnings', () async {
final p = project(mainSrc: '''
void main() {
int i;
@@ -981,7 +981,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
@@ -998,7 +998,7 @@
expect(result.exitCode, 254);
});
- test('Compile JIT snapshot with warnings', () {
+ test('Compile JIT snapshot with warnings', () async {
final p = project(mainSrc: '''
void main() {
int i = 0;
@@ -1007,7 +1007,7 @@
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
- var result = p.runSync(
+ var result = await p.run(
[
'compile',
'jit-snapshot',
diff --git a/pkg/dartdev/test/commands/create_integration_test.dart b/pkg/dartdev/test/commands/create_integration_test.dart
index 8bc1066..e4363a4 100644
--- a/pkg/dartdev/test/commands/create_integration_test.dart
+++ b/pkg/dartdev/test/commands/create_integration_test.dart
@@ -22,10 +22,10 @@
// Create tests for each template.
for (String templateId in CreateCommand.legalTemplateIds) {
- test(templateId, () {
+ test(templateId, () async {
p = project();
- ProcessResult createResult = p.runSync([
+ ProcessResult createResult = await p.run([
'create',
'--force',
'--template',
@@ -37,11 +37,11 @@
// Validate that the project analyzes cleanly.
// TODO: Should we use --fatal-infos here?
ProcessResult analyzeResult =
- p.runSync(['analyze'], workingDir: p.dir.path);
+ await p.run(['analyze'], workingDir: p.dir.path);
expect(analyzeResult.exitCode, 0, reason: analyzeResult.stdout);
// Validate that the code is well formatted.
- ProcessResult formatResult = p.runSync([
+ ProcessResult formatResult = await p.run([
'format',
'--output',
'none',
diff --git a/pkg/dartdev/test/commands/create_test.dart b/pkg/dartdev/test/commands/create_test.dart
index 5af3323..6978d98 100644
--- a/pkg/dartdev/test/commands/create_test.dart
+++ b/pkg/dartdev/test/commands/create_test.dart
@@ -23,9 +23,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['create', '--help']);
+ var result = await p.run(['create', '--help']);
expect(result.stdout, contains('Create a new Dart project.'));
expect(
@@ -38,9 +38,9 @@
expect(result.exitCode, 0);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['create', '--help', '--verbose']);
+ var result = await p.run(['create', '--help', '--verbose']);
expect(result.stdout, contains('Create a new Dart project.'));
expect(
@@ -53,21 +53,21 @@
expect(result.exitCode, 0);
});
- test('default template exists', () {
+ test('default template exists', () async {
expect(CreateCommand.legalTemplateIds,
contains(CreateCommand.defaultTemplateId));
});
- test('all templates exist', () {
+ test('all templates exist', () async {
for (String templateId in CreateCommand.legalTemplateIds) {
expect(CreateCommand.legalTemplateIds, contains(templateId));
}
});
- test('list templates', () {
+ test('list templates', () async {
p = project();
- ProcessResult result = p.runSync(['create', '--list-templates']);
+ ProcessResult result = await p.run(['create', '--list-templates']);
expect(result.exitCode, 0);
String output = result.stdout.toString();
@@ -78,27 +78,27 @@
expect(parsedResult[0]['description'], isNotNull);
});
- test('no directory given', () {
+ test('no directory given', () async {
p = project();
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'create',
]);
expect(result.exitCode, 1);
});
- test('directory already exists', () {
+ test('directory already exists', () async {
p = project();
- ProcessResult result = p.runSync(
+ ProcessResult result = await p.run(
['create', '--template', CreateCommand.defaultTemplateId, p.dir.path]);
expect(result.exitCode, 73);
});
- test('project in current directory', () {
+ test('project in current directory', () async {
p = project();
final projectDir = Directory('foo')..createSync();
- final result = p.runSync(
+ final result = await p.run(
['create', '--force', '.'],
workingDir: projectDir.path,
);
@@ -107,9 +107,9 @@
expect(result.exitCode, 0);
});
- test('project with normalized package name', () {
+ test('project with normalized package name', () async {
p = project();
- final result = p.runSync(['create', 'requires-normalization']);
+ final result = await p.run(['create', 'requires-normalization']);
expect(result.stderr, isEmpty);
expect(
result.stdout,
@@ -118,9 +118,9 @@
expect(result.exitCode, 0);
});
- test('project with an invalid package name', () {
+ test('project with an invalid package name', () async {
p = project();
- final result = p.runSync(['create', 'bad-package^name']);
+ final result = await p.run(['create', 'bad-package^name']);
expect(
result.stderr,
contains(
@@ -131,20 +131,20 @@
expect(result.exitCode, 73);
});
- test('bad template id', () {
+ test('bad template id', () async {
p = project();
- ProcessResult result =
- p.runSync(['create', '--no-pub', '--template', 'foo-bar', p.dir.path]);
+ ProcessResult result = await p
+ .run(['create', '--no-pub', '--template', 'foo-bar', p.dir.path]);
expect(result.exitCode, isNot(0));
});
// Create tests for each template.
for (String templateId in CreateCommand.legalTemplateIds) {
- test(templateId, () {
+ test(templateId, () async {
p = project();
const projectName = 'template_project';
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'create',
'--force',
'--no-pub',
diff --git a/pkg/dartdev/test/commands/debug_adapter_test.dart b/pkg/dartdev/test/commands/debug_adapter_test.dart
index c21f476..00a7e8c 100644
--- a/pkg/dartdev/test/commands/debug_adapter_test.dart
+++ b/pkg/dartdev/test/commands/debug_adapter_test.dart
@@ -13,9 +13,9 @@
void debugAdapter() {
// Implementation of debug_adapter is tested in the DDS package where the
// DAP implementation lives.
- test('--help', () {
+ test('--help', () async {
final p = project();
- var result = p.runSync(['debug_adapter', '--help']);
+ var result = await p.run(['debug_adapter', '--help']);
expect(
result.stdout,
diff --git a/pkg/dartdev/test/commands/devtools_test.dart b/pkg/dartdev/test/commands/devtools_test.dart
index 37bc32e..656b8c6 100644
--- a/pkg/dartdev/test/commands/devtools_test.dart
+++ b/pkg/dartdev/test/commands/devtools_test.dart
@@ -18,9 +18,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['devtools', '--help']);
+ var result = await p.run(['devtools', '--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Open DevTools'));
@@ -31,9 +31,9 @@
expect(result.stdout.contains('--try-ports'), isFalse);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['devtools', '--help', '--verbose']);
+ var result = await p.run(['devtools', '--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Open DevTools'));
diff --git a/pkg/dartdev/test/commands/fix_test.dart b/pkg/dartdev/test/commands/fix_test.dart
index 97cddf9..036eb7d 100644
--- a/pkg/dartdev/test/commands/fix_test.dart
+++ b/pkg/dartdev/test/commands/fix_test.dart
@@ -52,18 +52,18 @@
''');
}
- ProcessResult runFix(List<String> args, {String workingDir}) {
+ Future<ProcessResult> runFix(List<String> args, {String workingDir}) async {
if (runFromSource) {
var binary = path.join(Directory.current.path, 'bin', 'dartdev.dart');
- return p.runSync([binary, 'fix', ...?args], workingDir: workingDir);
+ return await p.run([binary, 'fix', ...?args], workingDir: workingDir);
}
- return p.runSync(['fix', ...args], workingDir: workingDir);
+ return await p.run(['fix', ...args], workingDir: workingDir);
}
- test('--help', () {
+ test('--help', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = runFix([p.dirPath, '--help']);
+ var result = await runFix([p.dirPath, '--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -76,10 +76,10 @@
expect(result.stdout, contains('Usage: dart fix [arguments]'));
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = runFix([p.dirPath, '--help', '--verbose']);
+ var result = await runFix([p.dirPath, '--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -95,10 +95,10 @@
);
});
- test('none', () {
+ test('none', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = runFix([p.dirPath]);
+ var result = await runFix([p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -106,17 +106,17 @@
result.stdout, contains('Apply automated fixes to Dart source code.'));
});
- test('--apply (none)', () {
+ test('--apply (none)', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = runFix(['--apply', p.dirPath]);
+ var result = await runFix(['--apply', p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Nothing to fix!'));
});
- test('--apply (no args)', () {
+ test('--apply (no args)', () async {
p = project(
mainSrc: '''
var x = "";
@@ -128,7 +128,7 @@
''',
);
- var result = runFix(['--apply'], workingDir: p.dirPath);
+ var result = await runFix(['--apply'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(
@@ -140,7 +140,7 @@
]));
});
- test('--dry-run', () {
+ test('--dry-run', () async {
p = project(
mainSrc: '''
class A {
@@ -158,7 +158,7 @@
- prefer_single_quotes
''',
);
- var result = runFix(['--dry-run', '.'], workingDir: p.dirPath);
+ var result = await runFix(['--dry-run', '.'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(
@@ -171,7 +171,7 @@
]));
});
- test('--apply (.)', () {
+ test('--apply (.)', () async {
p = project(
mainSrc: '''
var x = "";
@@ -182,7 +182,7 @@
- prefer_single_quotes
''',
);
- var result = runFix(['--apply', '.'], workingDir: p.dirPath);
+ var result = await runFix(['--apply', '.'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(
@@ -195,7 +195,7 @@
]));
});
- test('--apply (excludes)', () {
+ test('--apply (excludes)', () async {
p = project(
mainSrc: '''
var x = "";
@@ -209,13 +209,13 @@
- prefer_single_quotes
''',
);
- var result = runFix(['--apply', '.'], workingDir: p.dirPath);
+ var result = await runFix(['--apply', '.'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Nothing to fix!'));
});
- test('--apply (ignores)', () {
+ test('--apply (ignores)', () async {
p = project(
mainSrc: '''
// ignore: prefer_single_quotes
@@ -227,14 +227,14 @@
- prefer_single_quotes
''',
);
- var result = runFix(['--apply', '.'], workingDir: p.dirPath);
+ var result = await runFix(['--apply', '.'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Nothing to fix!'));
});
group('compare-to-golden', () {
- test('applied fixes do not match expected', () {
+ test('applied fixes do not match expected', () async {
p = project(
mainSrc: '''
class A {
@@ -261,11 +261,12 @@
String a() => '';
}
''');
- result = runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
+ result =
+ await runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
assertResult(exitCode: 1);
});
- test('applied fixes match expected', () {
+ test('applied fixes match expected', () async {
p = project(
mainSrc: '''
class A {
@@ -293,11 +294,12 @@
String a() => '';
}
''');
- result = runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
+ result =
+ await runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
assertResult();
});
- test('missing expect', () {
+ test('missing expect', () async {
p = project(
mainSrc: '''
class A {
@@ -315,11 +317,12 @@
- prefer_single_quotes
''',
);
- result = runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
+ result =
+ await runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
assertResult(exitCode: 1);
});
- test('missing original', () {
+ test('missing original', () async {
p = project(mainSrc: '''
class C {}
''');
@@ -329,11 +332,12 @@
p.file('lib/secondary.dart.expect', '''
class A {}
''');
- result = runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
+ result =
+ await runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
assertResult(exitCode: 1);
});
- test('no fixes to apply does not match expected', () {
+ test('no fixes to apply does not match expected', () async {
p = project(
mainSrc: '''
class A {
@@ -351,7 +355,8 @@
String a() => '';
}
''');
- result = runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
+ result =
+ await runFix(['--compare-to-golden', '.'], workingDir: p.dirPath);
assertResult(exitCode: 1);
});
});
diff --git a/pkg/dartdev/test/commands/flag_test.dart b/pkg/dartdev/test/commands/flag_test.dart
index da055db..b5aa76e 100644
--- a/pkg/dartdev/test/commands/flag_test.dart
+++ b/pkg/dartdev/test/commands/flag_test.dart
@@ -59,9 +59,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['--help']);
+ var result = await p.run(['--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -77,9 +77,9 @@
expect(result.stdout, contains('migrate '));
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['--help', '--verbose']);
+ var result = await p.run(['--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -87,9 +87,9 @@
contains('The following options are only used for VM development'));
});
- test('--help -v', () {
+ test('--help -v', () async {
p = project();
- var result = p.runSync(['--help', '-v']);
+ var result = await p.run(['--help', '-v']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -97,25 +97,26 @@
contains('The following options are only used for VM development'));
});
- test('print Dart CLI help on usage error', () {
+ test('print Dart CLI help on usage error', () async {
p = project();
- var result = p.runSync(['---help']);
+ var result = await p.run(['---help']);
expect(result.exitCode, 255);
expect(result.stdout, contains(DartdevRunner.dartdevDescription));
expect(result.stderr, isEmpty);
});
- test('print VM help on usage error when --disable-dart-dev is provided', () {
+ test('print VM help on usage error when --disable-dart-dev is provided',
+ () async {
p = project();
- var result = p.runSync(['---help', '--disable-dart-dev']);
+ var result = await p.run(['---help', '--disable-dart-dev']);
expect(result.exitCode, 255);
expect(result.stdout, isNot(contains(DartdevRunner.dartdevDescription)));
expect(result.stderr, isEmpty);
});
- test('help', () {
+ test('help', () async {
p = project();
- var result = p.runSync(['help']);
+ var result = await p.run(['help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -131,9 +132,9 @@
expect(result.stdout, contains('migrate '));
});
- test('help --verbose', () {
+ test('help --verbose', () async {
p = project();
- var result = p.runSync(['help', '--verbose']);
+ var result = await p.run(['help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stdout,
@@ -141,9 +142,9 @@
expect(result.stdout, contains('migrate '));
});
- test('help -v', () {
+ test('help -v', () async {
p = project();
- var result = p.runSync(['help', '-v']);
+ var result = await p.run(['help', '-v']);
expect(result.exitCode, 0);
expect(result.stdout,
diff --git a/pkg/dartdev/test/commands/format_test.dart b/pkg/dartdev/test/commands/format_test.dart
index 568f3ce..5331c6d 100644
--- a/pkg/dartdev/test/commands/format_test.dart
+++ b/pkg/dartdev/test/commands/format_test.dart
@@ -18,9 +18,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['format', '--help']);
+ var result = await p.run(['format', '--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Idiomatically format Dart source code.'));
@@ -31,9 +31,9 @@
expect(result.stdout.contains('--stdin-name'), isFalse);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['format', '--help', '--verbose']);
+ var result = await p.run(['format', '--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Idiomatically format Dart source code.'));
@@ -44,17 +44,17 @@
expect(result.stdout, contains('--stdin-name'));
});
- test('unchanged', () {
+ test('unchanged', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- ProcessResult result = p.runSync(['format', p.relativeFilePath]);
+ ProcessResult result = await p.run(['format', p.relativeFilePath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, startsWith('Formatted 1 file (0 changed) in '));
});
- test('formatted', () {
+ test('formatted', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- ProcessResult result = p.runSync(['format', p.relativeFilePath]);
+ ProcessResult result = await p.run(['format', p.relativeFilePath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(
@@ -63,9 +63,9 @@
'Formatted lib/main.dart\nFormatted 1 file (1 changed) in '));
});
- test('formatted with exit code set', () {
+ test('formatted with exit code set', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'format',
'--set-exit-if-changed',
p.relativeFilePath,
@@ -78,9 +78,9 @@
'Formatted lib/main.dart\nFormatted 1 file (1 changed) in '));
});
- test('not formatted with exit code set', () {
+ test('not formatted with exit code set', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'format',
'--set-exit-if-changed',
p.relativeFilePath,
@@ -90,10 +90,10 @@
expect(result.stdout, startsWith('Formatted 1 file (0 changed) in '));
});
- test('unknown file', () {
+ test('unknown file', () async {
p = project(mainSrc: 'int get foo => 1;\n');
var unknownFilePath = '${p.relativeFilePath}-unknown-file.dart';
- ProcessResult result = p.runSync(['format', unknownFilePath]);
+ ProcessResult result = await p.run(['format', unknownFilePath]);
expect(result.exitCode, 0);
expect(result.stderr,
startsWith('No file or directory found at "$unknownFilePath".'));
diff --git a/pkg/dartdev/test/commands/help_test.dart b/pkg/dartdev/test/commands/help_test.dart
index 09c3c41..2202b56 100644
--- a/pkg/dartdev/test/commands/help_test.dart
+++ b/pkg/dartdev/test/commands/help_test.dart
@@ -26,10 +26,10 @@
.commands
.forEach((String commandKey, Command command) {
if (!_commandsNotTested.contains(commandKey)) {
- test('(help $commandKey == $commandKey --help)', () {
+ test('(help $commandKey == $commandKey --help)', () async {
p = project();
- var result = p.runSync(['help', commandKey]);
- var verbHelpResult = p.runSync([commandKey, '--help']);
+ var result = await p.run(['help', commandKey]);
+ var verbHelpResult = await p.run([commandKey, '--help']);
expect(result.stdout, contains(verbHelpResult.stdout));
expect(result.stderr, contains(verbHelpResult.stderr));
@@ -37,20 +37,20 @@
}
});
- test('(help test ~= test --help) outside project', () {
+ test('(help test ~= test --help) outside project', () async {
p = project();
p.deleteFile('pubspec.yaml');
- var result = p.runSync(['help', 'test']);
- var testHelpResult = p.runSync(['test', '--help']);
+ var result = await p.run(['help', 'test']);
+ var testHelpResult = await p.run(['test', '--help']);
expect(testHelpResult.stdout, contains(result.stdout));
expect(testHelpResult.stderr, contains(result.stderr));
});
- test('(help pub == pub --help)', () {
+ test('(help pub == pub --help)', () async {
p = project();
- var result = p.runSync(['help', 'pub']);
- var pubHelpResult = p.runSync(['pub', '--help']);
+ var result = await p.run(['help', 'pub']);
+ var pubHelpResult = await p.run(['pub', '--help']);
expect(result.stdout, contains(pubHelpResult.stdout));
expect(result.stderr, contains(pubHelpResult.stderr));
diff --git a/pkg/dartdev/test/commands/migrate_test.dart b/pkg/dartdev/test/commands/migrate_test.dart
index 94795be..68475ee 100644
--- a/pkg/dartdev/test/commands/migrate_test.dart
+++ b/pkg/dartdev/test/commands/migrate_test.dart
@@ -19,9 +19,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['migrate', '--help']);
+ var result = await p.run(['migrate', '--help']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -35,9 +35,9 @@
);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['migrate', '--help', '--verbose']);
+ var result = await p.run(['migrate', '--help', '--verbose']);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
@@ -53,43 +53,43 @@
);
});
- test('directory implicit', () {
+ test('directory implicit', () async {
p = project(mainSrc: dartVersionFilePrefix2_9 + 'int get foo => 1;\n');
var result =
- p.runSync(['migrate', '--no-web-preview'], workingDir: p.dirPath);
+ await p.run(['migrate', '--no-web-preview'], workingDir: p.dirPath);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Generating migration suggestions'));
});
- test('directory explicit', () {
+ test('directory explicit', () async {
p = project(mainSrc: dartVersionFilePrefix2_9 + 'int get foo => 1;\n');
- var result = p.runSync(['migrate', '--no-web-preview', p.dirPath]);
+ var result = await p.run(['migrate', '--no-web-preview', p.dirPath]);
expect(result.exitCode, 0);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Generating migration suggestions'));
});
- test('bad directory', () {
+ test('bad directory', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['migrate', 'foo_bar_dir']);
+ var result = await p.run(['migrate', 'foo_bar_dir']);
expect(result.exitCode, 1);
expect(result.stderr, contains('foo_bar_dir does not exist'));
expect(result.stdout, isEmpty);
});
- test('pub get needs running', () {
+ test('pub get needs running', () async {
p = project(mainSrc: 'import "package:foo/foo.dart";\n');
- var result = p.runSync(['migrate', p.dirPath]);
+ var result = await p.run(['migrate', p.dirPath]);
expect(result.exitCode, 1);
expect(result.stderr, isEmpty);
expect(result.stdout, runPubGet);
expect(result.stdout, isNot(setLowerSdkConstraint));
});
- test('non-pub-related error', () {
+ test('non-pub-related error', () async {
p = project(mainSrc: 'var missing = "semicolon"\n');
- var result = p.runSync(['migrate', p.dirPath]);
+ var result = await p.run(['migrate', p.dirPath]);
expect(result.exitCode, 1);
expect(result.stderr, isEmpty);
expect(result.stdout, runPubGet);
diff --git a/pkg/dartdev/test/commands/pub_test.dart b/pkg/dartdev/test/commands/pub_test.dart
index ab5b715..2eafe5e 100644
--- a/pkg/dartdev/test/commands/pub_test.dart
+++ b/pkg/dartdev/test/commands/pub_test.dart
@@ -25,8 +25,8 @@
expect(result.stderr, isEmpty);
}
- test('implicit --help', () {
- final result = project().runSync(['pub']);
+ test('implicit --help', () async {
+ final result = await project().run(['pub']);
expect(result, isNotNull);
expect(result.exitCode, 64);
expect(result.stderr, contains('Missing subcommand for "dart pub".'));
@@ -34,18 +34,18 @@
expect(result.stdout, isEmpty);
});
- test('--help', () {
- _assertPubHelpInvoked(project().runSync(['pub', '--help']));
+ test('--help', () async {
+ _assertPubHelpInvoked(await project().run(['pub', '--help']));
});
- test('-h', () {
- _assertPubHelpInvoked(project().runSync(['pub', '-h']));
+ test('-h', () async {
+ _assertPubHelpInvoked(await project().run(['pub', '-h']));
});
- test('help cache', () {
+ test('help cache', () async {
p = project();
- var result = p.runSync(['help', 'pub', 'cache']);
- var result2 = p.runSync(['pub', 'cache', '--help']);
+ var result = await p.run(['help', 'pub', 'cache']);
+ var result2 = await p.run(['pub', 'cache', '--help']);
expect(result.exitCode, 0);
@@ -56,10 +56,10 @@
expect(result.stderr, result2.stderr);
});
- test('help publish', () {
+ test('help publish', () async {
p = project();
- var result = p.runSync(['help', 'pub', 'publish']);
- var result2 = p.runSync(['pub', 'publish', '--help']);
+ var result = await p.run(['help', 'pub', 'publish']);
+ var result2 = await p.run(['pub', 'publish', '--help']);
expect(result.exitCode, 0);
@@ -71,17 +71,17 @@
expect(result.stderr, result2.stderr);
});
- test('failure', () {
+ test('failure', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['pub', 'deps']);
+ var result = await p.run(['pub', 'deps']);
expect(result.exitCode, 65);
expect(result.stdout, isEmpty);
expect(result.stderr, contains('No pubspec.lock file found'));
});
- test('failure unknown option', () {
+ test('failure unknown option', () async {
p = project(mainSrc: 'int get foo => 1;\n');
- var result = p.runSync(['pub', 'deps', '--foo']);
+ var result = await p.run(['pub', 'deps', '--foo']);
expect(result.exitCode, 64);
expect(result.stdout, isEmpty);
expect(result.stderr, startsWith('Could not find an option named "foo".'));
diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart
index 613a508..1e9b3e0 100644
--- a/pkg/dartdev/test/commands/run_test.dart
+++ b/pkg/dartdev/test/commands/run_test.dart
@@ -25,9 +25,9 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- var result = p.runSync(['run', '--help']);
+ var result = await p.run(['run', '--help']);
expect(result.stdout, contains('Run a Dart program.'));
expect(result.stdout, contains('Debugging options:'));
@@ -41,9 +41,9 @@
expect(result.exitCode, 0);
});
- test('--help --verbose', () {
+ test('--help --verbose', () async {
p = project();
- var result = p.runSync(['run', '--help', '--verbose']);
+ var result = await p.run(['run', '--help', '--verbose']);
expect(result.stdout, contains('Run a Dart program.'));
expect(result.stdout, contains('Debugging options:'));
@@ -57,30 +57,30 @@
expect(result.exitCode, 0);
});
- test("'Hello World'", () {
+ test("'Hello World'", () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync(['run', p.relativeFilePath]);
+ ProcessResult result = await p.run(['run', p.relativeFilePath]);
expect(result.stdout, contains('Hello World'));
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
});
- test('no such file', () {
+ test('no such file', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
ProcessResult result =
- p.runSync(['run', 'no/such/file/${p.relativeFilePath}']);
+ await p.run(['run', 'no/such/file/${p.relativeFilePath}']);
expect(result.stderr, isNotEmpty);
expect(result.exitCode, isNot(0));
});
- test('implicit packageName.dart', () {
+ test('implicit packageName.dart', () async {
// TODO(jwren) circle back to reimplement this test if possible, the file
// name (package name) will be the name of the temporary directory on disk
p = project(mainSrc: "void main() { print('Hello World'); }");
p.file('bin/main.dart', "void main() { print('Hello main.dart'); }");
- ProcessResult result = p.runSync(['run']);
+ ProcessResult result = await p.run(['run']);
expect(result.stdout, contains('Hello main.dart'));
expect(result.stderr, isEmpty);
@@ -88,10 +88,10 @@
}, skip: true);
// Could not find the implicit file to run: bin
- test('missing implicit packageName.dart', () {
+ test('missing implicit packageName.dart', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
p.file('bin/foo.dart', "void main() { print('Hello main.dart'); }");
- ProcessResult result = p.runSync(['run']);
+ ProcessResult result = await p.run(['run']);
expect(result.stdout, isEmpty);
expect(
@@ -101,10 +101,10 @@
expect(result.exitCode, 255);
});
- test('arguments are properly passed', () {
+ test('arguments are properly passed', () async {
p = project();
p.file('main.dart', 'void main(args) { print(args); }');
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--enable-experiment=test-experiment',
'main.dart',
@@ -118,7 +118,7 @@
expect(result.exitCode, 0);
});
- test('from path-dependency with cyclic dependency', () {
+ test('from path-dependency with cyclic dependency', () async {
p = project(name: 'foo');
final bar = TestProject(name: 'bar');
p.file('pubspec.yaml', '''
@@ -141,7 +141,7 @@
void main(List<String> args) => print("$b $args");
''');
- ProcessResult result = p.runSync(['run', 'bar:main', '--arg1', 'arg2']);
+ ProcessResult result = await p.run(['run', 'bar:main', '--arg1', 'arg2']);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('FOO BAR [--arg1, arg2]'));
@@ -156,7 +156,7 @@
p.file('main.dart', 'void main(args) { print(args); }');
// Test with absolute path
final name = path.join(p.dirPath, 'main.dart');
- final result = p.runSync([
+ final result = await p.run([
'run',
'--enable-experiment=test-experiment',
name,
@@ -175,7 +175,7 @@
p.file('main.dart', 'void main(args) { print(args); }');
// Test with File uri
final name = path.join(p.dirPath, 'main.dart');
- final result = p.runSync([
+ final result = await p.run([
'run',
Uri.file(name).toString(),
'--argument1',
@@ -199,7 +199,7 @@
//
// This test ensures that allowed arguments for dart run which are valid VM
// arguments are properly handled by the VM.
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--observe',
'--pause-isolates-on-start',
@@ -220,7 +220,7 @@
expect(result.exitCode, 0);
// Again, with --disable-service-auth-codes.
- result = p.runSync([
+ result = await p.run([
'run',
'--observe',
'--pause-isolates-on-start',
@@ -242,7 +242,7 @@
expect(result.exitCode, 0);
// Again, with IPv6.
- result = p.runSync([
+ result = await p.run([
'run',
'--observe=8181/::1',
'--pause-isolates-on-start',
@@ -269,7 +269,7 @@
// Any VM flags not listed under 'dart run help --verbose' should be passed
// before a dartdev command.
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--vm-name=foo',
p.relativeFilePath,
@@ -288,7 +288,7 @@
// Any VM flags not listed under 'dart run help --verbose' should be passed
// before a dartdev command.
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--verbose_gc',
p.relativeFilePath,
@@ -307,7 +307,7 @@
// Ensure --enable-asserts doesn't cause the dartdev isolate to fail to
// load. Regression test for: https://github.com/dart-lang/sdk/issues/42831
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--enable-asserts',
p.relativeFilePath,
@@ -322,7 +322,7 @@
p = project(mainSrc: 'void main() { assert(false); }');
// Any VM flags passed after the script shouldn't be interpreted by the VM.
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
p.relativeFilePath,
'--enable-asserts',
@@ -333,10 +333,10 @@
expect(result.exitCode, 0);
});
- test('without verbose CFE info', () {
+ test('without verbose CFE info', () async {
final p = project(mainSrc: '''void main() {}''');
- var result = p.runSync(
+ var result = await p.run(
[
'run',
'--verbosity=warning',
@@ -352,9 +352,9 @@
group('DDS', () {
group('disable', () {
- test('dart run simple', () {
+ test('dart run simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--no-dds',
'--enable-vm-service',
@@ -364,9 +364,9 @@
expect(result.stdout, contains(observatoryMessagePrefix));
});
- test('dart simple', () {
+ test('dart simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--no-dds',
'--enable-vm-service',
p.relativeFilePath,
@@ -377,9 +377,9 @@
});
group('explicit enable', () {
- test('dart run simple', () {
+ test('dart run simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--dds',
'--enable-vm-service',
@@ -389,9 +389,9 @@
expect(result.stdout, contains(observatoryMessagePrefix));
});
- test('dart simple', () {
+ test('dart simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--dds',
'--enable-vm-service',
p.relativeFilePath,
@@ -405,7 +405,7 @@
group('DevTools', () {
test('dart run simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--enable-vm-service',
p.relativeFilePath,
@@ -415,7 +415,7 @@
test('dart simple', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--enable-vm-service',
p.relativeFilePath,
]);
@@ -424,7 +424,7 @@
test('dart run explicit', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--serve-devtools',
'--enable-vm-service',
@@ -435,7 +435,7 @@
test('dart explicit', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--serve-devtools',
'--enable-vm-service',
p.relativeFilePath,
@@ -445,7 +445,7 @@
test('dart run disabled', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--enable-vm-service',
'--no-serve-devtools',
@@ -456,7 +456,7 @@
test('dart disabled', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--enable-vm-service',
'--no-serve-devtools',
p.relativeFilePath,
@@ -466,7 +466,7 @@
test('dart run VM service not enabled', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'run',
'--serve-devtools',
p.relativeFilePath,
@@ -476,7 +476,7 @@
test('dart VM service not enabled', () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
- ProcessResult result = p.runSync([
+ ProcessResult result = await p.run([
'--serve-devtools',
p.relativeFilePath,
]);
diff --git a/pkg/dartdev/test/commands/test_test.dart b/pkg/dartdev/test/commands/test_test.dart
index bda022bb..634d2b9 100644
--- a/pkg/dartdev/test/commands/test_test.dart
+++ b/pkg/dartdev/test/commands/test_test.dart
@@ -21,10 +21,10 @@
tearDown(() => p?.dispose());
- test('--help', () {
+ test('--help', () async {
p = project();
- final result = p.runSync(['test', '--help']);
+ final result = await p.run(['test', '--help']);
expect(result.exitCode, 0);
expect(result.stdout, startsWith('''
@@ -35,22 +35,22 @@
expect(result.stderr, isEmpty);
});
- test('dart help test', () {
+ test('dart help test', () async {
p = project();
- final result = p.runSync(['help', 'test']);
+ final result = await p.run(['help', 'test']);
expect(result.exitCode, 0);
expect(result.stdout, contains(' tests for a project'));
expect(result.stderr, isEmpty);
});
- test('no pubspec.yaml', () {
+ test('no pubspec.yaml', () async {
p = project();
var pubspec = File(path.join(p.dirPath, 'pubspec.yaml'));
pubspec.deleteSync();
- var result = p.runSync(['test']);
+ var result = await p.run(['test']);
expect(result.stderr, isEmpty);
expect(result.stdout, '''
@@ -58,7 +58,7 @@
''');
expect(result.exitCode, 65);
- var resultHelp = p.runSync(['test', '--help']);
+ var resultHelp = await p.run(['test', '--help']);
expect(resultHelp.stderr, isEmpty);
expect(resultHelp.stdout, '''
@@ -74,7 +74,7 @@
expect(resultHelp.exitCode, 65);
});
- test('runs test', () {
+ test('runs test', () async {
p = project();
p.file('test/foo_test.dart', '''
import 'package:test/test.dart';
@@ -87,13 +87,14 @@
''');
// An implicit `pub get` will happen.
- final result = p.runSync(['test', '--no-color', '--reporter', 'expanded']);
+ final result =
+ await p.run(['test', '--no-color', '--reporter', 'expanded']);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('All tests passed!'));
expect(result.exitCode, 0);
});
- test('no package:test dependency', () {
+ test('no package:test dependency', () async {
p = project(mainSrc: 'int get foo => 1;\n');
p.file('pubspec.yaml', '''
name: ${p.name}
@@ -110,7 +111,7 @@
}
''');
- final result = p.runSync(['test']);
+ final result = await p.run(['test']);
expect(result.exitCode, 65);
expect(
result.stdout,
@@ -119,16 +120,17 @@
expect(result.stderr, isEmpty);
expect(result.exitCode, 65);
- final resultPubAdd = p.runSync(['pub', 'add', 'test']);
+ final resultPubAdd = await p.run(['pub', 'add', 'test']);
expect(resultPubAdd.exitCode, 0);
- final result2 = p.runSync(['test', '--no-color', '--reporter', 'expanded']);
+ final result2 =
+ await p.run(['test', '--no-color', '--reporter', 'expanded']);
expect(result2.stderr, isEmpty);
expect(result2.stdout, contains('All tests passed!'));
expect(result2.exitCode, 0);
});
- test('has package:test dependency', () {
+ test('has package:test dependency', () async {
p = project(mainSrc: 'int get foo => 1;\n');
p.file('test/foo_test.dart', '''
$dartVersionFilePrefix2_9
@@ -142,15 +144,16 @@
}
''');
- final result = p.runSync(['test', '--no-color', '--reporter', 'expanded']);
+ final result =
+ await p.run(['test', '--no-color', '--reporter', 'expanded']);
expect(result.exitCode, 0);
expect(result.stdout, contains('All tests passed!'));
expect(result.stderr, isEmpty);
});
group('--enable-experiment', () {
- ProcessResult runTestWithExperimentFlag(String flag) {
- return p.runSync([
+ Future<ProcessResult> runTestWithExperimentFlag(String flag) async {
+ return await p.run([
if (flag != null) flag,
'test',
'--no-color',
@@ -159,21 +162,21 @@
]);
}
- void expectSuccess(String flag) {
- final result = runTestWithExperimentFlag(flag);
+ Future<void> expectSuccess(String flag) async {
+ final result = await runTestWithExperimentFlag(flag);
expect(result.stdout, contains('feature enabled'),
reason: 'stderr: ${result.stderr}');
expect(result.exitCode, 0,
reason: 'stdout: ${result.stdout} stderr: ${result.stderr}');
}
- void expectFailure(String flag) {
- final result = runTestWithExperimentFlag(flag);
+ Future<void> expectFailure(String flag) async {
+ final result = await runTestWithExperimentFlag(flag);
expect(result.exitCode, isNot(0));
}
for (final experiment in experiments) {
- test(experiment.name, () {
+ test(experiment.name, () async {
final currentSdk = Version.parse(Platform.version.split(' ').first);
p = project(
mainSrc: experiment.validation,
@@ -190,12 +193,12 @@
''');
if (experiment.enabledIn != null) {
// The experiment has been released - enabling it should have no effect.
- expectSuccess(null);
- expectSuccess('--enable-experiment=${experiment.name}');
+ await expectSuccess(null);
+ await expectSuccess('--enable-experiment=${experiment.name}');
} else {
- expectFailure(null);
- expectFailure('--enable-experiment=no-${experiment.name}');
- expectSuccess('--enable-experiment=${experiment.name}');
+ await expectFailure(null);
+ await expectFailure('--enable-experiment=no-${experiment.name}');
+ await expectSuccess('--enable-experiment=${experiment.name}');
}
});
}
diff --git a/pkg/dartdev/test/load_from_dill_test.dart b/pkg/dartdev/test/load_from_dill_test.dart
index 6de6c6c..e73d35e 100644
--- a/pkg/dartdev/test/load_from_dill_test.dart
+++ b/pkg/dartdev/test/load_from_dill_test.dart
@@ -14,13 +14,13 @@
tearDown(() => p?.dispose());
test("Fallback to dartdev.dill from dartdev.dart.snapshot for 'Hello World'",
- () {
+ () async {
p = project(mainSrc: "void main() { print('Hello World'); }");
// The DartDev snapshot includes the --use-bare-instructions flag. If
// --no-use-bare-instructions is passed, the VM will fail to load the
// snapshot and should fall back to using the DartDev dill file.
ProcessResult result =
- p.runSync(['--no-use-bare-instructions', 'run', p.relativeFilePath]);
+ await p.run(['--no-use-bare-instructions', 'run', p.relativeFilePath]);
expect(result.stdout, contains('Hello World'));
expect(result.stderr, isEmpty);
diff --git a/pkg/dartdev/test/no_such_file_test.dart b/pkg/dartdev/test/no_such_file_test.dart
index b5a3452..9b2edc4 100644
--- a/pkg/dartdev/test/no_such_file_test.dart
+++ b/pkg/dartdev/test/no_such_file_test.dart
@@ -11,25 +11,25 @@
tearDown(() => p?.dispose());
- test('Ensure parsing fails after encountering invalid file', () {
+ test('Ensure parsing fails after encountering invalid file', () async {
// Regression test for https://github.com/dart-lang/sdk/issues/43991
p = project();
- final noArgsResult = p.runSync(['foo.dart']);
+ final noArgsResult = await p.run(['foo.dart']);
expect(noArgsResult.stderr, isNotEmpty);
expect(noArgsResult.stdout, isEmpty);
expect(noArgsResult.exitCode, 64);
- final argsResult = p.runSync(['foo.dart', '--bar']);
+ final argsResult = await p.run(['foo.dart', '--bar']);
expect(argsResult.stderr, noArgsResult.stderr);
expect(argsResult.stdout, isEmpty);
expect(argsResult.exitCode, 64);
});
test('Providing --snapshot VM option with invalid script fails gracefully',
- () {
+ () async {
// Regression test for https://github.com/dart-lang/sdk/issues/43785
p = project();
- final result = p.runSync(['--snapshot=abc', 'foo.dart']);
+ final result = await p.run(['--snapshot=abc', 'foo.dart']);
expect(result.stderr, isNotEmpty);
expect(result.stderr, contains("Error when reading 'foo.dart':"));
expect(result.stdout, isEmpty);
diff --git a/pkg/dartdev/test/utils.dart b/pkg/dartdev/test/utils.dart
index 73f944f..3f97d71 100644
--- a/pkg/dartdev/test/utils.dart
+++ b/pkg/dartdev/test/utils.dart
@@ -51,6 +51,8 @@
final Map<String, dynamic> pubspec;
+ Process _process;
+
TestProject(
{String mainSrc,
String analysisOptions,
@@ -92,24 +94,35 @@
}
void dispose() {
+ _process?.kill();
+ _process = null;
if (dir.existsSync()) {
dir.deleteSync(recursive: true);
}
}
- ProcessResult runSync(
+ Future<ProcessResult> run(
List<String> arguments, {
String workingDir,
- }) {
- return Process.runSync(
+ }) async {
+ _process = await Process.start(
Platform.resolvedExecutable,
[
'--no-analytics',
...arguments,
],
workingDirectory: workingDir ?? dir.path,
- environment: {if (logAnalytics) '_DARTDEV_LOG_ANALYTICS': 'true'},
- stdoutEncoding: utf8);
+ environment: {if (logAnalytics) '_DARTDEV_LOG_ANALYTICS': 'true'});
+
+ final stdoutContents = await _process.stdout.transform(utf8.decoder).join();
+ final stderrContents = await _process.stderr.transform(utf8.decoder).join();
+ final code = await _process.exitCode;
+ return ProcessResult(
+ _process.pid,
+ code,
+ stdoutContents,
+ stderrContents,
+ );
}
Future<Process> start(
diff --git a/tools/VERSION b/tools/VERSION
index 48ee568..3250b93 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 32
+PRERELEASE 33
PRERELEASE_PATCH 0
\ No newline at end of file