Skip to content

Commit

Permalink
Move compiled assembly only when compilation succeeded and cover in t…
Browse files Browse the repository at this point in the history
…ests.
  • Loading branch information
yazeedobaid committed Jan 31, 2022
1 parent 7c88047 commit ccfeffb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/app/Fake.Runtime/CompileRunner.fs
Expand Up @@ -189,13 +189,11 @@ let runUncached (context:FakeContext) : ResultCoreCacheInfo * RunResult =

let compileErrors, returnCode = compile context compilerAssemblyTempPath

trace "moving compiled files..."
// here we will move the result of compilation to FAKE script directory instead of temporary directory
File.Move(compilerAssemblyTempPath, wishPath)
File.Move(compilerPdbTempPath, pdbWishPath)

let cacheInfo = handleCoreCaching context wishPath compileErrors.FormattedErrors
if returnCode = 0 then
// here we will move the result of compilation to FAKE script directory instead of temporary directory
File.Move(compilerAssemblyTempPath, wishPath)
File.Move(compilerPdbTempPath, pdbWishPath)
use execContext = Fake.Core.Context.FakeExecutionContext.Create false context.Config.ScriptFilePath []
Fake.Core.Context.setExecutionContext (Fake.Core.Context.RuntimeContext.Fake execContext)
match cacheInfo.AsCacheInfo with
Expand Down
10 changes: 8 additions & 2 deletions src/test/Fake.Core.IntegrationTests/TestHelpers.fs
Expand Up @@ -6,10 +6,9 @@ open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open System
//open NUnit.Framework
open System.Linq
open Expecto
open Expecto.Flip
open System
open System.IO

type TestDir =
Expand Down Expand Up @@ -179,13 +178,20 @@ let checkIntellisenseInPath scriptName path =
"#endif" ]
Expect.equal "intellisense.fsx should be forwarding" expected lines

let checkScriptAssemblyInPath (scriptName:string) path =
let scriptNameWithoutExtension = scriptName.Replace(".fsx", "")
let cachePath = path </> ".fake" </> scriptName
Directory.EnumerateFiles(cachePath, $"{scriptNameWithoutExtension}_*.dll").Any()
|> Expect.isTrue "Expect script compiled assembly to exist"

let checkIntellisense scriptName scenario =
let scenarioPath = scenarioTempPath scenario
checkIntellisenseInPath scriptName scenarioPath

let fakeRunAndCheckInPath ctx scriptName runArgs scenario path =
let result = fakeRunInPath ctx runArgs scenario path
checkIntellisenseInPath scriptName (resolvePath scenario path)
checkScriptAssemblyInPath scriptName (resolvePath scenario path)
result

let fakeRunAndCheck ctx scriptName runArgs scenario =
Expand Down

0 comments on commit ccfeffb

Please sign in to comment.