Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Fable 5 to be used with Fable 4 plugins #3963

Merged
merged 7 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Fable.Transforms/Global/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type InlineExprLazy(f: Compiler -> InlineExpr) =

[<AutoOpen>]
module CompilerExt =
let private expectedVersionMatchesActual (expected: string) (actual: string) =
let expectedVersionMatchesActual (expected: string) (actual: string) =
try
let r = System.Text.RegularExpressions.Regex(@"^(\d+)\.(\d+)(?:\.(\d+))?")

Expand All @@ -116,10 +116,10 @@ module CompilerExt =
let actualMajor, actualMinor, actualPatch = parse actual
let expectedMajor, expectedMinor, expectedPatch = parse expected

// Fail also if actual major is bigger than expected major version
actualMajor = expectedMajor
&& (actualMinor > expectedMinor
|| (actualMinor = expectedMinor && actualPatch >= expectedPatch))
actualMajor > expectedMajor
|| (actualMajor = expectedMajor
&& (actualMinor > expectedMinor
|| (actualMinor = expectedMinor && actualPatch >= expectedPatch)))
with _ ->
false

Expand Down
24 changes: 24 additions & 0 deletions tests/Integration/Compiler/CompilerHelpersTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Fable.Tests.Compiler.CompilerHelpers

open Fable.Core
open Util.Testing
open Fable.Tests.Compiler.Util
open Fable.Tests.Compiler.Util.Compiler

let tests =
testList "Compiler Helpers" [
testCase "expectedVersionMatchesActual works for same major version" <| fun _ ->
Fable.CompilerExt.expectedVersionMatchesActual "5.0.0" "5.0.0" |> equal true
Fable.CompilerExt.expectedVersionMatchesActual "5.0.0" "5.0.1" |> equal true
Fable.CompilerExt.expectedVersionMatchesActual "5.1.0" "5.1.0" |> equal true

testCase "expectedVersionMatchesActual works if actual version is higher than expected version" <| fun _ ->
Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "5.0.0" |> equal true
Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "5.0.1" |> equal true
Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "5.1.0" |> equal true

testCase "expectedVersionMatchesActual reject if actual version is lower than expected version" <| fun _ ->
Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "3.0.0" |> equal false
Fable.CompilerExt.expectedVersionMatchesActual "4.0.1" "3.0.0" |> equal false
Fable.CompilerExt.expectedVersionMatchesActual "4.1.0" "3.0.0" |> equal false
]
3 changes: 2 additions & 1 deletion tests/Integration/Compiler/Fable.Tests.Compiler.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<Compile Include="Util/Compiler.fs" />
<Compile Include="CompilerMessagesTests.fs" />
<Compile Include="AnonRecordInInterfaceTests.fs" />
<Compile Include="CompilerHelpersTests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions tests/Integration/Compiler/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let allTests =
[
CompilerMessages.tests
AnonRecordInInterface.tests
CompilerHelpers.tests
]


Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Integration/CompilationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let tests =
Expect.equal exitCode 0 "Expected exit code to be 0"

let normalize content =
Regex.Replace(content, @"(/fable-library-js)[.0-9]+", "$1")
Regex.Replace(content, @"(/fable-library-js)[^/]+", "$1")
|> _.ReplaceLineEndings()
|> _.Trim()

Expand Down
Loading