diff --git a/pkg/analysis_server/test/lsp/completion_dart_test.dart b/pkg/analysis_server/test/lsp/completion_dart_test.dart index 4783dfe93d7f..2474fa8c503e 100644 --- a/pkg/analysis_server/test/lsp/completion_dart_test.dart +++ b/pkg/analysis_server/test/lsp/completion_dart_test.dart @@ -3779,11 +3779,6 @@ void f() { } Future test_snippets_testBlock() async { - // This test fails when running on macOS using Windows style paths. This - // is because DartSnippetProducer.isInTestDirectory compares a path using - // the tests PathContext (eg. backslashes when running as Windows-on-macOS) - // to `LinterContextImpl.testDirectories` which are always using native - // paths. mainFilePath = join(projectFolderPath, 'test', 'foo_test.dart'); mainFileUri = pathContext.toUri(mainFilePath); final content = ''' diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart index 1fbba0171356..f703e14c364d 100644 --- a/pkg/analysis_server/test/lsp/initialization_test.dart +++ b/pkg/analysis_server/test/lsp/initialization_test.dart @@ -855,6 +855,11 @@ class InitializationTest extends AbstractLspAnalysisServerTest { expect(server.contextManager.includedPaths, equals([projectFolderPath])); } + Future test_initialize_rootUri_encodedDriveLetterColon() async { + await initialize(rootUri: withEncodedDriveLetterColon(projectFolderUri)); + expect(server.contextManager.includedPaths, equals([projectFolderPath])); + } + Future test_initialize_rootUri_trailingSlash() async { await initialize(rootUri: withTrailingSlashUri(projectFolderUri)); expect(server.contextManager.includedPaths, equals([projectFolderPath])); @@ -865,6 +870,13 @@ class InitializationTest extends AbstractLspAnalysisServerTest { expect(server.contextManager.includedPaths, equals([projectFolderPath])); } + Future + test_initialize_workspaceFolders_encodedDriveLetterColon() async { + await initialize( + workspaceFolders: [withEncodedDriveLetterColon(projectFolderUri)]); + expect(server.contextManager.includedPaths, equals([projectFolderPath])); + } + Future test_initialize_workspaceFolders_trailingSlash() async { await initialize( workspaceFolders: [withTrailingSlashUri(projectFolderUri)]); diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart index d6d43b9cd161..3d208cabe8ad 100644 --- a/pkg/analysis_server/test/lsp/server_abstract.dart +++ b/pkg/analysis_server/test/lsp/server_abstract.dart @@ -339,6 +339,13 @@ analyzer: return verifier; } + /// Encodes any drive letter colon in the URI. + /// + /// file:///C:/foo -> file:///C%3A/foo + Uri withEncodedDriveLetterColon(Uri uri) { + return uri.replace(path: uri.path.replaceAll(':', '%3A')); + } + /// Adds a trailing slash (direction based on path context) to [path]. /// /// Throws if the path already has a trailing slash. diff --git a/pkg/analysis_server/test/lsp/server_test.dart b/pkg/analysis_server/test/lsp/server_test.dart index 696ef28dab40..4ec18106dd27 100644 --- a/pkg/analysis_server/test/lsp/server_test.dart +++ b/pkg/analysis_server/test/lsp/server_test.dart @@ -209,8 +209,6 @@ class ServerTest extends AbstractLspAnalysisServerTest { await initialize(); await expectLater( getHover(missingDriveLetterFileUri, startOfDocPos), - // The pathContext.toUri() above translates to a non-file:// URI of just - // 'a/b.dart' so will get the not-file-scheme error message. throwsA(isResponseError(ServerErrorCodes.InvalidFilePath, message: 'URI was not an absolute file path (missing drive letter)')), );