Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to fix pathToExtension in FsiExtension tests. #3922

Open
wants to merge 5 commits into
base: fsharp5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions integrationtests/Paket.IntegrationTests/FsiExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ module FsiExtension =
"Release"
#endif

let pathToExtension = Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "src", "FSharp.DependencyManager.Paket", "bin", configuration, "netstandard2.1")
let extensionFileName = "FSharp.DependencyManager.Paket.dll"

let pathToExtension () =
let mostRecentLocation =
(
DirectoryInfo(Path.Combine(__SOURCE_DIRECTORY__, "..", "..")).EnumerateFiles(extensionFileName, SearchOption.AllDirectories)
|> Seq.filter (fun f -> not (f.FullName.Contains((string Path.DirectorySeparatorChar) + "obj" + (string Path.DirectorySeparatorChar))))
|> Seq.sortByDescending (fun f -> f.CreationTimeUtc)
|> Seq.head
)
printfn "%s found in %s" extensionFileName mostRecentLocation.Directory.FullName
mostRecentLocation.Directory.FullName

[<Test>]
let ``fcs can type check `` () =
System.AppDomain.CurrentDomain.add_AssemblyResolve(fun _ (e: System.ResolveEventArgs) ->
printfn "assembly resolve: %s" e.Name
// the paket dependency manager assembly depends on fsharp.core version
// which may not be the same as hosting process
if e.Name.StartsWith "FSharp.Core," then
Expand All @@ -29,7 +40,7 @@ module FsiExtension =
)

let checker = FSharpChecker.Create(suggestNamesForErrors=true, keepAssemblyContents=true)
let fileName = Path.Combine(pathToExtension,extensionFileName)
let fileName = Path.Combine(pathToExtension (),extensionFileName)
if not (File.Exists fileName) then
failwithf "Extension: %s not found" fileName

Expand All @@ -38,7 +49,7 @@ module FsiExtension =
let v = FSharp.Data.JsonValue.Boolean true
"""
let projectOptions =
checker.GetProjectOptionsFromScript("test.fsx", SourceText.ofString sourceText, otherFlags = [| "/langversion:preview"; sprintf "/compilertool:%s" pathToExtension |] )
checker.GetProjectOptionsFromScript("test.fsx", SourceText.ofString sourceText, otherFlags = [| "/langversion:preview"; sprintf "/compilertool:%s" (pathToExtension()) |] )
|> Async.RunSynchronously
|> fst

Expand All @@ -61,7 +72,7 @@ module FsiExtension =
let fsxsFolder = Path.Combine(__SOURCE_DIRECTORY__, "..", "scenarios", "fsi-depmanager", "deterministic.output")

let runSingleFsxTestForOutput (fsxFile: FileInfo) =
let arguments = sprintf @"fsi --langversion:preview %s %s" (sprintf "--compilertool:%s" pathToExtension) fsxFile.FullName
let arguments = sprintf @"fsi --langversion:preview %s %s" (sprintf "--compilertool:%s" (pathToExtension ())) fsxFile.FullName
let standardOutput, errorOutput =
let p = new System.Diagnostics.Process()
p.StartInfo.UseShellExecute <- false
Expand Down