Skip to content

Commit 55cccc1

Browse files
refactor build script to build and run tests for both drivers. Remaining to deal with packaging.
1 parent ed24def commit 55cccc1

1 file changed

Lines changed: 47 additions & 34 deletions

File tree

build/build.fs

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,31 @@ let files includes =
2828

2929
// Information about the project to be used at NuGet and in AssemblyInfo files
3030
let systemSqlProject = {|
31-
runtime="FSharp.Data.SqlClient"
32-
designTime="FSharp.Data.SqlClient.DesignTime"
31+
runtime = "FSharp.Data.SqlClient"
32+
designTime = "FSharp.Data.SqlClient.DesignTime"
33+
slnPath = makeRootPath "SqlClient.sln"
34+
testProjectsSlnPath = makeRootPath "TestProjects.sln"
35+
testSlnPath = makeRootPath "Tests.sln"
36+
testProjectPath = makeRootPath "tests/SqlClient.Tests/SqlClient.Tests.fsproj"
37+
3338
|}
3439
let microsoftSqlProject = {|
35-
runtime="FSharp.Data.MicrosoftSqlClient"
36-
designTime="FSharp.Data.MicrosoftSqlClient.DesignTime"
40+
runtime = "FSharp.Data.MicrosoftSqlClient"
41+
designTime = "FSharp.Data.MicrosoftSqlClient.DesignTime"
42+
slnPath = makeRootPath "MicrosoftSqlClient.sln"
43+
testProjectsSlnPath = makeRootPath "MicrosoftTestProjects.sln"
44+
testSlnPath = makeRootPath "MicrosoftTests.sln"
45+
testProjectPath = makeRootPath "tests/SqlClient.Tests/MicrosoftSqlClient.Tests.fsproj"
3746
|}
47+
48+
let projects = [systemSqlProject;microsoftSqlProject]
3849
let authors = ["Dmitry Morozov, Dmitry Sevastianov"]
3950
let summary = "SqlClient F# type providers"
40-
let description = "SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.\nSqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code."
51+
let description = """SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.
52+
SqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code.
53+
"""
4154
let tags = "F# fsharp data typeprovider sql"
42-
55+
4356
let gitHome = "https://github.com/fsprojects"
4457
let gitName = "FSharp.Data.SqlClient"
4558

@@ -98,11 +111,7 @@ Target.create "AssemblyInfo" (fun _ ->
98111
AssemblyInfo.InternalsVisibleTo "MicrosoftSqlClient.Tests" ] )
99112
)
100113

101-
let slnPath = makeRootPath "SqlClient.sln"
102-
let testProjectsSlnPath = makeRootPath "TestProjects.sln"
103-
let testSlnPath = makeRootPath "Tests.sln"
104114
let testDir = makeRootPath "tests"
105-
let testProjectPath = makeRootPath "tests/SqlClient.Tests/SqlClient.Tests.fsproj"
106115

107116
let msBuildPaths extraPaths =
108117
[
@@ -158,10 +167,10 @@ let runMsBuild project =
158167
Target.create "Clean" (fun _ ->
159168
Shell.cleanDirs ["bin"; "temp"]
160169
let dnDefault (args: DotNet.Options) = { args with Verbosity = Some DotNet.Verbosity.Quiet }
161-
DotNet.exec dnDefault "clean" slnPath |> ignore
162-
DotNet.exec dnDefault "clean" testProjectsSlnPath |> ignore
163-
DotNet.exec dnDefault "clean" testSlnPath |> ignore
164-
()
170+
for entry in projects do
171+
DotNet.exec dnDefault "clean" entry.slnPath |> ignore
172+
DotNet.exec dnDefault "clean" entry.testProjectsSlnPath |> ignore
173+
DotNet.exec dnDefault "clean" entry.testSlnPath |> ignore
165174
)
166175

167176
Target.create "CleanDocs" (fun _ ->
@@ -179,9 +188,10 @@ let dnDefault =
179188
>> DotNet.Options.withCustomParams (Some "--tl")
180189

181190
Target.create "Build" (fun _ ->
191+
for entry in projects do
182192
DotNet.build
183-
(fun args -> { args with Configuration = DotNet.Release } |> dnDefault)
184-
slnPath
193+
(fun args -> { args with Configuration = DotNet.Release } |> dnDefault)
194+
entry.slnPath
185195
)
186196

187197
open System.Data.SqlClient
@@ -291,42 +301,45 @@ let funBuildRunMSBuild stageName sln =
291301
}
292302

293303
Target.create "BuildTestProjects" (fun _ ->
294-
pipeline "BuildTestProjects" {
295-
funBuildRestore "test projects sln" testProjectsSlnPath
296-
funBuildRunMSBuild "test projects sln" testProjectsSlnPath
304+
for entry in projects do
305+
if File.Exists entry.testProjectsSlnPath then
306+
pipeline $"BuildTestProjects {entry.runtime}" {
307+
funBuildRestore "test projects sln" entry.testProjectsSlnPath
308+
funBuildRunMSBuild "test projects sln" entry.testProjectsSlnPath
297309
runImmediate
298-
}
310+
}
299311
)
300312

301313
// --------------------------------------------------------------------------------------
302314
// Run the unit tests
303315
Target.create "RunTests" (fun _ ->
304316

305-
let runTests () =
317+
let runTests (entry: {|testSlnPath: string; testProjectPath: string|}) =
306318
let dnTestOptions framework (args: DotNet.TestOptions) =
307319
{ args with
308320
Framework = Some framework
309321
Common = args.Common
310322
NoBuild = true
311323
MSBuildParams = { args.MSBuildParams with DisableInternalBinLog = true }
312324
}
313-
try
314-
DotNet.test (dnTestOptions "net462") testSlnPath
315-
DotNet.test (dnTestOptions "net8.0") testProjectPath
325+
326+
try
327+
DotNet.test (dnTestOptions "net462") entry.testSlnPath
328+
DotNet.test (dnTestOptions "net8.0") entry.testProjectPath
316329
with
317330
| ex ->
318331
Trace.log (sprintf "Test exception: %A" ex)
319332
raise ex
320-
321-
pipeline "RunTests" {
322-
funBuildRestore "test sln" testSlnPath
323-
funBuildRunMSBuild "test sln" testSlnPath
324-
325-
stage "run tests" {
326-
run (fun ctx -> runTests())
327-
}
328-
runImmediate
329-
}
333+
for entry in projects do
334+
pipeline $"RunTests {entry.runtime}" {
335+
funBuildRestore "test sln" entry.testSlnPath
336+
funBuildRunMSBuild "test sln" entry.testSlnPath
337+
338+
stage "run tests" {
339+
run (fun ctx -> runTests {|testSlnPath=entry.testSlnPath; testProjectPath=entry.testProjectPath|})
340+
}
341+
runImmediate
342+
}
330343
)
331344

332345
// --------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)