Fix some failures on the windows bots

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2392793003 .
This commit is contained in:
Brian Wilkerson 2016-10-04 08:21:28 -07:00
parent 29c5c9985e
commit 154bd389db
5 changed files with 37 additions and 49 deletions

View file

@ -43,6 +43,21 @@ class MemoryResourceProvider implements ResourceProvider {
@override
pathos.Context get pathContext => _pathContext;
/**
* Convert the given posix [path] to conform to this provider's path context.
*
* This is a utility method for testing; paths passed in to other methods in
* this class are never converted automatically.
*/
String convertPath(String path) {
if (pathContext == pathos.windows &&
path.startsWith(pathos.posix.separator)) {
path = r'C:' +
path.replaceAll(pathos.posix.separator, pathos.windows.separator);
}
return path;
}
/**
* Delete the file with the given path.
*/

View file

@ -62,7 +62,7 @@ class JS {
const JS([String js]) { }
}
'''
});
}, resourceProvider: resourceProvider);
}
void test_abstractSuperMemberReference_getter() {

View file

@ -144,16 +144,6 @@ class IncrementalResolverTest extends ResolverTestCase {
LibraryElement library;
CompilationUnit unit;
@override
void reset() {
analysisContext2 = AnalysisContextFactory.contextWithCore();
}
@override
void resetWithOptions(AnalysisOptions options) {
AnalysisContextFactory.contextWithCoreAndOptions(options);
}
void setUp() {
super.setUp();
logging.logger = logging.NULL_LOGGER;

View file

@ -32,16 +32,6 @@ const String pubspecName = 'pubspec.yaml';
@reflectiveTest
class DependencyFinderTest extends ResolverTestCase {
/**
* The resource provider to be used by tests.
*/
MemoryResourceProvider resourceProvider;
@override
void setUp() {
resourceProvider = new MemoryResourceProvider();
}
void test_transitiveDependenciesFor_circularDependencies() {
String packageA = '/pub-cache/a-1.0';
String packageB = '/pub-cache/b-1.0';
@ -212,16 +202,6 @@ class PackageDescriptionTest extends ResolverTestCase {
@reflectiveTest
class PackageManagerTest extends ResolverTestCase {
/**
* The resource provider to be used by tests.
*/
MemoryResourceProvider resourceProvider;
@override
void setUp() {
resourceProvider = new MemoryResourceProvider();
}
void test_getContext() {
String packageA = '/pub-cache/a-1.0';
String packageB1 = '/pub-cache/b-1.0';

View file

@ -9,6 +9,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
@ -298,6 +299,11 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
}
class ResolverTestCase extends EngineTestCase {
/**
* The resource provider used by the test case.
*/
MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
/**
* The analysis context used to parse the compilation units being resolved.
*/
@ -332,14 +338,13 @@ class ResolverTestCase extends EngineTestCase {
TypeSystem get typeSystem => analysisContext2.typeSystem;
/**
* Add a source file to the content provider. The file path should be absolute.
*
* @param filePath the path of the file being added
* @param contents the contents to be returned by the content provider for the specified file
* @return the source object representing the added file
* Add a source file with the given [filePath] in the root of the file system.
* The file path should be absolute. The file will have the given [contents]
* set in the content provider. Return the source representing the added file.
*/
Source addNamedSource(String filePath, String contents) {
Source source = cacheSource(filePath, contents);
Source source =
cacheSource(resourceProvider.convertPath(filePath), contents);
ChangeSet changeSet = new ChangeSet();
changeSet.addedSource(source);
analysisContext2.applyChanges(changeSet);
@ -347,10 +352,9 @@ class ResolverTestCase extends EngineTestCase {
}
/**
* Add a source file to the content provider.
*
* @param contents the contents to be returned by the content provider for the specified file
* @return the source object representing the added file
* Add a source file named 'test.dart' in the root of the file system. The
* file will have the given [contents] set in the content provider. Return the
* source representing the added file.
*/
Source addSource(String contents) => addNamedSource("/test.dart", contents);
@ -614,21 +618,20 @@ class ResolverTestCase extends EngineTestCase {
}
/**
* In the rare cases we want to group several tests into single "test_" method, so need a way to
* reset test instance to reuse it.
* Re-create the analysis context being used by the test case.
*/
void reset() {
analysisContext2 = AnalysisContextFactory.contextWithCore();
analysisContext2 = AnalysisContextFactory.contextWithCore(
resourceProvider: resourceProvider);
}
/**
* Reset the analysis context to have the given options applied.
*
* @param options the analysis options to be applied to the context
* Re-create the analysis context being used by the test case and set the
* [options] in the newly created context to the given [options].
*/
void resetWithOptions(AnalysisOptions options) {
analysisContext2 =
AnalysisContextFactory.contextWithCoreAndOptions(options);
analysisContext2 = AnalysisContextFactory.contextWithCoreAndOptions(options,
resourceProvider: resourceProvider);
}
/**