diff --git a/src/Fable.Transforms/Rust/Fable2Rust.fs b/src/Fable.Transforms/Rust/Fable2Rust.fs index 6c0b7943cf..f12cb78d84 100644 --- a/src/Fable.Transforms/Rust/Fable2Rust.fs +++ b/src/Fable.Transforms/Rust/Fable2Rust.fs @@ -6480,12 +6480,16 @@ module Compiler = ModuleDepth = 0 } + let entryPointItems = file.Declarations |> getEntryPointItems com ctx + let topAttrs = [ if isLastFileInProject com then // adds "no_std" to crate if feature is enabled mkInnerAttr "cfg_attr" [ "feature = \"no_std\""; "no_std" ] - mkInnerAttr "cfg_attr" [ "feature = \"no_std\""; "no_main" ] + // Libraries retain Cargo's test-harness entry point. + if not (List.isEmpty entryPointItems) then + mkInnerAttr "cfg_attr" [ "feature = \"no_std\""; "no_main" ] // TODO: make some of those conditional on compiler options mkInnerAttr "allow" [ "dead_code" ] @@ -6507,7 +6511,6 @@ module Compiler = // mkInnerAttr "feature" ["destructuring_assignment"] ] - let entryPointItems = file.Declarations |> getEntryPointItems com ctx let importItems = com.GetAllImports(ctx) |> transformImports com ctx let declItems = file.Declarations |> transformDeclarations com ctx let modItems = getModuleItems com ctx // global module imports diff --git a/tests/Beam/Fable.Tests.Beam.fsproj b/tests/Beam/Fable.Tests.Beam.fsproj index 54bd8eb912..f310f1716d 100644 --- a/tests/Beam/Fable.Tests.Beam.fsproj +++ b/tests/Beam/Fable.Tests.Beam.fsproj @@ -1,6 +1,10 @@ Exe + + false + false + false net10.0 Major false @@ -10,8 +14,9 @@ - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -24,6 +29,10 @@ + + + + @@ -104,6 +113,5 @@ - diff --git a/tests/Beam/Main.fs b/tests/Beam/Main.fs deleted file mode 100644 index b00af3eaac..0000000000 --- a/tests/Beam/Main.fs +++ /dev/null @@ -1,6 +0,0 @@ -#if FABLE_COMPILER -module Program -() -#else -module Program = let [] main _ = 0 -#endif diff --git a/tests/Beam/xunit.runner.json b/tests/Beam/xunit.runner.json new file mode 100644 index 0000000000..8641732346 --- /dev/null +++ b/tests/Beam/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "parallelizeTestCollections": false, + "maxParallelThreads": 1 +} diff --git a/tests/Php/Fable.Tests.Php.fsproj b/tests/Php/Fable.Tests.Php.fsproj index 509b2813e4..b670ce39b8 100644 --- a/tests/Php/Fable.Tests.Php.fsproj +++ b/tests/Php/Fable.Tests.Php.fsproj @@ -1,6 +1,10 @@ Exe + + false + false + false net10.0 Major false @@ -9,8 +13,9 @@ - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -31,7 +36,6 @@ - diff --git a/tests/Php/Main.fs b/tests/Php/Main.fs deleted file mode 100644 index ae5f6f6959..0000000000 --- a/tests/Php/Main.fs +++ /dev/null @@ -1,6 +0,0 @@ -#if FABLE_COMPILER -module Program -() -#else -module Program = let [] main _ = 0 -#endif \ No newline at end of file diff --git a/tests/Python/Fable.Tests.Python.fsproj b/tests/Python/Fable.Tests.Python.fsproj index 24ef0fbcf9..92bfcf5106 100644 --- a/tests/Python/Fable.Tests.Python.fsproj +++ b/tests/Python/Fable.Tests.Python.fsproj @@ -1,6 +1,10 @@ Exe + + false + false + false net10.0 Major false @@ -10,8 +14,9 @@ - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -22,6 +27,10 @@ + + + + @@ -88,6 +97,5 @@ - diff --git a/tests/Python/Main.fs b/tests/Python/Main.fs deleted file mode 100644 index ae5f6f6959..0000000000 --- a/tests/Python/Main.fs +++ /dev/null @@ -1,6 +0,0 @@ -#if FABLE_COMPILER -module Program -() -#else -module Program = let [] main _ = 0 -#endif \ No newline at end of file diff --git a/tests/Python/xunit.runner.json b/tests/Python/xunit.runner.json new file mode 100644 index 0000000000..8641732346 --- /dev/null +++ b/tests/Python/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "parallelizeTestCollections": false, + "maxParallelThreads": 1 +} diff --git a/tests/Rust/Fable.Tests.Rust.fsproj b/tests/Rust/Fable.Tests.Rust.fsproj index 2b9a48b8ba..dfd8096cf8 100644 --- a/tests/Rust/Fable.Tests.Rust.fsproj +++ b/tests/Rust/Fable.Tests.Rust.fsproj @@ -1,5 +1,10 @@ + Exe + + false + false + false net10.0 Major false @@ -8,8 +13,9 @@ - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/Rust/tests/src/lib.fs b/tests/Rust/tests/src/lib.fs index e448cd8f1f..dd4a08ea7a 100644 --- a/tests/Rust/tests/src/lib.fs +++ b/tests/Rust/tests/src/lib.fs @@ -5,7 +5,3 @@ open Fable.Core.Rust let _imports() = importAll "./ExtInteropTests.rs" () - -// Comment the main func when no longer needed (after migrating to xunit v3) -[] -let main _args = 0