Skip to content

Commit 487b0a2

Browse files
committed
Refactor to prepare test for fake-cli
1 parent 5758663 commit 487b0a2

File tree

5 files changed

+49
-17
lines changed

5 files changed

+49
-17
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {}
5+
}

legacy-build.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ let version =
151151
None)
152152
|> Seq.append [ 0I ]
153153
|> Seq.max
154-
[ PreReleaseSegment.AlphaNumeric "local"; PreReleaseSegment.Numeric (currentVer + 1I) ], ""
154+
let d = System.DateTime.Now
155+
[ PreReleaseSegment.AlphaNumeric "local"; PreReleaseSegment.Numeric (currentVer + 1I) ], d.ToString("yyyy-MM-dd_HHmm")
155156

156157
let semVer = SemVer.parse release.NugetVersion
157158
let prerelease =

src/test/Fake.Core.IntegrationTests/Fake.Core.Process.fs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,16 @@ open Expecto
88
open Fake.Core.IntegrationTests.TestHelpers
99
open System.Diagnostics
1010

11-
let dotnetSdk = lazy DotNet.install DotNet.Versions.FromGlobalJson
12-
1311
let dllPath = System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly().Location)
1412

1513
let runProjectRaw noBuild proj args =
16-
let options = dotnetSdk.Value (DotNet.Options.Create())
17-
18-
let dir = System.IO.Path.GetDirectoryName options.DotNetCliPath
19-
let oldPath =
20-
options
21-
|> Process.getEnvironmentVariable "PATH"
22-
2314
[
2415
yield "run"
2516
if noBuild then yield "--no-build"
2617
yield! [ "--project"; proj; "--" ]
2718
yield! args |> Args.fromWindowsCommandLine |> Seq.toList
2819
]
29-
|> CreateProcess.fromRawCommand options.DotNetCliPath
30-
|> CreateProcess.withEnvironment (options.Environment |> Map.toList)
31-
|> CreateProcess.setEnvironmentVariable "PATH" (
32-
match oldPath with
33-
| Some oldPath -> sprintf "%s%c%s" dir System.IO.Path.PathSeparator oldPath
34-
| None -> dir)
35-
|> CreateProcess.withWorkingDirectory options.WorkingDirectory
20+
|> runDotNetRaw
3621

3722
let runProject noBuild f proj args =
3823
runProjectRaw noBuild proj args

src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ open System.IO
88
open System.Diagnostics
99
open Newtonsoft.Json
1010
open Newtonsoft.Json.Linq
11+
open Fake.Core
1112

1213
let fail s = Expect.isTrue s false
1314
let ignProc = ignore<Fake.Core.ProcessResult>
1415

1516

17+
1618
type Declaration =
1719
{ File : string
1820
Line : int
@@ -32,10 +34,29 @@ type Target =
3234
Declaration : Declaration
3335
Description : string }
3436

37+
let getInfoVersion () =
38+
let attr = typeof<Fake.Core.Process.ProcessList>.Assembly.GetCustomAttributes(typeof<System.Reflection.AssemblyInformationalVersionAttribute>, false)
39+
match attr |> Seq.tryHead with
40+
| Some (:? Reflection.AssemblyInformationalVersionAttribute as attr) -> attr.InformationalVersion
41+
| None -> failwithf "Could not retrieve version"
3542

3643
[<Tests>]
3744
let tests =
3845
testList "Fake.Core.IntegrationTests" [
46+
//testCase "fake-cli local tool works" <| fun _ ->
47+
// // dotnet tool install --version 5.19.0-alpha.local.1 fake-cli --add-source /e/Projects/FAKE/release/dotnetcore/
48+
// let res =
49+
// [
50+
// yield! ["tool"; "install"]
51+
// yield! [ "--version"; getInfoVersion () ]
52+
// yield "fake-cli"
53+
// yield! ["--add-source" ]
54+
// ]
55+
// |> runDotNetRaw
56+
// |> CreateProcess.withWorkingDirectory ""
57+
// |> Proc.run
58+
// ()
59+
3960
testCase "no dependencies hello world and casing #2314" <| fun _ ->
4061
let result =
4162
if Paket.Utils.isWindows then

src/test/Fake.Core.IntegrationTests/TestHelpers.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module Fake.Core.IntegrationTests.TestHelpers
33

44
open Fake.Core
5+
open Fake.DotNet
56
open Fake.IO
67
open Fake.IO.FileSystemOperators
78
open System
@@ -21,6 +22,25 @@ type TestDir =
2122
eprintf "Failed to delete '%s': %O" x.Dir e
2223
()
2324

25+
let dotnetSdk = lazy DotNet.install DotNet.Versions.FromGlobalJson
26+
27+
let runDotNetRaw args =
28+
let options = dotnetSdk.Value (Fake.DotNet.DotNet.Options.Create())
29+
30+
let dir = System.IO.Path.GetDirectoryName options.DotNetCliPath
31+
let oldPath =
32+
options
33+
|> Process.getEnvironmentVariable "PATH"
34+
35+
args
36+
|> CreateProcess.fromRawCommand options.DotNetCliPath
37+
|> CreateProcess.withEnvironment (options.Environment |> Map.toList)
38+
|> CreateProcess.setEnvironmentVariable "PATH" (
39+
match oldPath with
40+
| Some oldPath -> sprintf "%s%c%s" dir System.IO.Path.PathSeparator oldPath
41+
| None -> dir)
42+
|> CreateProcess.withWorkingDirectory options.WorkingDirectory
43+
2444
let createTestDir () =
2545
let testFile = Path.combine (Path.GetTempPath ()) (Path.GetRandomFileName ())
2646
Directory.CreateDirectory(testFile)

0 commit comments

Comments
 (0)