diff options
5 files changed, 60 insertions, 29 deletions
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs new file mode 100644 index 0000000000..a0937e152c --- /dev/null +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Interactive.fs @@ -0,0 +1,29 @@ +namespace MonoDevelopTests +open System.Threading +open NUnit.Framework +open MonoDevelop.FSharp.MonoDevelop +open MonoDevelop.FSharp +open System.IO +open System.Reflection +open System.Threading.Tasks +open System.Runtime.CompilerServices + +[<TestFixture>] +module Interactive = + let toTask computation : Task = Async.StartAsTask computation :> _ + + [<Test;AsyncStateMachine(typeof<Task>)>] + let ``Interactive receives prompt``() = + async { + let (/) a b = Path.Combine(a,b) + let testDllFolder = Assembly.GetExecutingAssembly().Location |> Path.GetDirectoryName + let pathToExe = "\"" + testDllFolder/".."/".."/".."/".."/".."/"build"/"AddIns"/"BackendBindings"/"MonoDevelop.FSharpInteractive.Service.exe\"" + let ses = InteractiveSession(pathToExe) + do! Async.Sleep 1000 // give the process chance to start + if ses.HasExited() then + Assert.Fail("Interactive session has exited") + ses.StartReceiving() + let finished = new AutoResetEvent(false) // using AutoResetEvent because I can't get Async.AwaitEvent to work here without a hang + ses.PromptReady.Add(fun _ -> finished.Set() |> ignore) + finished.WaitOne() |> ignore + Assert.Pass() } |> toTask diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj index 74415feab3..167edaf570 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj @@ -137,26 +137,6 @@ <Name>MonoDevelop.PackageManagement</Name> </ProjectReference> </ItemGroup> - <ItemGroup> - <Compile Include="TestBase.fs" /> - <Compile Include="TestDocument.fs" /> - <Compile Include="TestWorkbenchWindow.fs" /> - <Compile Include="TestViewContent.fs" /> - <Compile Include="TestHelpers.fs" /> - <Compile Include="DebuggerExpressionResolver.fs" /> - <Compile Include="CompilerArguments.fs" /> - <Compile Include="IndentationTrackerTests.fs" /> - <Compile Include="FSharpUnitTestTextEditorExtensionTests.fs" /> - <Compile Include="SyntaxHighlighting.fs" /> - <Compile Include="SemanticHighlighting.fs" /> - <Compile Include="TestTooltipProvider.fs" /> - <Compile Include="ProjectTests.fs" /> - <Compile Include="ProjectCracking.fs" /> - <Compile Include="GlobalSearch.fs" /> - <Compile Include="ParsingTests.fs" /> - <Compile Include="CompletionTests.fs" /> - <Compile Include="TemplateTests.fs" /> - </ItemGroup> <PropertyGroup> <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> </PropertyGroup> @@ -179,6 +159,25 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <Compile Include="TestBase.fs" /> + <Compile Include="TestDocument.fs" /> + <Compile Include="TestWorkbenchWindow.fs" /> + <Compile Include="TestViewContent.fs" /> + <Compile Include="TestHelpers.fs" /> + <Compile Include="DebuggerExpressionResolver.fs" /> + <Compile Include="CompilerArguments.fs" /> + <Compile Include="IndentationTrackerTests.fs" /> + <Compile Include="FSharpUnitTestTextEditorExtensionTests.fs" /> + <Compile Include="SyntaxHighlighting.fs" /> + <Compile Include="SemanticHighlighting.fs" /> + <Compile Include="TestTooltipProvider.fs" /> + <Compile Include="ProjectTests.fs" /> + <Compile Include="ProjectCracking.fs" /> + <Compile Include="GlobalSearch.fs" /> + <Compile Include="ParsingTests.fs" /> + <Compile Include="CompletionTests.fs" /> + <Compile Include="TemplateTests.fs" /> + <Compile Include="Interactive.fs" /> <Compile Include="ParameterHinting.fs" /> <Compile Include="HighlightUsagesTests.fs" /> <Compile Include="CopyPaste.fs" /> @@ -194,10 +193,10 @@ <None Include="Samples\android\fsandroidnuget2\fsandroidnuget2.fsproj"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="Samples\android\packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll"> + <None Include="Samples\android\fsandroidnuget2\MainActivity.fs"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="Samples\android\fsandroidnuget2\MainActivity.fs"> + <None Include="Samples\android\packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpInteractivePad.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpInteractivePad.fs index 2aa2a6e912..af682b528f 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpInteractivePad.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpInteractivePad.fs @@ -189,7 +189,8 @@ type FSharpInteractivePad() = let setupSession() = try - let ses = InteractiveSession() + let pathToExe = "\"" + Path.Combine(Reflection.Assembly.GetExecutingAssembly().Location |> Path.GetDirectoryName, "MonoDevelop.FSharpInteractive.Service.exe") + "\"" + let ses = InteractiveSession(pathToExe) input.Clear() promptReceived <- false let textReceived = ses.TextReceived.Subscribe(fun t -> Runtime.RunInMainThread(fun () -> fsiOutput t) |> ignore) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/InteractiveSession.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/InteractiveSession.fs index f461f22c5d..0736a082e7 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/InteractiveSession.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/InteractiveSession.fs @@ -18,7 +18,7 @@ type CompletionData = { description: string } -type InteractiveSession() = +type InteractiveSession(pathToExe) = let (|Completion|_|) (command: string) = if command.StartsWith("completion ") then let payload = command.[11..] @@ -40,15 +40,14 @@ type InteractiveSession() = else None - let path = "\"" + Path.Combine(Reflection.Assembly.GetExecutingAssembly().Location |> Path.GetDirectoryName, "MonoDevelop.FSharpInteractive.Service.exe") + "\"" let mutable waitingForResponse = false let fsiProcess = let processName = - if Environment.runningOnMono then Environment.getMonoPath() else path + if Environment.runningOnMono then Environment.getMonoPath() else pathToExe let arguments = - if Environment.runningOnMono then path else null + if Environment.runningOnMono then pathToExe else null let startInfo = new ProcessStartInfo @@ -98,7 +97,7 @@ type InteractiveSession() = | ParameterHints hints -> parameterHintReceivedEvent.Trigger hints | _ -> LoggingService.logDebug "[fsharpi] don't know how to process command %s" de.Data - + with | :? JsonException -> LoggingService.logError "[fsharpi] - error deserializing error stream - %s" de.Data @@ -120,6 +119,8 @@ type InteractiveSession() = member x.TextReceived = textReceived.Publish member x.PromptReady = promptReady.Publish + member x.HasExited() = fsiProcess.HasExited + member x.Kill() = if not fsiProcess.HasExited then x.SendInput "#q;;" @@ -135,6 +136,8 @@ type InteractiveSession() = LoggingService.logDebug "Interactive: waiting for process exit after kill... %d" (i*200) fsiProcess.WaitForExit(200) |> ignore + member x.KillNow() = fsiProcess.Kill() + member x.SendInput input = for line in String.getLines input do sendCommand ("input " + line) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj index eb8a2b1df7..c2dab81f56 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj @@ -200,7 +200,6 @@ <ItemGroup> <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath> - <Private>False</Private> <Paket>True</Paket> </Reference> </ItemGroup> |