From 392f30f69353408078efd7eae08b704e04f70044 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Sat, 28 Jan 2023 18:03:03 -0600 Subject: [PATCH] try runtime-aided directory lookup instead of __SOURCE_DIRECTORY__ --- .../RenameParamToMatchSignatureTests.fs | 2 +- .../CompletionTests.fs | 9 ++-- test/FsAutoComplete.Tests.Lsp/CoreTests.fs | 10 ++-- .../DependentFileCheckingTests.fs | 19 +++---- .../DetectUnitTests.fs | 3 +- .../ExtensionsTests.fs | 12 ++--- .../FindReferencesTests.fs | 3 +- test/FsAutoComplete.Tests.Lsp/GoToTests.fs | 4 +- .../HighlightingTests.fs | 3 +- .../InfoPanelTests.fs | 3 +- test/FsAutoComplete.Tests.Lsp/RenameTests.fs | 6 +-- test/FsAutoComplete.Tests.Lsp/ScriptTests.fs | 9 ++-- .../UnsedDeclarationsTests.fs | 2 +- .../Utils/Server.Tests.fs | 4 +- test/FsAutoComplete.Tests.Lsp/Utils/Utils.fs | 49 +++++++++++-------- .../XmlGenerationTests.fs | 3 +- 16 files changed, 78 insertions(+), 63 deletions(-) diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/RenameParamToMatchSignatureTests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/RenameParamToMatchSignatureTests.fs index daa72bc34..0702f0a51 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/RenameParamToMatchSignatureTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/RenameParamToMatchSignatureTests.fs @@ -18,7 +18,7 @@ let tests state = // requires `fsi` and corresponding `fs` file (and a project!) // -> cannot use untitled doc // -> use existing files, but load with text specified in tests - let path = Path.Combine(__SOURCE_DIRECTORY__, @"../TestCases/CodeFixTests/RenameParamToMatchSignature/") + let path = Path.Combine(File.CurrentDir(), @"../TestCases/CodeFixTests/RenameParamToMatchSignature/") let (fsiFile, fsFile) = ("Code.fsi", "Code.fs") serverTestList (nameof RenameParamToMatchSignature) state defaultConfigDto (Some path) (fun server -> [ diff --git a/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs b/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs index 929b66a0a..8be8d4789 100644 --- a/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs @@ -8,11 +8,12 @@ open FsAutoComplete.Utils open FsAutoComplete.Lsp open FsToolkit.ErrorHandling open Utils.Server +open Utils.Utils let tests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "Completion") + let path = Path.Combine(File.CurrentDir(), "TestCases", "Completion") let! (server, events) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing events let path = Path.Combine(path, "Script.fsx") @@ -212,7 +213,7 @@ let tests state = let autocompleteTest state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "AutocompleteTest") + let path = Path.Combine(File.CurrentDir(), "TestCases", "AutocompleteTest") let! (server, event) = serverInitialize path defaultConfigDto state let projectPath = Path.Combine(path, "AutocompleteTest.fsproj") do! waitForWorkspaceFinishedParsing event @@ -226,7 +227,7 @@ let autocompleteTest state = let scriptServer = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "AutocompleteScriptTest") + let path = Path.Combine(File.CurrentDir(), "TestCases", "AutocompleteScriptTest") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event let path = Path.Combine(path, "Script.fsx") @@ -379,7 +380,7 @@ let autocompleteTest state = let autoOpenTests state = let dirPath = - Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "CompletionAutoOpenTests") + Path.Combine(File.CurrentDir(), "TestCases", "CompletionAutoOpenTests") let serverFor (scriptPath: string) = async { diff --git a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs index 26b6b7560..493ff5687 100644 --- a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs @@ -35,7 +35,7 @@ let initTests createServer = let p: InitializeParams = { ProcessId = Some 1 - RootPath = Some __SOURCE_DIRECTORY__ + RootPath = Some (File.CurrentDir()) RootUri = None InitializationOptions = Some(Server.serialize defaultConfigDto) Capabilities = Some clientCaps @@ -105,7 +105,7 @@ let initTests createServer = let documentSymbolTest state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "DocumentSymbolTest") + let path = Path.Combine(File.CurrentDir(), "TestCases", "DocumentSymbolTest") let! (server, event) = serverInitialize path defaultConfigDto state let path = Path.Combine(path, "Script.fsx") let tdop: DidOpenTextDocumentParams = { TextDocument = loadDocument path } @@ -139,7 +139,7 @@ let documentSymbolTest state = let foldingTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "FoldingTests") + let path = Path.Combine(File.CurrentDir(), "TestCases", "FoldingTests") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event @@ -190,7 +190,7 @@ let tooltipTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "Tooltips") + let path = Path.Combine(File.CurrentDir(), "TestCases", "Tooltips") let scriptPath = Path.Combine(path, "Script.fsx") let! (server, events) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing events @@ -359,7 +359,7 @@ let tooltipTests state = let closeTests state = // Note: clear diagnostics also implies clear caches (-> remove file & project options from State). - let root = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "CloseTests") + let root = Path.Combine(File.CurrentDir(), "TestCases", "CloseTests") let workspace = Path.Combine(root, "Workspace") serverTestList "close tests" state defaultConfigDto (Some workspace) (fun server -> diff --git a/test/FsAutoComplete.Tests.Lsp/DependentFileCheckingTests.fs b/test/FsAutoComplete.Tests.Lsp/DependentFileCheckingTests.fs index b317fc9e8..7b30b12ac 100644 --- a/test/FsAutoComplete.Tests.Lsp/DependentFileCheckingTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/DependentFileCheckingTests.fs @@ -9,9 +9,10 @@ open Utils.Server open System open FSharp.Control.Reactive open FSharpx.Control +open Utils.Utils let tests state = - let root = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "DependentFileChecking", "SameProject") + let root = Path.Combine(File.CurrentDir(), "TestCases", "DependentFileChecking", "SameProject") let aFile, bFile = "A.fs", "B.fs" testList (nameof DependentFileChecking) [ // Separate server for each test @@ -29,10 +30,10 @@ let tests state = // make a change to A (that is clearly incorrect) let! startAChange = Document.changeTextTo "farts" aDoc |> Async.StartChild // start listening for new diagnostics for B - let! diagnosticsForBWaiter = - bDiagsStream - |> Observable.timeoutSpan (TimeSpan.FromSeconds 15.) - |> Async.AwaitObservable + let! diagnosticsForBWaiter = + bDiagsStream + |> Observable.timeoutSpan (TimeSpan.FromSeconds 15.) + |> Async.AwaitObservable |> Async.StartChild let! aDiags = startAChange Expect.isNonEmpty aDiags $"Should have had some compilation errors for {aFile} after erroneous changes" @@ -55,11 +56,11 @@ let tests state = // make a change to A (that is clearly incorrect) let! startAChange = Document.changeTextTo "farts" aDoc |> Async.StartChild // start listening for new diagnostics for B - let! diagnosticsForBWaiter = - bDiagsStream + let! diagnosticsForBWaiter = + bDiagsStream |> Observable.skip i - |> Observable.timeoutSpan (TimeSpan.FromSeconds 15.) - |> Async.AwaitObservable + |> Observable.timeoutSpan (TimeSpan.FromSeconds 15.) + |> Async.AwaitObservable |> Async.StartChild let! aDiags = startAChange Expect.isNonEmpty aDiags $"Should have had some compilation errors for {aFile} after erroneous change #%d{i}" diff --git a/test/FsAutoComplete.Tests.Lsp/DetectUnitTests.fs b/test/FsAutoComplete.Tests.Lsp/DetectUnitTests.fs index 1b7c1d9a8..d84129180 100644 --- a/test/FsAutoComplete.Tests.Lsp/DetectUnitTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/DetectUnitTests.fs @@ -7,11 +7,12 @@ open FsAutoComplete open FsAutoComplete.LspHelpers open Helpers open FsToolkit.ErrorHandling +open Utils.Utils let tests state = let geTestNotification projectFolder fileName = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", projectFolder) + let path = Path.Combine(File.CurrentDir(), "TestCases", projectFolder) let! server, events = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing events let path = Path.Combine(path, fileName) diff --git a/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs b/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs index 735d8be0e..484fe5106 100644 --- a/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs @@ -8,13 +8,13 @@ open FsAutoComplete open FsAutoComplete.LspHelpers open Helpers open FsAutoComplete.Lsp - +open Utils.Utils let fsdnTest state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "FsdnTest") + let path = Path.Combine(File.CurrentDir(), "TestCases", "FsdnTest") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event return server @@ -90,7 +90,7 @@ let uriTests = let linterTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "LinterTest") + let path = Path.Combine(File.CurrentDir(), "TestCases", "LinterTest") let! (server, events) = serverInitialize path { defaultConfigDto with Linter = Some true } state let path = Path.Combine(path, "Script.fsx") let tdop: DidOpenTextDocumentParams = { TextDocument = loadDocument path } @@ -240,7 +240,7 @@ let linterTests state = let formattingTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "Formatting") + let path = Path.Combine(File.CurrentDir(), "TestCases", "Formatting") let! (server, events) = serverInitialize path defaultConfigDto state do! dotnetToolRestore path // need to restore CLI tools in order to use fantomas return server, events, path @@ -298,7 +298,7 @@ let formattingTests state = let analyzerTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "Analyzers") + let path = Path.Combine(File.CurrentDir(), "TestCases", "Analyzers") // because the analyzer is a project this project has a reference, the analyzer can be // found in alongside this project, so we can use the directory this project is in let analyzerPath = @@ -356,7 +356,7 @@ let analyzerTests state = let signatureTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "Signature") + let path = Path.Combine(File.CurrentDir(), "TestCases", "Signature") let scriptPath = Path.Combine(path, "Script.fsx") let! (server, events) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing events diff --git a/test/FsAutoComplete.Tests.Lsp/FindReferencesTests.fs b/test/FsAutoComplete.Tests.Lsp/FindReferencesTests.fs index 4e182fdaa..9e742ac84 100644 --- a/test/FsAutoComplete.Tests.Lsp/FindReferencesTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/FindReferencesTests.fs @@ -5,13 +5,14 @@ open System.IO open FsAutoComplete open Helpers open Ionide.LanguageServerProtocol.Types +open Utils.Utils let tests state = testList "Find All References tests" [ let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "FindReferences") + let path = Path.Combine(File.CurrentDir(), "TestCases", "FindReferences") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event diff --git a/test/FsAutoComplete.Tests.Lsp/GoToTests.fs b/test/FsAutoComplete.Tests.Lsp/GoToTests.fs index d84e4f4b8..7a8a7c369 100644 --- a/test/FsAutoComplete.Tests.Lsp/GoToTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/GoToTests.fs @@ -16,7 +16,7 @@ open Utils.TextEdit let private gotoTest state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "GoToTests") + let path = Path.Combine(File.CurrentDir(), "TestCases", "GoToTests") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event @@ -489,7 +489,7 @@ let private gotoTest state = let private scriptGotoTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "GoToTests") + let path = Path.Combine(File.CurrentDir(), "TestCases", "GoToTests") let! (server, event) = serverInitialize path defaultConfigDto state do! waitForWorkspaceFinishedParsing event let scriptPath = Path.Combine(path, "Script.fsx") diff --git a/test/FsAutoComplete.Tests.Lsp/HighlightingTests.fs b/test/FsAutoComplete.Tests.Lsp/HighlightingTests.fs index 916f9d4ab..9c698b40a 100644 --- a/test/FsAutoComplete.Tests.Lsp/HighlightingTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/HighlightingTests.fs @@ -6,9 +6,10 @@ open Helpers open FsAutoComplete.LspHelpers open Ionide.LanguageServerProtocol.Types open FsAutoComplete.Utils +open Utils.Utils let tests state = - let testPath = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "HighlightingTest") + let testPath = Path.Combine(File.CurrentDir(), "TestCases", "HighlightingTest") let scriptPath = Path.Combine(testPath, "Script.fsx") let server = diff --git a/test/FsAutoComplete.Tests.Lsp/InfoPanelTests.fs b/test/FsAutoComplete.Tests.Lsp/InfoPanelTests.fs index 6d2218fc7..6f16d7825 100644 --- a/test/FsAutoComplete.Tests.Lsp/InfoPanelTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/InfoPanelTests.fs @@ -6,11 +6,12 @@ open Ionide.LanguageServerProtocol.Types open FsAutoComplete open Helpers open FsToolkit.ErrorHandling +open Utils.Utils let docFormattingTest state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "FormattedDocumentation") + let path = Path.Combine(File.CurrentDir(), "TestCases", "FormattedDocumentation") let config = defaultConfigDto let! (server, events) = serverInitialize path config state let path = Path.Combine(path, "Script.fsx") diff --git a/test/FsAutoComplete.Tests.Lsp/RenameTests.fs b/test/FsAutoComplete.Tests.Lsp/RenameTests.fs index 5be43ab78..ead66a5e6 100644 --- a/test/FsAutoComplete.Tests.Lsp/RenameTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/RenameTests.fs @@ -20,7 +20,7 @@ let private normalizePathCasing = let tests state = let sameProjectTests = let testDir = - Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "RenameTest", "SameProject") + Path.Combine(File.CurrentDir(), "TestCases", "RenameTest", "SameProject") serverTestList "Within Same Project" state defaultConfigDto (Some testDir) (fun server -> [ testCaseAsync @@ -141,7 +141,7 @@ let tests state = NewName = newName } let! res = doc.Server.Server.TextDocumentRename p - let edits = + let edits = match res with | Result.Error e -> failtestf "Request failed: %A" e | Result.Ok None -> failtest "Request none" @@ -219,7 +219,7 @@ let tests state = let server = async { let testDir = - Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "RenameTest", "CrossProject") + Path.Combine(File.CurrentDir(), "TestCases", "RenameTest", "CrossProject") let! (server, event) = serverInitialize testDir defaultConfigDto state do! waitForWorkspaceFinishedParsing event diff --git a/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs b/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs index 2ef4fa925..b481b55dd 100644 --- a/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/ScriptTests.fs @@ -11,11 +11,12 @@ open FsToolkit.ErrorHandling open FSharpx.Control.Observable open FSharp.Control.Reactive open System +open Utils.Utils let scriptPreviewTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "PreviewScriptFeatures") + let path = Path.Combine(File.CurrentDir(), "TestCases", "PreviewScriptFeatures") let scriptPath = Path.Combine(path, "Script.fsx") @@ -45,7 +46,7 @@ let scriptPreviewTests state = let scriptEvictionTests state = let server = async { - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ScriptEviction") + let path = Path.Combine(File.CurrentDir(), "TestCases", "ScriptEviction") let scriptPath = Path.Combine(path, "Script.fsx") let! (server, events) = serverInitialize path defaultConfigDto state @@ -94,7 +95,7 @@ let dependencyManagerTests state = let server = async { let workingDir = - Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "DependencyManagement") + Path.Combine(File.CurrentDir(), "TestCases", "DependencyManagement") let dependencyManagerAssemblyDir = Path.Combine( @@ -152,7 +153,7 @@ let scriptProjectOptionsCacheTests state = let server = async { let workingDir = - Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ScriptProjectOptsCache") + Path.Combine(File.CurrentDir(), "TestCases", "ScriptProjectOptsCache") let previewEnabledConfig = { defaultConfigDto with FSIExtraParameters = Some [| "--langversion:preview" |] } diff --git a/test/FsAutoComplete.Tests.Lsp/UnsedDeclarationsTests.fs b/test/FsAutoComplete.Tests.Lsp/UnsedDeclarationsTests.fs index f0d5456b6..65eb1bd8c 100644 --- a/test/FsAutoComplete.Tests.Lsp/UnsedDeclarationsTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/UnsedDeclarationsTests.fs @@ -130,7 +130,7 @@ let private scriptTests state = ]) let private projectTests state = - let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "UnusedDeclarations") + let path = Path.Combine(File.CurrentDir(), "TestCases", "UnusedDeclarations") let file = Existing "Library.fs" let config = { diff --git a/test/FsAutoComplete.Tests.Lsp/Utils/Server.Tests.fs b/test/FsAutoComplete.Tests.Lsp/Utils/Server.Tests.fs index 510aa40b1..b3d76c4ba 100644 --- a/test/FsAutoComplete.Tests.Lsp/Utils/Server.Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/Utils/Server.Tests.fs @@ -222,7 +222,7 @@ let tests state = testList (nameof(Server)) [ testList "with root path" [ let inTestCases name = - System.IO.Path.Combine(__SOURCE_DIRECTORY__, "..", "TestCases", "ServerTests", name) + System.IO.Path.Combine(File.CurrentDir(), "..", "TestCases", "ServerTests", name) |> Some let noAnalyzersConfig = @@ -592,7 +592,7 @@ f2 "bar" |> ignore serverTestList "no root path without analyzers" state defaultConfigDto None (fun server -> [ testCaseAsync "can create Document by absolute path without root path" <| async { let relativePath = "../TestCases/ServerTests/JustScript/Script.fsx" - let absolutePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(__SOURCE_DIRECTORY__, relativePath)) + let absolutePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(File.CurrentDir(), relativePath)) let! (doc, _) = server |> Server.openDocument absolutePath use doc = doc () diff --git a/test/FsAutoComplete.Tests.Lsp/Utils/Utils.fs b/test/FsAutoComplete.Tests.Lsp/Utils/Utils.fs index e039936d1..6a29926ea 100644 --- a/test/FsAutoComplete.Tests.Lsp/Utils/Utils.fs +++ b/test/FsAutoComplete.Tests.Lsp/Utils/Utils.fs @@ -1,5 +1,12 @@ module Utils.Utils +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +type File = + static member CurrentDir([] callerPath: string) = callerPath + + module Expect = open FsAutoComplete.Utils open Expecto @@ -20,9 +27,9 @@ module Expect = } /// passed Async `f` is expected to throw `Expecto.AssertException` /// -> Expecto Test in `f` is expected to fail - /// + /// /// ~ Basically fancy `Async` wrapper for `Expect.throwsT` - /// + /// /// Note: `failwith` doesn't trigger success (throws `System.Exception`). Use `failtest` instead let failure f = failureMatching (fun _ -> true) f @@ -42,7 +49,7 @@ module Position = assert(pos.Line >= 0) assert(pos.Character >= 0) - let inline eq p1 p2 = + let inline eq p1 p2 = // p1.Line = p2.Line && p1.Character = p2.Character p1 = p2 let inline gt p1 p2 = @@ -50,7 +57,7 @@ module Position = let inline geq p1 p2 = eq p1 p2 || gt p1 p2 let inline lt p1 p2 = gt p2 p1 let inline leq p1 p2 = geq p2 p1 - + /// Note: Always assumes correct order inside Range: `Start <= End` module Range = open Ionide.LanguageServerProtocol.Types @@ -64,7 +71,7 @@ module Range = range.Start = range.End /// Strict: `pos` on `Start` or `End` of `range` counts as containing - /// + /// /// ```text /// -----------------------------------> /// ^^^^^^^^^^^^^^^^^ range @@ -79,7 +86,7 @@ module Range = Position.leq range.Start pos && Position.leq pos range.End /// Loose: `pos` on `Start` or `End` of `range` doesn't count as containing - /// + /// /// ```text /// -----------------------------------> /// ^^^^^^^^^^^^^^^^^ range @@ -113,7 +120,7 @@ module Range = /// | | ^^^^^^^^ false /// | ^^^^^^^^ true /// ^^^^^^^^ false - /// ^^^^^^ false + /// ^^^^^^ false /// ^^^ false /// ^ true /// ^^^ true @@ -129,7 +136,7 @@ module Range = /// | | ^^^^^^^^ false /// | ^^^^^^^^ true /// ^^^^^^^^ true - /// ^^^^^^^ true + /// ^^^^^^^ true /// ``` let overlapsStrictly (range1: Range) (range2: Range) = range1 |> containsStrictly range2.Start @@ -139,17 +146,17 @@ module Range = range2 |> containsStrictly range1.Start || range2 |> containsStrictly range1.End - + /// Loose: Touching doesn't count as overlapping. /// Neither does both just position and same position - /// + /// /// ```text /// --------------------------> /// ^^^^^^^ /// | | | ^^^^^^^^ false /// | | ^^^^^^^^ false /// | ^^^^^^^^ true - /// ^^^^^^^ true + /// ^^^^^^^ true /// ``` /// ```text /// --------------------------> @@ -165,7 +172,7 @@ module Range = not (range1 |> touches range2) /// Strict: Touching is not disjoint - /// + /// /// ```text /// --------------------------> /// ^^^^^^^ @@ -177,7 +184,7 @@ module Range = let isDisjointStrictly (range1: Range) (range2: Range) = not <| overlapsStrictly range1 range2 /// Loose: Touching is disjoint - /// + /// /// ```text /// --------------------------> /// ^^^^^^^ @@ -200,18 +207,18 @@ module Text = text.Replace("\r\n", "\n").Replace("\r", "\n") /// Note: only works with `\n`, but fails with `\r`! - let lines (text: string) = + let lines (text: string) = assertNoCarriageReturn text text.Split '\n' - /// remove leading `\n` from triple quoted string with text starting in next line + /// remove leading `\n` from triple quoted string with text starting in next line let private trimLeadingNewLine (text: string) = if text.StartsWith '\n' then text.Substring 1 else text - /// remove trailing whitespace from last line, if last line is otherwise empty. - /// Note: keeps the `\n`! + /// remove trailing whitespace from last line, if last line is otherwise empty. + /// Note: keeps the `\n`! /// Note: doesn't trim a single line with just whitespace -> requires at least one `\n` let private trimLastWhitespacesLine (text: string) = match text.LastIndexOf '\n' with @@ -257,19 +264,19 @@ module Text = line.Substring ind ) |> String.concat "\n" - + /// Trim: /// * Leading `\n` from triple quotes string with text starting in next line /// * indentation (measured for non-empty lines) - /// * Trailing whitespace in otherwise empty last line + /// * Trailing whitespace in otherwise empty last line /// Note: `\n` isn't removed - /// + /// /// Note: Asserts the passed text contains no `\r` (neither `\r` nor `\r\n`). /// It doesn't replace `\r` with `\n` but instead fails! let trimTripleQuotation (text: string) = assertNoCarriageReturn text - text + text |> trimLeadingNewLine |> trimIndentation |> trimLastWhitespacesLine diff --git a/test/FsAutoComplete.Tests.Lsp/XmlGenerationTests.fs b/test/FsAutoComplete.Tests.Lsp/XmlGenerationTests.fs index ca06d0342..fdf0db841 100644 --- a/test/FsAutoComplete.Tests.Lsp/XmlGenerationTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/XmlGenerationTests.fs @@ -7,11 +7,12 @@ open FsToolkit.ErrorHandling open Helpers open Ionide.LanguageServerProtocol.Types open System.IO +open Utils.Utils open type System.Environment let tests state = - let testPath = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "XmlDocGen") + let testPath = Path.Combine(File.CurrentDir(), "TestCases", "XmlDocGen") let scriptPath = Path.Combine(testPath, "Script.fsx") let server =