Skip to content

Commit

Permalink
Using dotnet test and reducing Fable test complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Jan 6, 2022
1 parent e1101e2 commit 4628373
Show file tree
Hide file tree
Showing 23 changed files with 1,209 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,4 @@ paket-files/
fable_modules
.fable
*.fs.js
js-dist/
45 changes: 0 additions & 45 deletions FsToolkit.ErrorHandling.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsToolkit.ErrorHandling.Asy
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsToolkit.ErrorHandling.AsyncSeq.Tests", "tests\FsToolkit.ErrorHandling.AsyncSeq.Tests\FsToolkit.ErrorHandling.AsyncSeq.Tests.fsproj", "{5DED3CA8-B331-4B48-A6A2-2EE1410437CA}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsToolkit.ErrorHandling.Fable.Tests", "tests\FsToolkit.ErrorHandling.Fable.Tests\FsToolkit.ErrorHandling.Fable.Tests.fsproj", "{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsToolkit.ErrorHandling.Tests.Runner", "tests\FsToolkit.ErrorHandling.Tests.Runner\FsToolkit.ErrorHandling.Tests.Runner.fsproj", "{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsToolkit.ErrorHandling.AsyncSeq.Tests.Runner", "tests\FsToolkit.ErrorHandling.AsyncSeq.Tests.Runner\FsToolkit.ErrorHandling.AsyncSeq.Tests.Runner.fsproj", "{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -154,42 +148,6 @@ Global
{5DED3CA8-B331-4B48-A6A2-2EE1410437CA}.Release|x64.Build.0 = Release|Any CPU
{5DED3CA8-B331-4B48-A6A2-2EE1410437CA}.Release|x86.ActiveCfg = Release|Any CPU
{5DED3CA8-B331-4B48-A6A2-2EE1410437CA}.Release|x86.Build.0 = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|x64.ActiveCfg = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|x64.Build.0 = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|x86.ActiveCfg = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Debug|x86.Build.0 = Debug|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|Any CPU.Build.0 = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|x64.ActiveCfg = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|x64.Build.0 = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|x86.ActiveCfg = Release|Any CPU
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E}.Release|x86.Build.0 = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|x64.ActiveCfg = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|x64.Build.0 = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|x86.ActiveCfg = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Debug|x86.Build.0 = Debug|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|Any CPU.Build.0 = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|x64.ActiveCfg = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|x64.Build.0 = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|x86.ActiveCfg = Release|Any CPU
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30}.Release|x86.Build.0 = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|x64.ActiveCfg = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|x64.Build.0 = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|x86.ActiveCfg = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Debug|x86.Build.0 = Debug|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|Any CPU.Build.0 = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|x64.ActiveCfg = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|x64.Build.0 = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|x86.ActiveCfg = Release|Any CPU
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E0466000-F8E4-416B-B605-C65F7602367A} = {E28025A7-EF6A-45BF-8FA0-75E394D3D42B}
Expand All @@ -201,8 +159,5 @@ Global
{600EA6E9-C9F2-4F02-99EF-1F992711DB1C} = {9F888E39-5D40-4E29-9529-67C466722431}
{02DF2AE6-A7D4-4C38-AA4D-651BDD1D3571} = {E28025A7-EF6A-45BF-8FA0-75E394D3D42B}
{5DED3CA8-B331-4B48-A6A2-2EE1410437CA} = {D8B86171-2147-49EF-8ADA-1CF8B0A20D40}
{629C5ADC-6C4D-454C-88EE-CC067FB21D5E} = {D8B86171-2147-49EF-8ADA-1CF8B0A20D40}
{B70E0B97-0CDD-481B-8F77-E1B0A486EB30} = {D8B86171-2147-49EF-8ADA-1CF8B0A20D40}
{3DC38BAA-68F3-4493-B6F7-4A1C8C101897} = {D8B86171-2147-49EF-8ADA-1CF8B0A20D40}
EndGlobalSection
EndGlobal
90 changes: 27 additions & 63 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ Target.create "Clean" (fun _ ->
++ "tests/**/bin"
++ "src/**/obj"
++ "tests/**/obj"
++ "dist"
++"js-dist"
|> Shell.cleanDirs

[
Expand All @@ -129,80 +131,42 @@ Target.create "NpmRestore" (fun _ ->
Npm.install id
)

let runTestAssembly setParams testAssembly =
let exitCode =
let fakeStartInfo testAssembly (args : Expecto.Params) =
let workingDir =
if String.isNotNullOrEmpty args.WorkingDirectory
then args.WorkingDirectory else Fake.IO.Path.getDirectory testAssembly
(fun (info: ProcStartInfo) ->
{ info with
FileName = "dotnet"
Arguments = sprintf "%s %s" testAssembly (string args)
WorkingDirectory = workingDir } )

let execWithExitCode testAssembly argsString timeout =
Process.execSimple (fakeStartInfo testAssembly argsString) timeout

execWithExitCode testAssembly (setParams Expecto.Params.DefaultParams) TimeSpan.MaxValue

testAssembly, exitCode

let runTests setParams testAssemblies =
let details = testAssemblies |> String.separated ", "
use __ = Trace.traceTask "Expecto" details
match testAssemblies with
| [] -> raise <| Fake.Testing.Common.FailedTestsException "No test assemblies found"
| _ -> ()
let res =
testAssemblies
|> Seq.map (runTestAssembly setParams)
|> Seq.filter( snd >> (<>) 0)
|> Seq.toList

match res with
| [] -> ()
| failedAssemblies ->
failedAssemblies
|> List.map (fun (testAssembly,exitCode) ->
sprintf "Expecto test of assembly '%s' failed. Process finished with exit code %d." testAssembly exitCode )
|> String.concat System.Environment.NewLine
|> Fake.Testing.Common.FailedTestsException |> raise
__.MarkSuccess()

let testProjects = [
"tests/FsToolkit.ErrorHandling.Tests.Runner"
"tests/FsToolkit.ErrorHandling.AsyncSeq.Tests.Runner"
"tests/FsToolkit.ErrorHandling.JobResult.Tests"
"tests/FsToolkit.ErrorHandling.TaskResult.Tests"
"tests/FsToolkit.ErrorHandling.Fable.Tests"
]
let dotnetTest ctx =

let testAssemblies = [
for proj in testProjects do
let projName = proj.Split('/') |> Array.last
let pattern = proj </> "bin" </> configuration </> "**" </> (projName + ".dll")
let args =
[
"--no-build"
]
DotNet.test(fun c ->

yield! (!!pattern)
]
{ c with
Configuration =DotNet.BuildConfiguration.Release
Common =
c.Common
|> DotNet.Options.withAdditionalArgs args
}) solutionFile

Target.create "RunTests" (fun _ ->
runTests id testAssemblies
)
Target.create "RunTests" dotnetTest

let runFableTests _ =
Npm.test id

Target.create "RunFableTests" runFableTests

let fableAwareTests = [
"./tests/FsToolkit.ErrorHandling.Tests"
"./tests/FsToolkit.ErrorHandling.AsyncSeq.Tests"
]

Target.create "FemtoValidate" (fun _ ->
let result =
CreateProcess.fromRawCommand "dotnet" [ "femto"; "./tests/FsToolkit.ErrorHandling.Fable.Tests"; "--validate" ]
|> Proc.run
for testProject in fableAwareTests do
let result =
CreateProcess.fromRawCommand "dotnet" [ "femto"; testProject; "--validate" ]
|> Proc.run

if result.ExitCode <> 0
then
Fake.Testing.Common.FailedTestsException "Femto failed; perhaps you need to update the package.json?" |> raise
if result.ExitCode <> 0
then
Fake.Testing.Common.FailedTestsException "Femto failed; perhaps you need to update the package.json?" |> raise
)

let release = ReleaseNotes.load "RELEASE_NOTES.md"
Expand Down

0 comments on commit 4628373

Please sign in to comment.