From ccfeffb3f9fd5f55109450a27c2a47f59e00cbe1 Mon Sep 17 00:00:00 2001 From: Yazeed Obaid Date: Thu, 13 Jan 2022 13:22:49 +0200 Subject: [PATCH] Move compiled assembly only when compilation succeeded and cover in tests. --- src/app/Fake.Runtime/CompileRunner.fs | 8 +++----- src/test/Fake.Core.IntegrationTests/TestHelpers.fs | 10 ++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/app/Fake.Runtime/CompileRunner.fs b/src/app/Fake.Runtime/CompileRunner.fs index b33c1fece32..d5d5353336c 100644 --- a/src/app/Fake.Runtime/CompileRunner.fs +++ b/src/app/Fake.Runtime/CompileRunner.fs @@ -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 diff --git a/src/test/Fake.Core.IntegrationTests/TestHelpers.fs b/src/test/Fake.Core.IntegrationTests/TestHelpers.fs index 27694688746..b93ba2701fd 100644 --- a/src/test/Fake.Core.IntegrationTests/TestHelpers.fs +++ b/src/test/Fake.Core.IntegrationTests/TestHelpers.fs @@ -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 = @@ -179,6 +178,12 @@ 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 @@ -186,6 +191,7 @@ let checkIntellisense scriptName scenario = 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 =