Skip to content

Commit

Permalink
Finish new tests setup architecture to planned future of using integr…
Browse files Browse the repository at this point in the history
…ations tests too
  • Loading branch information
MangelMaxime committed Mar 14, 2024
1 parent 415f339 commit 826cb34
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Glutinum.Build/Glutinum.Build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<Compile Include="Utils/ChangelogParser.fs" />
<Compile Include="Utils/Changelog.fs" />
<Compile Include="Utils/Path.fs" />
<Compile Include="Test/Specs.fs" />
<Compile Include="Tasks/Cli.fs" />
<Compile Include="Tasks/Test/Specs.fs" />
<Compile Include="Web.fs" />
<Compile Include="Publish.fs" />
<Compile Include="Main.fs" />
Expand Down
1 change: 1 addition & 0 deletions src/Glutinum.Build/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Build.Main

open SimpleExec
open BlackFox.CommandLine
open Build.Tasks

// This is a basic help message, as the CLI parser is not a "real" CLI parser
// For now, it is enough as this is just a dev tool
Expand Down
1 change: 1 addition & 0 deletions src/Glutinum.Build/Publish.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open System.IO
open SimpleExec
open BlackFox.CommandLine
open Build.Utils
open Build.Tasks
open Build.Utils.Pnpm
open System.Text.RegularExpressions

Expand Down
18 changes: 18 additions & 0 deletions src/Glutinum.Build/Tasks/Cli.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Build.Tasks.Cli

open SimpleExec
open BlackFox.CommandLine

let handle (args: string list) =
let isWatch = args |> List.contains "--watch"

Command.Run(
"dotnet",
CmdLine.empty
|> CmdLine.appendRaw "fable"
|> CmdLine.appendRaw "src/Glutinum.Converter.CLI"
|> CmdLine.appendPrefix "--outDir" "dist"
|> CmdLine.appendRaw "--sourceMaps"
|> CmdLine.appendIf isWatch "--watch"
|> CmdLine.toString
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Build.Test.Specs
module Build.Tasks.Test.Specs

open BlackFox.CommandLine
open SimpleExec
Expand Down Expand Up @@ -40,6 +40,16 @@ let private generateSpecsTestFile () =
if Directory.Exists(generatedSpecsTestDestination) then
Directory.Delete(generatedSpecsTestDestination, true)

Directory.CreateDirectory(generatedSpecsTestDestination) |> ignore

// Copy the vitest.config.ts file, in the future we will be able to pass
// --clearScreen false to the CLI instead of relying on the config file
File.Copy(
"tests/specs/vitest.config.ts",
generatedSpecsTestDestination + "vitest.config.ts",
true
)

let specFiles =
Directory.GetFiles(
"tests/specs/references",
Expand Down Expand Up @@ -148,12 +158,12 @@ let handle (args: string list) =
CmdLine.empty
|> CmdLine.appendRaw "fable"
|> CmdLine.appendIf isWatch "watch"
|> CmdLine.appendRaw "src/Glutinum.Converter"
|> CmdLine.appendRaw "../../src/Glutinum.Converter"
|> CmdLine.appendRaw "--sourceMaps"
// Avoid strange logs because both Fable and Vitest rewrite the console
|> CmdLine.appendRaw "--verbose"
|> CmdLine.appendRaw "--run"
|> CmdLine.appendRaw vitestCmd
|> CmdLine.toString

Command.Run("dotnet", fableCmd)
Command.Run("dotnet", fableCmd, workingDirectory = "tests/specs")
2 changes: 1 addition & 1 deletion src/Glutinum.Converter/Generate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let generateBindingFile (filePath: string) =
let res = Transform.transform true readerResult.GlueAST

#if DEBUG
printfn "fsharhpAst: %A" res
printfn "fsharpAst: %A" res
#endif

let outFile =
Expand Down
8 changes: 8 additions & 0 deletions tests/specs/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vite'

export default defineConfig({
// Vitest don't support yet clearScreen option via CLI
// but it does respect it when it's set in the vite config
// https://github.com/vitest-dev/vitest/issues/5185
clearScreen: false,
})
3 changes: 3 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default [
'tests/specs/generated/'
]

0 comments on commit 826cb34

Please sign in to comment.